Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
const-cloudinary committed Nov 19, 2023
1 parent b64c62d commit c7dc6bd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 1 addition & 6 deletions tests/Helpers/RequestAssertionsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@

use Cloudinary\Api\ApiClient;
use Cloudinary\Configuration\Configuration;
use Cloudinary\Configuration\Provisioning\ProvisioningAccountConfig;
use Cloudinary\Configuration\Provisioning\ProvisioningConfiguration;
use Psr\Http\Message\RequestInterface;

use GuzzleHttp\Psr7;
Expand Down Expand Up @@ -112,11 +110,8 @@ protected static function assertRequestUrl(RequestInterface $request, $path, $me
*/
protected static function assertAccountRequestUrl(RequestInterface $request, $path, $message = '')
{
$config = ProvisioningConfiguration::instance();

self::assertEquals(
'/' . ApiClient::apiVersion() . '/' . 'provisioning/accounts/' . $config->provisioningAccount->accountId
. $path,
'/' . ApiClient::apiVersion() . '/' . 'provisioning/accounts' . $path,
$request->getUri()->getPath(),
$message
);
Expand Down
12 changes: 9 additions & 3 deletions tests/Unit/Provisioning/AccessKeysTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ public function testAccessKeys()

$lastRequest = $mockAccApi->getMockHandler()->getLastRequest();

self::assertAccountRequestUrl($lastRequest, '/sub_accounts/' . self::SUB_ACCOUNT_ID . '/access_keys');
self::assertAccountRequestUrl(
$lastRequest,
'/' . self::ACCOUNT_ID . '/sub_accounts/' . self::SUB_ACCOUNT_ID . '/access_keys'
);

self::assertRequestGet($lastRequest);

Expand All @@ -53,7 +56,10 @@ public function testGenerateAccessKey()

$lastRequest = $mockAccApi->getMockHandler()->getLastRequest();

self::assertAccountRequestUrl($lastRequest, '/sub_accounts/' . self::SUB_ACCOUNT_ID . '/access_keys');
self::assertAccountRequestUrl(
$lastRequest,
'/' . self::ACCOUNT_ID . '/sub_accounts/' . self::SUB_ACCOUNT_ID . '/access_keys'
);
self::assertRequestPost($lastRequest);

self::assertRequestJsonBodySubset($lastRequest, ['enabled' => true, 'name' => 'test_key']);
Expand All @@ -76,7 +82,7 @@ public function testUpdateAccessKey()

self::assertAccountRequestUrl(
$lastRequest,
'/sub_accounts/' . self::SUB_ACCOUNT_ID . '/access_keys/' . self::API_KEY
'/' . self::ACCOUNT_ID . '/sub_accounts/' . self::SUB_ACCOUNT_ID . '/access_keys/' . self::API_KEY
);
self::assertRequestPut($lastRequest);

Expand Down

0 comments on commit c7dc6bd

Please sign in to comment.