From 069987b32d8166588932abfe8f89b0cfe8c4ae0d Mon Sep 17 00:00:00 2001 From: Vladimir Kolchin Date: Fri, 20 Jan 2023 10:37:23 +0100 Subject: [PATCH] add test for update-scopes method --- .../Methods/Version5/ApiClientModuleTest.php | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/RetailCrm/Tests/Methods/Version5/ApiClientModuleTest.php diff --git a/tests/RetailCrm/Tests/Methods/Version5/ApiClientModuleTest.php b/tests/RetailCrm/Tests/Methods/Version5/ApiClientModuleTest.php new file mode 100644 index 0000000..5cd7a34 --- /dev/null +++ b/tests/RetailCrm/Tests/Methods/Version5/ApiClientModuleTest.php @@ -0,0 +1,60 @@ +getMockBuilder(\RetailCrm\Http\Client::class) + ->disableOriginalConstructor() + ->setMethods(['makeRequest']) + ->getMock(); + + $requires = [ + 'scopes' => [ + "integration_read", + "integration_write" + ], + ]; + + $stub->expects(self::once()) + ->method('makeRequest') + ->with( + sprintf('/integration-modules/%s/update-scopes', $integrationCode), + "POST", + ['requires' => json_encode($requires)] + ) + ->willReturn( + (new ApiResponse(200, json_encode(['success' => true, 'apiKey' => 'test key']))) + ->asJsonResponse() + ) + ; + $client = static::getMockedApiClient($stub); + + /** @var \RetailCrm\Response\ApiResponse $response */ + $response = $client->request->integrationModulesUpdateScopes($integrationCode, $requires); + + static::assertInstanceOf('RetailCrm\Response\ApiResponse', $response); + static::assertEquals($response->getStatusCode(), 200); + static::assertTrue($response->isSuccessful()); + static::assertNotEmpty($response['apiKey']); + } +}