From 556010d46494350591bbf399fc628f36f06007b4 Mon Sep 17 00:00:00 2001 From: Bohdan Bobko <172895427+bhdnb@users.noreply.github.com> Date: Thu, 1 Oct 2026 15:42:35 +0300 Subject: [PATCH] test: replace JSON string fixtures with json_encode arrays --- tests/CrowdinApiClient/Api/AdvisorApiTest.php | 2 +- .../CrowdinApiClient/Api/AiGatewayApiTest.php | 110 ++-- tests/CrowdinApiClient/Api/BranchApiTest.php | 166 +++--- .../CrowdinApiClient/Api/DirectoryApiTest.php | 128 ++-- .../Api/Enterprise/AiGatewayApiTest.php | 110 ++-- .../Api/Enterprise/FieldApiTest.php | 1 - .../MachineTranslationEngineApiTest.php | 107 ++-- .../Api/Enterprise/ProjectApiTest.php | 542 ++++++++--------- .../Api/Enterprise/ReportArchiveApiTest.php | 177 +++--- .../Api/Enterprise/SecurityLogApiTest.php | 73 ++- .../Enterprise/StringCorrectionApiTest.php | 128 ++-- .../Enterprise/StringTranslationApiTest.php | 362 ++++++------ .../Api/Enterprise/TaskApiTest.php | 346 +++++------ .../Api/Enterprise/VendorApiTest.php | 37 +- .../Enterprise/WorkflowTemplateApiTest.php | 60 +- tests/CrowdinApiClient/Api/IssueApiTest.php | 204 ++++--- .../CrowdinApiClient/Api/LanguageApiTest.php | 195 +++--- .../Api/MachineTranslationEngineApiTest.php | 153 ++--- .../Api/OrganizationWebhookApiTest.php | 217 +++---- tests/CrowdinApiClient/Api/ProjectApiTest.php | 2 +- .../Api/ReportArchiveApiTest.php | 179 +++--- .../Api/ScreenshotApiTest.php | 555 +++++++++--------- .../Api/SecurityLogApiTest.php | 73 ++- .../Api/SourceStringApiTest.php | 296 +++++----- tests/CrowdinApiClient/Api/StorageApiTest.php | 51 +- .../Api/StringCommentApiTest.php | 471 +++++++-------- .../Api/StringsExporterSettingApiTest.php | 162 ++--- .../Api/TaskCommentApiTest.php | 138 +++-- .../Api/TranslationApiTest.php | 7 +- .../Api/TranslationMemoryApiTest.php | 15 +- tests/CrowdinApiClient/Api/WebhookApiTest.php | 220 +++---- tests/CrowdinApiClient/Model/LanguageTest.php | 14 +- .../CrowdinApiClient/Model/ScreenshotTest.php | 36 +- tests/CrowdinApiClient/Model/TagTest.php | 13 +- .../Model/TranslationMemoryTest.php | 12 +- tests/CrowdinApiClient/Model/WebhookTest.php | 21 +- 36 files changed, 2836 insertions(+), 2547 deletions(-) diff --git a/tests/CrowdinApiClient/Api/AdvisorApiTest.php b/tests/CrowdinApiClient/Api/AdvisorApiTest.php index 09f22599..1bb2d6c6 100644 --- a/tests/CrowdinApiClient/Api/AdvisorApiTest.php +++ b/tests/CrowdinApiClient/Api/AdvisorApiTest.php @@ -80,7 +80,7 @@ public function testCreateCheckForAllInspectors(): void $this->mockRequest([ 'path' => '/projects/2/advisors/checks', 'method' => 'post', - 'body' => '[]', + 'body' => json_encode([]), 'response' => $this->checkResponse(), ]); diff --git a/tests/CrowdinApiClient/Api/AiGatewayApiTest.php b/tests/CrowdinApiClient/Api/AiGatewayApiTest.php index d3c2eabb..55915356 100644 --- a/tests/CrowdinApiClient/Api/AiGatewayApiTest.php +++ b/tests/CrowdinApiClient/Api/AiGatewayApiTest.php @@ -11,16 +11,24 @@ public function testGatewayGet(): void $this->mockRequest([ 'path' => '/users/1/ai/providers/2/gateway/chat/completions', 'method' => 'get', - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayGet(1, 2, 'chat/completions'); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); $this->assertEquals('chat.completion', $response->getData()['object']); @@ -42,16 +50,24 @@ public function testGatewayPost(): void 'path' => '/users/1/ai/providers/2/gateway/chat/completions', 'method' => 'post', 'body' => json_encode($data), - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayPost(1, 2, 'chat/completions', $data); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); } @@ -72,16 +88,24 @@ public function testGatewayPut(): void 'path' => '/users/1/ai/providers/2/gateway/chat/completions', 'method' => 'put', 'body' => json_encode($data), - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayPut(1, 2, 'chat/completions', $data); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); } @@ -102,16 +126,24 @@ public function testGatewayPatch(): void 'path' => '/users/1/ai/providers/2/gateway/chat/completions', 'method' => 'patch', 'body' => json_encode($data), - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayPatch(1, 2, 'chat/completions', $data); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); } @@ -121,16 +153,24 @@ public function testGatewayDelete(): void $this->mockRequest([ 'path' => '/users/1/ai/providers/2/gateway/chat/completions', 'method' => 'delete', - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayDelete(1, 2, 'chat/completions'); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); } diff --git a/tests/CrowdinApiClient/Api/BranchApiTest.php b/tests/CrowdinApiClient/Api/BranchApiTest.php index 52db02b0..7a1e0f62 100644 --- a/tests/CrowdinApiClient/Api/BranchApiTest.php +++ b/tests/CrowdinApiClient/Api/BranchApiTest.php @@ -16,40 +16,39 @@ public function testList() $this->mockRequest([ 'uri' => 'https://api.crowdin.com/api/v2/projects/2/branches', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 34, - "projectId": 2, - "name": "develop-master", - "title": "Master branch", - "exportPattern": "%three_letters_code%", - "priority": "normal", - "createdAt": "2019-09-16T13:48:04+00:00", - "updatedAt": "2019-09-19T13:25:27+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 34, + 'projectId' => 2, + 'name' => 'develop-master', + 'title' => 'Master branch', + 'exportPattern' => '%three_letters_code%', + 'priority' => 'normal', + 'createdAt' => '2019-09-16T13:48:04+00:00', + 'updatedAt' => '2019-09-19T13:25:27+00:00', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $data = $this->crowdin->branch->list(2); $this->assertInstanceOf(ModelCollection::class, $data); $this->assertCount(1, $data); - /** - * @var Branch $branchModel - */ + + /** @var Branch $branchModel */ $branchModel = $data[0]; - $this->assertInstanceOf(Branch::class, $branchModel); + $this->assertInstanceOf(Branch::class, $branchModel); $this->assertEquals(34, $branchModel->getId()); $this->assertEquals(2, $branchModel->getProjectId()); $this->assertEquals('develop-master', $branchModel->getName()); @@ -102,24 +101,25 @@ public function testSearch(): void public function testGet() { - $this->mockRequestGet('/projects/2/branches/34', - '{ - "data": { - "id": 34, - "projectId": 2, - "name": "develop-master", - "title": "Master branch", - "exportPattern": "%three_letters_code%", - "priority": "normal", - "createdAt": "2019-09-16T13:48:04+00:00", - "updatedAt": "2019-09-19T13:25:27+00:00" - } - }'); + $this->mockRequestGet( + '/projects/2/branches/34', + json_encode([ + 'data' => [ + 'id' => 34, + 'projectId' => 2, + 'name' => 'develop-master', + 'title' => 'Master branch', + 'exportPattern' => '%three_letters_code%', + 'priority' => 'normal', + 'createdAt' => '2019-09-16T13:48:04+00:00', + 'updatedAt' => '2019-09-19T13:25:27+00:00', + ], + ]) + ); $branch = $this->crowdin->branch->get(2, 34); $this->assertInstanceOf(Branch::class, $branch); - $this->assertEquals(34, $branch->getId()); $this->assertEquals(2, $branch->getProjectId()); $this->assertEquals('develop-master', $branch->getName()); @@ -143,18 +143,18 @@ public function testCreate() 'path' => '/projects/2/branches', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 34, - "projectId": 2, - "name": "develop-master", - "title": "Master branch", - "exportPattern": "%three_letters_code%", - "priority": "normal", - "createdAt": "2019-09-16T13:48:04+00:00", - "updatedAt": "2019-09-19T13:25:27+00:00" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 34, + 'projectId' => 2, + 'name' => 'develop-master', + 'title' => 'Master branch', + 'exportPattern' => '%three_letters_code%', + 'priority' => 'normal', + 'createdAt' => '2019-09-16T13:48:04+00:00', + 'updatedAt' => '2019-09-19T13:25:27+00:00', + ], + ]), ]); $branch = $this->crowdin->branch->create(2, $params); @@ -429,39 +429,43 @@ public function testGetMergeSummary(): void public function testUpdate() { $mock = $this->mockClient - ->willReturn('{ - "data": { - "id": 34, - "projectId": 2, - "name": "develop-master", - "title": "Master branch", - "exportPattern": "%three_letters_code%", - "priority": "normal", - "createdAt": "2019-09-16T13:48:04+00:00", - "updatedAt": "2019-09-19T13:25:27+00:00" - } - }'); + ->willReturn( + json_encode([ + 'data' => [ + 'id' => 34, + 'projectId' => 2, + 'name' => 'develop-master', + 'title' => 'Master branch', + 'exportPattern' => '%three_letters_code%', + 'priority' => 'normal', + 'createdAt' => '2019-09-16T13:48:04+00:00', + 'updatedAt' => '2019-09-19T13:25:27+00:00', + ], + ]) + ); $branch = $this->crowdin->branch->get(2, 34); - $branch->setName('develop-master-edit'); - $mock->will($this->returnCallback(function ($method, $uri, $options) { - $this->assertEquals('patch', $method); - $this->assertEquals('https://api.crowdin.com/api/v2/projects/2/branches/34', $uri); - return '{ - "data": { - "id": 34, - "projectId": 2, - "name": "develop-master-edit", - "title": "Master branch", - "exportPattern": "%three_letters_code%", - "priority": "normal", - "createdAt": "2019-09-16T13:48:04+00:00", - "updatedAt": "2019-09-19T13:25:27+00:00" - } - }'; - })); + $mock->will( + $this->returnCallback(function ($method, $uri) { + $this->assertEquals('patch', $method); + $this->assertEquals('https://api.crowdin.com/api/v2/projects/2/branches/34', $uri); + + return json_encode([ + 'data' => [ + 'id' => 34, + 'projectId' => 2, + 'name' => 'develop-master-edit', + 'title' => 'Master branch', + 'exportPattern' => '%three_letters_code%', + 'priority' => 'normal', + 'createdAt' => '2019-09-16T13:48:04+00:00', + 'updatedAt' => '2019-09-19T13:25:27+00:00', + ], + ]); + }) + ); $branchNew = $this->crowdin->branch->update($branch); diff --git a/tests/CrowdinApiClient/Api/DirectoryApiTest.php b/tests/CrowdinApiClient/Api/DirectoryApiTest.php index 9c847d9d..7d81e841 100644 --- a/tests/CrowdinApiClient/Api/DirectoryApiTest.php +++ b/tests/CrowdinApiClient/Api/DirectoryApiTest.php @@ -13,30 +13,30 @@ public function testList() $this->mockRequest([ 'path' => '/projects/2/directories', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 4, - "projectId": 2, - "branchId": 34, - "directoryId": 0, - "name": "main", - "title": "", - "exportPattern": "/localization/%locale%/%file_name%", - "priority": "normal", - "createdAt": "2019-09-19T14:14:00+00:00", - "updatedAt": "2019-09-19T14:14:00+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 4, + 'projectId' => 2, + 'branchId' => 34, + 'directoryId' => 0, + 'name' => 'main', + 'title' => '', + 'exportPattern' => '/localization/%locale%/%file_name%', + 'priority' => 'normal', + 'createdAt' => '2019-09-19T14:14:00+00:00', + 'updatedAt' => '2019-09-19T14:14:00+00:00', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $directories = $this->crowdin->directory->list(2); @@ -91,18 +91,21 @@ public function testSearch(): void public function testGetAndUpdate() { - $this->mockRequestGet('/projects/2/directories/34', '{ - "data": { - "id": 34, - "projectId": 2, - "name": "develop-master", - "title": "Master branch", - "exportPattern": "%three_letters_code%", - "priority": "normal", - "createdAt": "2019-09-16T13:48:04+00:00", - "updatedAt": "2019-09-19T13:25:27+00:00" - } - }'); + $this->mockRequestGet( + '/projects/2/directories/34', + json_encode([ + 'data' => [ + 'id' => 34, + 'projectId' => 2, + 'name' => 'develop-master', + 'title' => 'Master branch', + 'exportPattern' => '%three_letters_code%', + 'priority' => 'normal', + 'createdAt' => '2019-09-16T13:48:04+00:00', + 'updatedAt' => '2019-09-19T13:25:27+00:00', + ], + ]) + ); $directory = $this->crowdin->directory->get(2, 34); @@ -111,20 +114,24 @@ public function testGetAndUpdate() $directory->setName('edit test'); - $this->mockRequestPatch('/projects/2/directories/34', '{ - "data": { - "id": 34, - "projectId": 2, - "name": "edit test", - "title": "Master branch", - "exportPattern": "%three_letters_code%", - "priority": "normal", - "createdAt": "2019-09-16T13:48:04+00:00", - "updatedAt": "2019-09-19T13:25:27+00:00" - } - }'); + $this->mockRequestPatch( + '/projects/2/directories/34', + json_encode([ + 'data' => [ + 'id' => 34, + 'projectId' => 2, + 'name' => 'edit test', + 'title' => 'Master branch', + 'exportPattern' => '%three_letters_code%', + 'priority' => 'normal', + 'createdAt' => '2019-09-16T13:48:04+00:00', + 'updatedAt' => '2019-09-19T13:25:27+00:00', + ], + ]) + ); $this->crowdin->directory->update($directory); + $this->assertInstanceOf(Directory::class, $directory); $this->assertEquals(34, $directory->getId()); $this->assertEquals('edit test', $directory->getName()); @@ -143,21 +150,22 @@ public function testCreate() 'path' => '/projects/2/directories', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 34, - "projectId": 2, - "name": "develop-master", - "title": "Master branch", - "exportPattern": "%three_letters_code%", - "priority": "normal", - "createdAt": "2019-09-16T13:48:04+00:00", - "updatedAt": "2019-09-19T13:25:27+00:00" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 34, + 'projectId' => 2, + 'name' => 'develop-master', + 'title' => 'Master branch', + 'exportPattern' => '%three_letters_code%', + 'priority' => 'normal', + 'createdAt' => '2019-09-16T13:48:04+00:00', + 'updatedAt' => '2019-09-19T13:25:27+00:00', + ], + ]), ]); $directory = $this->crowdin->directory->create(2, $params); + $this->assertInstanceOf(Directory::class, $directory); $this->assertEquals(34, $directory->getId()); } diff --git a/tests/CrowdinApiClient/Api/Enterprise/AiGatewayApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/AiGatewayApiTest.php index 4b88c527..7b72f598 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/AiGatewayApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/AiGatewayApiTest.php @@ -11,16 +11,24 @@ public function testGatewayGet(): void $this->mockRequest([ 'path' => '/ai/providers/2/gateway/chat/completions', 'method' => 'get', - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayGet(2, 'chat/completions'); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); $this->assertEquals('chat.completion', $response->getData()['object']); @@ -42,16 +50,24 @@ public function testGatewayPost(): void 'path' => '/ai/providers/2/gateway/chat/completions', 'method' => 'post', 'body' => json_encode($data), - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayPost(2, 'chat/completions', $data); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); } @@ -72,16 +88,24 @@ public function testGatewayPut(): void 'path' => '/ai/providers/2/gateway/chat/completions', 'method' => 'put', 'body' => json_encode($data), - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayPut(2, 'chat/completions', $data); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); } @@ -102,16 +126,24 @@ public function testGatewayPatch(): void 'path' => '/ai/providers/2/gateway/chat/completions', 'method' => 'patch', 'body' => json_encode($data), - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayPatch(2, 'chat/completions', $data); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); } @@ -121,16 +153,24 @@ public function testGatewayDelete(): void $this->mockRequest([ 'path' => '/ai/providers/2/gateway/chat/completions', 'method' => 'delete', - 'response' => '{ - "data": { - "id": "chatcmpl-abc123", - "object": "chat.completion", - "choices": [{"message": {"role": "assistant", "content": "Hello!"}}] - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 'chatcmpl-abc123', + 'object' => 'chat.completion', + 'choices' => [ + [ + 'message' => [ + 'role' => 'assistant', + 'content' => 'Hello!', + ], + ], + ], + ], + ]), ]); $response = $this->crowdin->aiGateway->gatewayDelete(2, 'chat/completions'); + $this->assertInstanceOf(AiGatewayResponse::class, $response); $this->assertEquals('chatcmpl-abc123', $response->getData()['id']); } diff --git a/tests/CrowdinApiClient/Api/Enterprise/FieldApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/FieldApiTest.php index da95c9dd..3127634d 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/FieldApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/FieldApiTest.php @@ -109,7 +109,6 @@ public function testGetAndUpdate(): void public function testDelete(): void { $this->mockRequestDelete('/fields/1'); - $this->crowdin->field->delete(1); } } diff --git a/tests/CrowdinApiClient/Api/Enterprise/MachineTranslationEngineApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/MachineTranslationEngineApiTest.php index 1d3e01dc..eb76ab18 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/MachineTranslationEngineApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/MachineTranslationEngineApiTest.php @@ -11,13 +11,11 @@ public function testCreate() $params = [ 'name' => 'string', 'type' => 'google', - 'credentials' => + 'credentials' => [ [ - 0 => - [ - 'apiKey' => 'string', - ], + 'apiKey' => 'string', ], + ], 'groupId' => 0, ]; @@ -25,69 +23,78 @@ public function testCreate() 'path' => '/mts', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 2, - "groupId": 2, - "name": "Crowdin Translate (beta)", - "type": "crowdin", - "credentials": { - "crowdin_nmt": 1, - "crowdin_nmt_multi_translations": 1 - }, - "projectIds": [ - 1 - ] - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 2, + 'groupId' => 2, + 'name' => 'Crowdin Translate (beta)', + 'type' => 'crowdin', + 'credentials' => [ + 'crowdin_nmt' => 1, + 'crowdin_nmt_multi_translations' => 1, + ], + 'projectIds' => [ + 1, + ], + ], + ]), ]); $machineTranslationEngine = $this->crowdin->machineTranslationEngine->create($params); + $this->assertInstanceOf(MachineTranslationEngine::class, $machineTranslationEngine); $this->assertEquals(2, $machineTranslationEngine->getId()); } public function testGetAndUpdate() { - $this->mockRequestGet('/mts/2', '{ - "data": { - "id": 2, - "groupId": 2, - "name": "Crowdin Translate (beta)", - "type": "crowdin", - "credentials": { - "crowdin_nmt": 1, - "crowdin_nmt_multi_translations": 1 - }, - "projectIds": [ - 1 - ] - } - }'); + $this->mockRequestGet( + '/mts/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'groupId' => 2, + 'name' => 'Crowdin Translate (beta)', + 'type' => 'crowdin', + 'credentials' => [ + 'crowdin_nmt' => 1, + 'crowdin_nmt_multi_translations' => 1, + ], + 'projectIds' => [ + 1, + ], + ], + ]) + ); $machineTranslationEngine = $this->crowdin->machineTranslationEngine->get(2); + $this->assertInstanceOf(MachineTranslationEngine::class, $machineTranslationEngine); $this->assertEquals(2, $machineTranslationEngine->getId()); $machineTranslationEngine->setName('test edit'); - $this->mockRequestPatch('/mts/2', '{ - "data": { - "id": 2, - "groupId": 2, - "name": "test edit", - "type": "crowdin", - "credentials": { - "crowdin_nmt": 1, - "crowdin_nmt_multi_translations": 1 - }, - "projectIds": [ - 1 - ] - } - }'); + $this->mockRequestPatch( + '/mts/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'groupId' => 2, + 'name' => 'test edit', + 'type' => 'crowdin', + 'credentials' => [ + 'crowdin_nmt' => 1, + 'crowdin_nmt_multi_translations' => 1, + ], + 'projectIds' => [ + 1, + ], + ], + ]) + ); $machineTranslationEngine = $this->crowdin->machineTranslationEngine->update($machineTranslationEngine); + $this->assertInstanceOf(MachineTranslationEngine::class, $machineTranslationEngine); $this->assertEquals(2, $machineTranslationEngine->getId()); $this->assertEquals('test edit', $machineTranslationEngine->getName()); diff --git a/tests/CrowdinApiClient/Api/Enterprise/ProjectApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/ProjectApiTest.php index 24b11357..573de880 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/ProjectApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/ProjectApiTest.php @@ -12,38 +12,38 @@ public function testList() $this->mockRequest([ 'path' => '/projects', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 8, - "groupId": 4, - "userId": 6, - "sourceLanguageId": "es", - "targetLanguageIds": [ - "uk" + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 8, + 'groupId' => 4, + 'userId' => 6, + 'sourceLanguageId' => 'es', + 'targetLanguageIds' => [ + 'uk', + ], + 'name' => 'Knowledge Base', + 'identifier' => '1f198a4e907688bc65834a6d5a6000c3', + 'description' => 'Vault of all terms and their explanation', + 'logo' => 'data:image/png;base64,iVBORw0KGgoAAAAN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IBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=', + 'background' => 'string', + 'isExternal' => false, + 'externalType' => 'proofread', + 'workflowId' => 3, + 'hasCrowdsourcing' => false, + 'createdAt' => '2019-09-20T11:34:40+00:00', + 'updatedAt' => '2019-09-20T11:34:40+00:00', ], - "name": "Knowledge Base", - "identifier": "1f198a4e907688bc65834a6d5a6000c3", - "description": "Vault of all terms and their explanation", - "logo": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+ArlpNNmzQBy+e/pZzV1tXjx7g9vT4qgGE51fiQ0fhg6SKYTB4Os8amZqyPT0bZwwoXbKY/huUko4KH4fP3lsPLy9NhZrXa8OuefSguveeCzVyDYTnBkIFB+Ob9KPTx9XGY2e0t2L4vA1duFOu/mAsxrG7q598X5tgVCAzwV84TDx7B2YIrOm/legyrG3x9vGGOjcaQgUHKecaxXOScPq/zVu6BYXWRyeSBL1ZGYFTwMOX8+Nk/kX70hM5buQ+G1U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sVixaakNFgsVuWcRz5PMKxOunO/DMlZ2lfAeOTzGMPqgmNnLuD85ULljEc+jzGsLopLzUR5RZVyxiMfhtVljU3N2JyUpnktzOhHPgyrG4pL7yHtt+OacyMf+TCsbsrOO41Lf99Qzox85MOwnGBbygFUVtcoZ0Y98mFYTlDf0IgtyemaX8NtxCMfhuUk127dRkZOrnJmxCMfhuVEmcfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=", - "background": "string", - "isExternal": false, - "externalType": "proofread", - "workflowId": 3, - "hasCrowdsourcing": false, - "createdAt": "2019-09-20T11:34:40+00:00", - "updatedAt": "2019-09-20T11:34:40+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $projects = $this->crowdin->project->list(); @@ -61,10 +61,9 @@ public function testCreate() 'sourceLanguageId' => 'en', 'groupId' => 1, 'templateId' => 0, - 'targetLanguageIds' => - [ - 0 => 'uk', - ], + 'targetLanguageIds' => [ + 'uk', + ], 'vendorId' => 52760, 'mtEngineId' => 2, 'description' => 'Vault of all terms and their explanation', @@ -74,69 +73,73 @@ public function testCreate() 'path' => '/projects', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 8, - "groupId": 4, - "userId": 6, - "sourceLanguageId": "es", - "targetLanguageIds": [ - "uk" + 'response' => json_encode([ + 'data' => [ + 'id' => 8, + 'groupId' => 4, + 'userId' => 6, + 'sourceLanguageId' => 'es', + 'targetLanguageIds' => [ + 'uk', + ], + 'name' => 'Knowledge Base', + 'identifier' => '1f198a4e907688bc65834a6d5a6000c3', + 'description' => 'Vault of all terms and their explanation', + 'logo' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+ArlpNNmzQBy+e/pZzV1tXjx7g9vT4qgGE51fiQ0fhg6SKYTB4Os8amZqyPT0bZwwoXbKY/huUko4KH4fP3lsPLy9NhZrXa8OuefSguveeCzVyDYTnBkIFB+Ob9KPTx9XGY2e0t2L4vA1duFOu/mAsxrG7q598X5tgVCAzwV84TDx7B2YIrOm/legyrG3x9vGGOjcaQgUHKecaxXOScPq/zVu6BYXWRyeSBL1ZGYFTwMOX8+Nk/kX70hM5buQ+G1UUfRyzG+JDRytn5y4XYfSBL543cC8PqguiFoZg68SXlrPBmCbYk70dLi85LuRmG1UkL3piOudOnKmcld+/jl13JsNnsOm/lfhhWJ0x/eSKWzZujnJU9rMC6nUloarbovJV7YlgdNPHFEMSGL1TOqmpq8VNcAmrq6nXeyn0xrA4YMyIYn0Uvhaen46+rvqERa3ck4mFltQs2c18Mqx1DBw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cfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=', + 'background' => 'string', + 'isExternal' => false, + 'externalType' => 'proofread', + 'workflowId' => 3, + 'hiddenStringsProofreadersAccess' => true, + 'inContextProcessHiddenStrings' => false, + 'glossaryAccess' => true, + 'normalizePlaceholder' => false, + 'saveMetaInfoInSource' => true, + 'notificationSettings' => [ + 'translatorNewStrings' => 'false', + 'managerNewStrings' => 'false', + 'managerLanguageCompleted' => 'false', ], - "name": "Knowledge Base", - "identifier": "1f198a4e907688bc65834a6d5a6000c3", - "description": "Vault of all terms and their explanation", - "logo": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+Ar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nDBmW3d6CPZlHkHI4RzlPzjqKkrv3lTMvL0+sjgrXfO+LHjNkWBk5uW2+KtlsdmxMTNV8x33Y4IGICZsvtV6vYMiwKqrbv/hQXlGF+HTt28wzXpmkeWmVDBpWR50tuIIT5/I156sWL8CgoPbfZDUihtWOhMxszVs4PPLRxrDaYbXasDExFc0aN5x55KPGsDrgQfkjJGRma8555OOIYXVQ3oVLOH3xL+WMRz6OGFYn7Nh/CA/KHylnPPJpjWF1gsVixaakNFgsVuWcRz5PMKxOunO/DMlZ2lfAeOTzGMPqgmNnLuD85ULljEc+jzGsLopLzUR5RZVyxiMfhtVljU3N2JyUpnktzOhHPgyrG4pL7yHtt+OacyMf+TCsbsrOO41Lf99Qzox85MOwnGBbygFUVtcoZ0Y98mFYTlDf0IgtyemaX8NtxCMfhuUk127dRkZOrnJmxCMfhuVEmcfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=", - "background": "string", - "isExternal": false, - "externalType": "proofread", - "workflowId": 3, - "hiddenStringsProofreadersAccess": true, - "inContextProcessHiddenStrings": false, - "glossaryAccess": true, - "normalizePlaceholder": false, - "saveMetaInfoInSource": true, - "notificationSettings": { - "translatorNewStrings": "false", - "managerNewStrings": "false", - "managerLanguageCompleted": "false" - }, - "hasCrowdsourcing": false, - "createdAt": "2019-09-20T11:34:40+00:00", - "updatedAt": "2019-09-20T11:34:40+00:00" - } - }' + 'hasCrowdsourcing' => false, + 'createdAt' => '2019-09-20T11:34:40+00:00', + 'updatedAt' => '2019-09-20T11:34:40+00:00', + ], + ]), ]); $project = $this->crowdin->project->create($params); + $this->assertInstanceOf(Project::class, $project); $this->assertEquals(8, $project->getId()); } public function testInfoGetAndUpdate() { - $this->mockRequestGet('/projects/8', '{ - "data": { - "id": 8, - "groupId": 4, - "userId": 6, - "sourceLanguageId": "es", - "targetLanguageIds": [ - "uk" - ], - "name": "Knowledge Base", - "identifier": "1f198a4e907688bc65834a6d5a6000c3", - "description": "Vault of all terms and their explanation", - "logo": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+ArlpNNmzQBy+e/pZzV1tXjx7g9vT4qgGE51fiQ0fhg6SKYTB4Os8amZqyPT0bZwwoXbKY/huUko4KH4fP3lsPLy9NhZrXa8OuefSguveeCzVyDYTnBkIFB+Ob9KPTx9XGY2e0t2L4vA1duFOu/mAsxrG7q598X5tgVCAzwV84TDx7B2YIrOm/legyrG3x9vGGOjcaQgUHKecaxXOScPq/zVu6BYXWRyeSBL1ZGYFTwMOX8+Nk/kX70hM5buQ+G1UUfRyzG+JDRytn5y4XYfSBL543cC8PqguiFoZg68SXlrPBmCbYk70dLi85LuRmG1UkL3piOudOn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goPbfZDUihtWOhMxszVs4PPLRxrDaYbXasDExFc0aN5x55KPGsDrgQfkjJGRma8555OOIYXVQ3oVLOH3xL+WMRz6OGFYn7Nh/CA/KHylnPPJpjWF1gsVixaakNFgsVuWcRz5PMKxOunO/DMlZ2lfAeOTzGMPqgmNnLuD85ULljEc+jzGsLopLzUR5RZVyxiMfhtVljU3N2JyUpnktzOhHPgyrG4pL7yHtt+OacyMf+TCsbsrOO41Lf99Qzox85MOwnGBbygFUVtcoZ0Y98mFYTlDf0IgtyemaX8NtxCMfhuUk127dRkZOrnJmxCMfhuVEmcfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=", - "isExternal": false, - "externalType": "proofread", - "workflowId": 3, - "hasCrowdsourcing": false, - "createdAt": "2019-09-20T11:34:40+00:00", - "updatedAt": "2019-09-20T11:34:40+00:00" - } - }'); + $this->mockRequestGet( + '/projects/8', + json_encode([ + 'data' => [ + 'id' => 8, + 'groupId' => 4, + 'userId' => 6, + 'sourceLanguageId' => 'es', + 'targetLanguageIds' => [ + 'uk', + ], + 'name' => 'Knowledge Base', + 'identifier' => '1f198a4e907688bc65834a6d5a6000c3', + 'description' => 'Vault of all terms and their explanation', + 'logo' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIq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wyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=', + 'isExternal' => false, + 'externalType' => 'proofread', + 'workflowId' => 3, + 'hasCrowdsourcing' => false, + 'createdAt' => '2019-09-20T11:34:40+00:00', + 'updatedAt' => '2019-09-20T11:34:40+00:00', + ], + ]) + ); $project = $this->crowdin->project->get(8); @@ -144,38 +147,42 @@ public function testInfoGetAndUpdate() $this->assertEquals(8, $project->getId()); $project->setName('edit test'); - $this->mockRequestPatch('/projects/8', '{ - "data": { - "id": 8, - "groupId": 4, - "userId": 6, - "sourceLanguageId": "es", - "targetLanguageIds": [ - "uk" - ], - "name": "edit test", - "identifier": "1f198a4e907688bc65834a6d5a6000c3", - "description": "Vault of all terms and their explanation", - "logo": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+ArlpNNmzQBy+e/pZzV1tXjx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zZFiq/1MVl95D0e1S5fMmkwc+Wh7W5j+b1Johw3ra5es38cO2XdiUtB919Q3KZ/r3C8CHy97VebOey/BhncwvwPr4JFgsVlRUVSMu7aDms5PGPo9Qjc+7U2uGDutw7ilsT8lo9Y56/tVr+P3UOc2/s2zem5qfeqAnDBmW3d6CPZlHkHI4RzlPzjqKkrv3lTMvL0+sjgrXfO+LHjNkWBk5uW2+KtlsdmxMTNV8x33Y4IGICZsvtV6vYMiwKqrbv/hQXlGF+HTt28wzXpmkeWmVDBpWR50tuIIT5/I156sWL8CgoPbfZDUihtWOhMxszVs4PPLRxrDaYbXasDExFc0aN5x55KPGsDrgQfkjJGRma8555OOIYXVQ3oVLOH3xL+WMRz6OGFYn7Nh/CA/KHylnPPJpjWF1gsVixaakNFgsVuWcRz5PMKxOunO/DMlZ2lfAeOTzGMPqgmNnLuD85ULljEc+jzGsLopLzUR5RZVyxiMfhtVljU3N2JyUpnktzOhHPgyrG4pL7yHtt+OacyMf+TCsbsrOO41Lf99Qzox85MOwnGBbygFUVtcoZ0Y98mFYTlDf0IgtyemaX8NtxCMfhuUk127dRkZOrnJmxCMfhuVEmcfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=", - "isExternal": false, - "externalType": "proofread", - "workflowId": 3, - "hasCrowdsourcing": false, - "hiddenStringsProofreadersAccess": true, - "inContextProcessHiddenStrings": false, - "glossaryAccess": true, - "normalizePlaceholder": false, - "saveMetaInfoInSource": true, - "notificationSettings": { - "translatorNewStrings": "false", - "managerNewStrings": "false", - "managerLanguageCompleted": "false" - }, - "createdAt": "2019-09-20T11:34:40+00:00", - "updatedAt": "2019-09-20T11:34:40+00:00" - } - }'); + + $this->mockRequestPatch( + '/projects/8', + json_encode([ + 'data' => [ + 'id' => 8, + 'groupId' => 4, + 'userId' => 6, + 'sourceLanguageId' => 'es', + 'targetLanguageIds' => [ + 'uk', + ], + 'name' => 'edit test', + 'identifier' => '1f198a4e907688bc65834a6d5a6000c3', + 'description' => 'Vault of all terms and their explanation', + 'logo' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+ArlpNNmzQBy+e/pZzV1tXjx7g9vT4qgGE51fiQ0fhg6SKYTB4Os8amZqyPT0bZwwoXbKY/huUko4KH4fP3lsPLy9NhZrXa8OuefSguveeCzVyDYTnBkIFB+Ob9KPTx9XGY2e0t2L4vA1duFOu/mAsxrG7q598X5tgVCAzwV84TDx7B2YIrOm/legyrG3x9vGGOjcaQgUHKecaxXOScPq/zVu6BYXWRyeSBL1ZGYFTwMOX8+Nk/kX70hM5buQ+G1UUfRyzG+JDRytn5y4XYfSBL543cC8PqguiFoZg68SXlrPBmCbYk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WmVDBpWR50tuIIT5/I156sWL8CgoPbfZDUihtWOhMxszVs4PPLRxrDaYbXasDExFc0aN5x55KPGsDrgQfkjJGRma8555OOIYXVQ3oVLOH3xL+WMRz6OGFYn7Nh/CA/KHylnPPJpjWF1gsVixaakNFgsVuWcRz5PMKxOunO/DMlZ2lfAeOTzGMPqgmNnLuD85ULljEc+jzGsLopLzUR5RZVyxiMfhtVljU3N2JyUpnktzOhHPgyrG4pL7yHtt+OacyMf+TCsbsrOO41Lf99Qzox85MOwnGBbygFUVtcoZ0Y98mFYTlDf0IgtyemaX8NtxCMfhuUk127dRkZOrnJmxCMfhuVEmcfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=', + 'isExternal' => false, + 'externalType' => 'proofread', + 'workflowId' => 3, + 'hasCrowdsourcing' => false, + 'hiddenStringsProofreadersAccess' => true, + 'inContextProcessHiddenStrings' => false, + 'glossaryAccess' => true, + 'normalizePlaceholder' => false, + 'saveMetaInfoInSource' => true, + 'notificationSettings' => [ + 'translatorNewStrings' => 'false', + 'managerNewStrings' => 'false', + 'managerLanguageCompleted' => 'false', + ], + 'createdAt' => '2019-09-20T11:34:40+00:00', + 'updatedAt' => '2019-09-20T11:34:40+00:00', + ], + ]) + ); $project = $this->crowdin->project->update($project); @@ -186,78 +193,81 @@ public function testInfoGetAndUpdate() public function testGetAndUpdate() { - $this->mockRequestGet('/projects/8', '{ - "data": { - "id": 8, - "groupId": 4, - "userId": 6, - "sourceLanguageId": "es", - "targetLanguageIds": [ - "uk" - ], - "name": "Knowledge Base", - "identifier": "1f198a4e907688bc65834a6d5a6000c3", - "description": "Vault of all terms and their explanation", - "logo": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+ArlpNNmzQBy+e/pZzV1tXjx7g9vT4qgGE51fiQ0fhg6SKYTB4Os8amZqyPT0bZwwoXbKY/huUko4KH4fP3lsPLy9NhZrXa8OuefSguveeCzVyDYTnBkIFB+Ob9KPTx9XGY2e0t2L4vA1duFOu/mAsxrG7q598X5tgVCAzwV84TDx7B2YIrOm/legyrG3x9vGGOjcaQgUHKecaxXOScPq/zVu6BYXWRyeSBL1ZGYFTwMOX8+Nk/kX70hM5buQ+G1UUfRyzG+JDRytn5y4XYfSBL543cC8PqguiFoZg68SXlrPBmCbYk70dLi85LuRmG1UkL3piOudOnKmcld+/jl13JsNnsOm/lfhhWJ0x/eSKWzZujnJU9rMC6nUloarbovJV7YlgdNPHFEMSGL1TOqmpq8VNcAmrq6nXeyn0xrA4YMyIYn0Uvhaen46+rvqERa3ck4mFltQs2c18Mqx1DBw3A16si4ePj7TCzWKz4eddelD74xwWbuTeG1YbAAH+YY1cgwL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RZVyxiMfhtVljU3N2JyUpnktzOhHPgyrG4pL7yHtt+OacyMf+TCsbsrOO41Lf99Qzox85MOwnGBbygFUVtcoZ0Y98mFYTlDf0IgtyemaX8NtxCMfhuUk127dRkZOrnJmxCMfhuVEmcfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=", - "isExternal": false, - "externalType": "proofread", - "workflowId": 3, - "hasCrowdsourcing": false, - "createdAt": "2019-09-20T11:34:40+00:00", - "updatedAt": "2019-09-20T11:34:40+00:00", - "translateDuplicates": 1, - "isMtAllowed": true, - "autoSubstitution": true, - "skipUntranslatedStrings": false, - "skipUntranslatedFiles": false, - "exportApprovedOnly": false, - "autoTranslateDialects": true, - "publicDownloads": true, - "useGlobalTm": false, - "inContext": true, - "inContextPseudoLanguageId": "uk", - "qaCheckIsActive": true, - "qaCheckCategories": { - "empty": true, - "size": true, - "tags": true, - "spaces": true, - "variables": true, - "punctuation": true, - "symbolRegister": true, - "specialSymbols": true, - "wrongTranslation": true, - "spellcheck": true, - "icu": true - }, - "customQaCheckIds": [ - "1" - ], - "languageMapping": { - "uk": { - "name": "Ukranian", - "two_letters_code": "ua", - "three_letters_code": "ukr", - "locale": "uk-UA", - "locale_with_underscore": "uk_UA", - "android_code": "uk-rUA", - "osx_code": "ua.lproj", - "osx_locale": "ua" - } - }, - "hiddenStringsProofreadersAccess": true, - "inContextProcessHiddenStrings": false, - "glossaryAccess": true, - "normalizePlaceholder": false, - "saveMetaInfoInSource": true, - "notificationSettings": { - "translatorNewStrings": "false", - "managerNewStrings": "false", - "managerLanguageCompleted": "false" - } - } - }'); + $this->mockRequestGet( + '/projects/8', + json_encode([ + 'data' => [ + 'id' => 8, + 'groupId' => 4, + 'userId' => 6, + 'sourceLanguageId' => 'es', + 'targetLanguageIds' => [ + 'uk', + ], + 'name' => 'Knowledge Base', + 'identifier' => '1f198a4e907688bc65834a6d5a6000c3', + 'description' => 'Vault of all terms and their explanation', + 'logo' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+ArlpNNmzQBy+e/pZzV1tXjx7g9vT4qgGE51fiQ0fhg6SKYTB4Os8amZqyPT0bZwwoXbKY/huUko4KH4fP3lsPLy9NhZrXa8OuefSguveeCzVyDYTnBkIFB+Ob9KPTx9XGY2e0t2L4vA1duFOu/mAsxrG7q598X5tgVCAzwV84TDx7B2YIrOm/legyrG3x9vGGOjcaQgUHKecaxXOScPq/zVu6BYXWRyeSBL1ZGYFTwMOX8+Nk/kX70hM5buQ+G1UUfRyzG+JDRytn5y4XYfSBL543cC8PqguiFoZg68SXlrPBmCbYk70dLi85LuRmG1UkL3piOudOnKmcld+/jl13JsNnsOm/lf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Vs4PPLRxrDaYbXasDExFc0aN5x55KPGsDrgQfkjJGRma8555OOIYXVQ3oVLOH3xL+WMRz6OGFYn7Nh/CA/KHylnPPJpjWF1gsVixaakNFgsVuWcRz5PMKxOunO/DMlZ2lfAeOTzGMPqgmNnLuD85ULljEc+jzGsLopLzUR5RZVyxiMfhtVljU3N2JyUpnktzOhHPgyrG4pL7yHtt+OacyMf+TCsbsrOO41Lf99Qzox85MOwnGBbygFUVtcoZ0Y98mFYTlDf0IgtyemaX8NtxCMfhuUk127dRkZOrnJmxCMfhuVEmcfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=', + 'isExternal' => false, + 'externalType' => 'proofread', + 'workflowId' => 3, + 'hasCrowdsourcing' => false, + 'createdAt' => '2019-09-20T11:34:40+00:00', + 'updatedAt' => '2019-09-20T11:34:40+00:00', + 'translateDuplicates' => 1, + 'isMtAllowed' => true, + 'autoSubstitution' => true, + 'skipUntranslatedStrings' => false, + 'skipUntranslatedFiles' => false, + 'exportApprovedOnly' => false, + 'autoTranslateDialects' => true, + 'publicDownloads' => true, + 'useGlobalTm' => false, + 'inContext' => true, + 'inContextPseudoLanguageId' => 'uk', + 'qaCheckIsActive' => true, + 'qaCheckCategories' => [ + 'empty' => true, + 'size' => true, + 'tags' => true, + 'spaces' => true, + 'variables' => true, + 'punctuation' => true, + 'symbolRegister' => true, + 'specialSymbols' => true, + 'wrongTranslation' => true, + 'spellcheck' => true, + 'icu' => true, + ], + 'customQaCheckIds' => [ + '1', + ], + 'languageMapping' => [ + 'uk' => [ + 'name' => 'Ukranian', + 'two_letters_code' => 'ua', + 'three_letters_code' => 'ukr', + 'locale' => 'uk-UA', + 'locale_with_underscore' => 'uk_UA', + 'android_code' => 'uk-rUA', + 'osx_code' => 'ua.lproj', + 'osx_locale' => 'ua', + ], + ], + 'hiddenStringsProofreadersAccess' => true, + 'inContextProcessHiddenStrings' => false, + 'glossaryAccess' => true, + 'normalizePlaceholder' => false, + 'saveMetaInfoInSource' => true, + 'notificationSettings' => [ + 'translatorNewStrings' => 'false', + 'managerNewStrings' => 'false', + 'managerLanguageCompleted' => 'false', + ], + ], + ]) + ); $project = $this->crowdin->project->get(8); @@ -265,78 +275,82 @@ public function testGetAndUpdate() $this->assertEquals(8, $project->getId()); $project->setName('edit test'); - $this->mockRequestPatch('/projects/8', '{ - "data": { - "id": 8, - "groupId": 4, - "userId": 6, - "sourceLanguageId": "es", - "targetLanguageIds": [ - "uk" - ], - "name": "edit test", - "identifier": "1f198a4e907688bc65834a6d5a6000c3", - "description": "Vault of all terms and their explanation", - "logo": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEiEl6sXkLThu2+Vfx6Xmom8C5fEfu7bM6Yh8p25ytmjyip8v3knqmpqxX6+O+ArlpNNmz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O7vDz82a+pvkxZFIzZFiq/1MVl95D0e1S5fMmkwc+Wh7W5j+b1Johw3ra5es38cO2XdiUtB919Q3KZ/r3C8CHy97VebOey/BhncwvwPr4JFgsVlRUVSMu7aDms5PGPo9Qjc+7U2uGDutw7ilsT8lo9Y56/tVr+P3UOc2/s2zem5qfeqAnDBmW3d6CPZlHkHI4RzlPzjqKkrv3lTMvL0+sjgrXfO+LHjNkWBk5uW2+KtlsdmxMTNV8x33Y4IGICZsvtV6vYMiwKqrbv/hQXlGF+HTt28wzXpmkeWmVDBpWR50tuIIT5/I156sWL8CgoPbfZDUihtWOhMxszVs4PPLRxrDaYbXasDExFc0aN5x55KPGsDrgQfkjJGRma8555OOIYXVQ3oVLOH3xL+WMRz6OGFYn7Nh/CA/KHylnPPJpjWF1gsVixaakNFgsVuWcRz5PMKxOunO/DMlZ2lfAeOTzGMPqgmNnLuD85ULljEc+jzGsLopLzUR5RZVyxiMfhtVljU3N2JyUpnktzOhHPgyrG4pL7yHtt+OacyMf+TCsbsrOO41Lf99Qzox85MOwnGBbygFUVtcoZ0Y98mFYTlDf0IgtyemaX8NtxCMfhuUk127dRkZOrnJmxCMfhuVEmcfzcLXolnJmtCMfhuVkW/emo7q2Tjkz0pEPw3Ky6to6bN2brvldWkY58mFYAq4W3cLhXPX3lBrlyMcj0ryGX1NHTsdXLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=", - "isExternal": false, - "externalType": "proofread", - "workflowId": 3, - "hasCrowdsourcing": false, - "createdAt": "2019-09-20T11:34:40+00:00", - "updatedAt": "2019-09-20T11:34:40+00:00", - "translateDuplicates": 1, - "isMtAllowed": true, - "autoSubstitution": true, - "skipUntranslatedStrings": false, - "skipUntranslatedFiles": false, - "exportApprovedOnly": false, - "autoTranslateDialects": true, - "publicDownloads": true, - "useGlobalTm": false, - "inContext": true, - "inContextPseudoLanguageId": "uk", - "qaCheckIsActive": true, - "qaCheckCategories": { - "empty": true, - "size": true, - "tags": true, - "spaces": true, - "variables": true, - "punctuation": true, - "symbolRegister": true, - "specialSymbols": true, - "wrongTranslation": true, - "spellcheck": true, - "icu": true - }, - "customQaCheckIds": [ - "1" - ], - "languageMapping": { - "uk": { - "name": "Ukranian", - "two_letters_code": "ua", - "three_letters_code": "ukr", - "locale": "uk-UA", - "locale_with_underscore": "uk_UA", - "android_code": "uk-rUA", - "osx_code": "ua.lproj", - "osx_locale": "ua" - } - }, - "hiddenStringsProofreadersAccess": true, - "inContextProcessHiddenStrings": false, - "glossaryAccess": true, - "normalizePlaceholder": false, - "saveMetaInfoInSource": true, - "notificationSettings": { - "translatorNewStrings": "false", - "managerNewStrings": "false", - "managerLanguageCompleted": "false" - } - } - }'); + + $this->mockRequestPatch( + '/projects/8', + json_encode([ + 'data' => [ + 'id' => 8, + 'groupId' => 4, + 'userId' => 6, + 'sourceLanguageId' => 'es', + 'targetLanguageIds' => [ + 'uk', + ], + 'name' => 'edit test', + 'identifier' => '1f198a4e907688bc65834a6d5a6000c3', + 'description' => 'Vault of all terms and their explanation', + 'logo' => 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAGm0lEQVR4nO3cWVCVdRjH8R+HTQQR93BJo1Jz1MrRSS21JDUNRWUxMabVpvXcNuNdl100U2qNuQ+KIiCCCIqYoSPkbiippCKiuBDKvp6FLmzG8Pxf1vO858D7+1z6vA7PMN85Oud//scj0rymBUROZnL1AtQ7MSwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSwbBIBMMiEQyLRDAsEsGwSATDIhEMi0QwLBLBsEgEwyIRDItEMCwSw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yLRDAsEsGwSMS//tClrE3peLcAAAAASUVORK5CYII=', + 'isExternal' => false, + 'externalType' => 'proofread', + 'workflowId' => 3, + 'hasCrowdsourcing' => false, + 'createdAt' => '2019-09-20T11:34:40+00:00', + 'updatedAt' => '2019-09-20T11:34:40+00:00', + 'translateDuplicates' => 1, + 'isMtAllowed' => true, + 'autoSubstitution' => true, + 'skipUntranslatedStrings' => false, + 'skipUntranslatedFiles' => false, + 'exportApprovedOnly' => false, + 'autoTranslateDialects' => true, + 'publicDownloads' => true, + 'useGlobalTm' => false, + 'inContext' => true, + 'inContextPseudoLanguageId' => 'uk', + 'qaCheckIsActive' => true, + 'qaCheckCategories' => [ + 'empty' => true, + 'size' => true, + 'tags' => true, + 'spaces' => true, + 'variables' => true, + 'punctuation' => true, + 'symbolRegister' => true, + 'specialSymbols' => true, + 'wrongTranslation' => true, + 'spellcheck' => true, + 'icu' => true, + ], + 'customQaCheckIds' => [ + '1', + ], + 'languageMapping' => [ + 'uk' => [ + 'name' => 'Ukranian', + 'two_letters_code' => 'ua', + 'three_letters_code' => 'ukr', + 'locale' => 'uk-UA', + 'locale_with_underscore' => 'uk_UA', + 'android_code' => 'uk-rUA', + 'osx_code' => 'ua.lproj', + 'osx_locale' => 'ua', + ], + ], + 'hiddenStringsProofreadersAccess' => true, + 'inContextProcessHiddenStrings' => false, + 'glossaryAccess' => true, + 'normalizePlaceholder' => false, + 'saveMetaInfoInSource' => true, + 'notificationSettings' => [ + 'translatorNewStrings' => 'false', + 'managerNewStrings' => 'false', + 'managerLanguageCompleted' => 'false', + ], + ], + ]) + ); $project = $this->crowdin->project->update($project); diff --git a/tests/CrowdinApiClient/Api/Enterprise/ReportArchiveApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/ReportArchiveApiTest.php index 38da2d1f..3ee32aa9 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/ReportArchiveApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/ReportArchiveApiTest.php @@ -6,38 +6,39 @@ use CrowdinApiClient\Model\ReportArchive; use CrowdinApiClient\Model\ReportArchiveExport; use CrowdinApiClient\ModelCollection; +use stdClass; class ReportArchiveApiTest extends AbstractTestApi { - public function testList() { $this->mockRequest([ 'path' => '/reports/archives', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 12, - "scopeType": "project", - "scopeId": 35, - "userId": 35, - "name": "string", - "webUrl": "https://crowdin.com/project/project-identifier/reports/archive/1", - "scheme": {}, - "createdAt": "2019-09-23T11:26:54+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 12, + 'scopeType' => 'project', + 'scopeId' => 35, + 'userId' => 35, + 'name' => 'string', + 'webUrl' => 'https://crowdin.com/project/project-identifier/reports/archive/1', + 'scheme' => new stdClass(), + 'createdAt' => '2019-09-23T11:26:54+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]), ]); $reportArchives = $this->crowdin->reportArchive->list(); + $this->assertInstanceOf(ModelCollection::class, $reportArchives); $this->assertCount(1, $reportArchives); $this->assertInstanceOf(ReportArchive::class, $reportArchives[0]); @@ -49,18 +50,18 @@ public function testGet() $this->mockRequest([ 'path' => '/reports/archives/12', 'method' => 'get', - 'response' => '{ - "data": { - "id": 12, - "scopeType": "project", - "scopeId": 35, - "userId": 35, - "name": "report archive name", - "webUrl": "https://crowdin.com/project/project-identifier/reports/archive/1", - "scheme": {}, - "createdAt": "2019-09-23T11:26:54+00:00" - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 12, + 'scopeType' => 'project', + 'scopeId' => 35, + 'userId' => 35, + 'name' => 'report archive name', + 'webUrl' => 'https://crowdin.com/project/project-identifier/reports/archive/1', + 'scheme' => new stdClass(), + 'createdAt' => '2019-09-23T11:26:54+00:00', + ], + ]), ]); $reportArchive = $this->crowdin->reportArchive->get(12); @@ -77,27 +78,26 @@ public function testDelete() public function testExport() { - $params = []; $this->mockRequest([ 'path' => '/reports/archives/12/exports', 'method' => 'post', - 'body' => json_encode($params), - 'response' => '{ - "data": { - "identifier": "50fb3506-4127-4ba8-8296-f97dc7e3e0c3", - "status": "finished", - "progress": 100, - "attributes": { - "format": "xlsx", - "reportName": "costs-estimation", - "schema": {} - }, - "createdAt": "2019-09-23T11:26:54+00:00", - "updatedAt": "2019-09-23T11:26:54+00:00", - "startedAt": "2019-09-23T11:26:54+00:00", - "finishedAt": "2019-09-23T11:26:54+00:00" - } - }' + 'body' => json_encode([]), + 'response' => json_encode([ + 'data' => [ + 'identifier' => '50fb3506-4127-4ba8-8296-f97dc7e3e0c3', + 'status' => 'finished', + 'progress' => 100, + 'attributes' => [ + 'format' => 'xlsx', + 'reportName' => 'costs-estimation', + 'schema' => new stdClass(), + ], + 'createdAt' => '2019-09-23T11:26:54+00:00', + 'updatedAt' => '2019-09-23T11:26:54+00:00', + 'startedAt' => '2019-09-23T11:26:54+00:00', + 'finishedAt' => '2019-09-23T11:26:54+00:00', + ], + ]), ]); $export = $this->crowdin->reportArchive->export(12); @@ -106,31 +106,37 @@ public function testExport() $this->assertEquals('50fb3506-4127-4ba8-8296-f97dc7e3e0c3', $export->getIdentifier()); $this->assertEquals('2019-09-23T11:26:54+00:00', $export->getCreatedAt()); $this->assertEquals('2019-09-23T11:26:54+00:00', $export->getStartedAt()); - $this->assertEquals([ - 'format' => 'xlsx', - 'reportName' => 'costs-estimation', - 'schema' => [], - ], $export->getAttributes()); + $this->assertEquals( + [ + 'format' => 'xlsx', + 'reportName' => 'costs-estimation', + 'schema' => [], + ], + $export->getAttributes() + ); } public function testCheckExportStatus() { - $this->mockRequestGet('/reports/archives/12/exports/50fb3506-4127-4ba8-8296-f97dc7e3e0c3', '{ - "data": { - "identifier": "50fb3506-4127-4ba8-8296-f97dc7e3e0c3", - "status": "finished", - "progress": 100, - "attributes": { - "format": "xlsx", - "reportName": "costs-estimation", - "schema": {} - }, - "createdAt": "2019-09-23T11:26:54+00:00", - "updatedAt": "2019-09-23T11:26:54+00:00", - "startedAt": "2019-09-23T11:26:54+00:00", - "finishedAt": "2019-09-23T11:26:54+00:00" - } - }'); + $this->mockRequestGet( + '/reports/archives/12/exports/50fb3506-4127-4ba8-8296-f97dc7e3e0c3', + json_encode([ + 'data' => [ + 'identifier' => '50fb3506-4127-4ba8-8296-f97dc7e3e0c3', + 'status' => 'finished', + 'progress' => 100, + 'attributes' => [ + 'format' => 'xlsx', + 'reportName' => 'costs-estimation', + 'schema' => new stdClass(), + ], + 'createdAt' => '2019-09-23T11:26:54+00:00', + 'updatedAt' => '2019-09-23T11:26:54+00:00', + 'startedAt' => '2019-09-23T11:26:54+00:00', + 'finishedAt' => '2019-09-23T11:26:54+00:00', + ], + ]) + ); $export = $this->crowdin->reportArchive->checkExportStatus(12, '50fb3506-4127-4ba8-8296-f97dc7e3e0c3'); @@ -144,16 +150,25 @@ public function testCheckExportStatus() public function testDownloadReportArchive() { - $this->mockRequestGet('/reports/archives/12/exports/50fb3506-4127-4ba8-8296-f97dc7e3e0c3/download', '{ - "data": { - "url": "https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62", - "expireIn": "2019-09-20T10:31:21+00:00" - } - }'); - - $downloadFile = $this->crowdin->reportArchive->downloadReportArchive(12, '50fb3506-4127-4ba8-8296-f97dc7e3e0c3'); + $this->mockRequestGet( + '/reports/archives/12/exports/50fb3506-4127-4ba8-8296-f97dc7e3e0c3/download', + json_encode([ + 'data' => [ + 'url' => 'https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', + 'expireIn' => '2019-09-20T10:31:21+00:00', + ], + ]) + ); + + $downloadFile = $this->crowdin->reportArchive->downloadReportArchive( + 12, + '50fb3506-4127-4ba8-8296-f97dc7e3e0c3' + ); $this->assertInstanceOf(DownloadFile::class, $downloadFile); - $this->assertEquals('https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', $downloadFile->getUrl()); + $this->assertEquals( + 'https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', + $downloadFile->getUrl() + ); } } diff --git a/tests/CrowdinApiClient/Api/Enterprise/SecurityLogApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/SecurityLogApiTest.php index f50ce2d6..1e79f82a 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/SecurityLogApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/SecurityLogApiTest.php @@ -9,33 +9,38 @@ class SecurityLogApiTest extends AbstractTestApi { public function testList() { - $this->mockRequestGet('/security-logs', '{ - "data": [ - { - "data": { - "id": 2, - "event": "Some event", - "info": "Some info", - "userId": 4, - "location": "USA", - "ipAddress": "127.0.0.1", - "deviceName": "MacOs on MacBook", - "createdAt": "2019-09-19T15:10:43+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }'); + $this->mockRequestGet( + '/security-logs', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'event' => 'Some event', + 'info' => 'Some info', + 'userId' => 4, + 'location' => 'USA', + 'ipAddress' => '127.0.0.1', + 'deviceName' => 'MacOs on MacBook', + 'createdAt' => '2019-09-19T15:10:43+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]) + ); $securityLogs = $this->crowdin->securityLog->listOrganizationSecurityLogs(); + $this->assertInstanceOf(ModelCollection::class, $securityLogs); $this->assertCount(1, $securityLogs); /** @var SecurityLog $securityLog */ $securityLog = $securityLogs[0]; + $this->assertInstanceOf(SecurityLog::class, $securityLog); $this->assertEquals(2, $securityLog->getId()); $this->assertEquals('Some event', $securityLog->getEvent()); @@ -49,20 +54,24 @@ public function testList() public function testGet() { - $this->mockRequestGet('/security-logs/2', '{ - "data": { - "id": 2, - "event": "Some event", - "info": "Some info", - "userId": 4, - "location": "USA", - "ipAddress": "127.0.0.1", - "deviceName": "MacOs on MacBook", - "createdAt": "2019-09-19T15:10:43+00:00" - } - }'); + $this->mockRequestGet( + '/security-logs/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'event' => 'Some event', + 'info' => 'Some info', + 'userId' => 4, + 'location' => 'USA', + 'ipAddress' => '127.0.0.1', + 'deviceName' => 'MacOs on MacBook', + 'createdAt' => '2019-09-19T15:10:43+00:00', + ], + ]) + ); $securityLog = $this->crowdin->securityLog->getOrganizationSecurityLog(2); + $this->assertInstanceOf(SecurityLog::class, $securityLog); $this->assertEquals(2, $securityLog->getId()); $this->assertEquals('Some event', $securityLog->getEvent()); diff --git a/tests/CrowdinApiClient/Api/Enterprise/StringCorrectionApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/StringCorrectionApiTest.php index cb6feeef..97007599 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/StringCorrectionApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/StringCorrectionApiTest.php @@ -12,28 +12,28 @@ public function testList(): void $this->mockRequest([ 'path' => '/projects/2/corrections', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 190695, - "text": "This string has been corrected", - "pluralCategoryName": "few", - "user": { - "id": 19, - "username": "john_doe", - "fullName": "John Smith", - "avatarUrl": "" - }, - "createdAt": "2019-09-23T11:26:54+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }', + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 190695, + 'text' => 'This string has been corrected', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'username' => 'john_doe', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'createdAt' => '2019-09-23T11:26:54+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]), ]); $corrections = $this->crowdin->stringCorrection->list(2); @@ -48,20 +48,20 @@ public function testGet(): void { $this->mockRequestGet( '/projects/2/corrections/190695', - '{ - "data": { - "id": 190695, - "text": "This string has been corrected", - "pluralCategoryName": "few", - "user": { - "id": 19, - "username": "john_doe", - "fullName": "John Smith", - "avatarUrl": "" - }, - "createdAt": "2019-09-23T11:26:54+00:00" - } - }' + json_encode([ + 'data' => [ + 'id' => 190695, + 'text' => 'This string has been corrected', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'username' => 'john_doe', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'createdAt' => '2019-09-23T11:26:54+00:00', + ], + ]) ); $correction = $this->crowdin->stringCorrection->get(2, 190695); @@ -83,20 +83,20 @@ public function testCreate(): void 'path' => '/projects/2/corrections', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 190696, - "text": "Corrected string text", - "pluralCategoryName": "few", - "user": { - "id": 19, - "username": "john_doe", - "fullName": "John Smith", - "avatarUrl": "" - }, - "createdAt": "2019-09-23T11:26:54+00:00" - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 190696, + 'text' => 'Corrected string text', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'username' => 'john_doe', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'createdAt' => '2019-09-23T11:26:54+00:00', + ], + ]), ]); $correction = $this->crowdin->stringCorrection->create(2, $params); @@ -111,20 +111,20 @@ public function testRestore(): void $this->mockRequest([ 'path' => '/projects/2/corrections/190695', 'method' => 'put', - 'response' => '{ - "data": { - "id": 190695, - "text": "This string has been corrected", - "pluralCategoryName": "few", - "user": { - "id": 19, - "username": "john_doe", - "fullName": "John Smith", - "avatarUrl": "" - }, - "createdAt": "2019-09-23T11:26:54+00:00" - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 190695, + 'text' => 'This string has been corrected', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'username' => 'john_doe', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'createdAt' => '2019-09-23T11:26:54+00:00', + ], + ]), ]); $correction = $this->crowdin->stringCorrection->restore(2, 190695); diff --git a/tests/CrowdinApiClient/Api/Enterprise/StringTranslationApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/StringTranslationApiTest.php index 525e8fdf..36276c52 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/StringTranslationApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/StringTranslationApiTest.php @@ -14,31 +14,32 @@ public function testList() $this->mockRequest([ 'path' => '/projects/2/translations', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 190695, - "text": "Цю стрічку перекладено", - "pluralCategoryName": "few", - "user": { - "id": 19, - "login": "john_doe" - }, - "rating": 10 - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 190695, + 'text' => 'Цю стрічку перекладено', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'rating' => 10, + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $stringTranslations = $this->crowdin->stringTranslation->list(2); + $this->assertInstanceOf(ModelCollection::class, $stringTranslations); $this->assertCount(1, $stringTranslations); $this->assertInstanceOf(StringTranslation::class, $stringTranslations[0]); @@ -47,20 +48,24 @@ public function testList() public function testGet() { - $this->mockRequestGet('/projects/2/translations/190695', '{ - "data": { - "id": 190695, - "text": "Цю стрічку перекладено", - "pluralCategoryName": "few", - "user": { - "id": 19, - "login": "john_doe" - }, - "rating": 10 - } - }'); + $this->mockRequestGet( + '/projects/2/translations/190695', + json_encode([ + 'data' => [ + 'id' => 190695, + 'text' => 'Цю стрічку перекладено', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'rating' => 10, + ], + ]) + ); $stringTranslation = $this->crowdin->stringTranslation->get(2, 190695); + $this->assertInstanceOf(StringTranslation::class, $stringTranslation); $this->assertEquals(190695, $stringTranslation->getId()); } @@ -84,21 +89,22 @@ public function create() 'path' => '', 'method' => 'post', 'body' => $params, - 'response' => '{ - "data": { - "id": 190695, - "text": "Цю стрічку перекладено", - "pluralCategoryName": "few", - "user": { - "id": 19, - "login": "john_doe" - }, - "rating": 10 - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 190695, + 'text' => 'Цю стрічку перекладено', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'rating' => 10, + ], + ]), ]); $stringTranslation = $this->crowdin->stringTranslation->create(2, $params); + $this->assertInstanceOf(StringTranslation::class, $stringTranslation); $this->assertEquals(190695, $stringTranslation->getId()); } @@ -106,23 +112,24 @@ public function create() public function testRestore() { $this->mockRequest([ - 'path' => '/projects/2/translations/190695', - 'method' => 'put', - 'response' => '{ - "data": { - "id": 190695, - "text": "Цю стрічку перекладено", - "pluralCategoryName": "few", - "user": { - "id": 19, - "login": "john_doe" - }, - "rating": 10 - } - }' + 'path' => '/projects/2/translations/190695', + 'method' => 'put', + 'response' => json_encode([ + 'data' => [ + 'id' => 190695, + 'text' => 'Цю стрічку перекладено', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'rating' => 10, + ], + ]), ]); $stringTranslation = $this->crowdin->stringTranslation->restore(2, 190695); + $this->assertInstanceOf(StringTranslation::class, $stringTranslation); $this->assertEquals(190695, $stringTranslation->getId()); } @@ -140,21 +147,22 @@ public function testCreate() 'path' => '/projects/2/translations', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 190695, - "text": "Цю стрічку перекладено", - "pluralCategoryName": "few", - "user": { - "id": 19, - "login": "john_doe" - }, - "rating": 10 - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 190695, + 'text' => 'Цю стрічку перекладено', + 'pluralCategoryName' => 'few', + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'rating' => 10, + ], + ]), ]); $stringTranslation = $this->crowdin->stringTranslation->create(2, $params); + $this->assertInstanceOf(StringTranslation::class, $stringTranslation); $this->assertEquals(190695, $stringTranslation->getId()); } @@ -164,30 +172,30 @@ public function testListApproval() $this->mockRequest([ 'path' => '/projects/2/approvals', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 190695, - "user": { - "id": 19, - "login": "john_doe" - }, - "translationId": 190695, - "stringId": 2345, - "languageId": "uk", - "workflowStepId": 122, - "createdAt": "2019-09-19T12:42:12+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 190695, + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'translationId' => 190695, + 'stringId' => 2345, + 'languageId' => 'uk', + 'workflowStepId' => 122, + 'createdAt' => '2019-09-19T12:42:12+00:00', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $stringTranslationApprovals = $this->crowdin->stringTranslation->listApprovals(2); @@ -206,45 +214,50 @@ public function testCreateApproval() 'path' => '/projects/2/approvals', 'body' => json_encode($params), 'method' => 'post', - 'response' => '{ - "data": { - "id": 190695, - "user": { - "id": 19, - "login": "john_doe" - }, - "translationId": 190695, - "stringId": 2345, - "languageId": "uk", - "workflowStepId": 122, - "createdAt": "2019-09-19T12:42:12+00:00" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 190695, + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'translationId' => 190695, + 'stringId' => 2345, + 'languageId' => 'uk', + 'workflowStepId' => 122, + 'createdAt' => '2019-09-19T12:42:12+00:00', + ], + ]), ]); $approval = $this->crowdin->stringTranslation->createApproval(2, $params); + $this->assertInstanceOf(StringTranslationApproval::class, $approval); $this->assertEquals(190695, $approval->getId()); } public function testGetApproval() { - $this->mockRequestGet('/projects/2/approvals/190695', '{ - "data": { - "id": 190695, - "user": { - "id": 19, - "login": "john_doe" - }, - "translationId": 190695, - "stringId": 2345, - "languageId": "uk", - "workflowStepId": 122, - "createdAt": "2019-09-19T12:42:12+00:00" - } - }'); + $this->mockRequestGet( + '/projects/2/approvals/190695', + json_encode([ + 'data' => [ + 'id' => 190695, + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'translationId' => 190695, + 'stringId' => 2345, + 'languageId' => 'uk', + 'workflowStepId' => 122, + 'createdAt' => '2019-09-19T12:42:12+00:00', + ], + ]) + ); $stringTranslationApproval = $this->crowdin->stringTranslation->getApproval(2, 190695); + $this->assertInstanceOf(StringTranslationApproval::class, $stringTranslationApproval); $this->assertEquals(190695, $stringTranslationApproval->getId()); } @@ -260,31 +273,32 @@ public function testListVote() $this->mockRequest([ 'path' => '/projects/2/votes', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 6643, - "user": { - "id": 19, - "login": "john_doe" - }, - "translationId": 19069345, - "votedAt": "2019-09-19T12:42:12+00:00", - "mark": "up" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }', + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 6643, + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'translationId' => 19069345, + 'votedAt' => '2019-09-19T12:42:12+00:00', + 'mark' => 'up', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $votes = $this->crowdin->stringTranslation->listVotes(2); + $this->assertInstanceOf(ModelCollection::class, $votes); $this->assertCount(1, $votes); $this->assertInstanceOf(Vote::class, $votes[0]); @@ -295,47 +309,53 @@ public function testCreateVote() { $params = [ 'mark' => 'up', - 'translationId' => 653412 + 'translationId' => 653412, ]; $this->mockRequest([ 'path' => '/projects/2/votes', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 6643, - "user": { - "id": 19, - "login": "john_doe" - }, - "translationId": 19069345, - "votedAt": "2019-09-19T12:42:12+00:00", - "mark": "up" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 6643, + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'translationId' => 19069345, + 'votedAt' => '2019-09-19T12:42:12+00:00', + 'mark' => 'up', + ], + ]), ]); $vote = $this->crowdin->stringTranslation->createVote(2, $params); + $this->assertInstanceOf(Vote::class, $vote); $this->assertEquals(6643, $vote->getId()); } public function testGetAndUpdateVote() { - $this->mockRequestGet('/projects/2/votes/6643', '{ - "data": { - "id": 6643, - "user": { - "id": 19, - "login": "john_doe" - }, - "translationId": 19069345, - "votedAt": "2019-09-19T12:42:12+00:00", - "mark": "up" - } - }'); + $this->mockRequestGet( + '/projects/2/votes/6643', + json_encode([ + 'data' => [ + 'id' => 6643, + 'user' => [ + 'id' => 19, + 'login' => 'john_doe', + ], + 'translationId' => 19069345, + 'votedAt' => '2019-09-19T12:42:12+00:00', + 'mark' => 'up', + ], + ]) + ); + $vote = $this->crowdin->stringTranslation->getVote(2, 6643); + $this->assertInstanceOf(Vote::class, $vote); $this->assertEquals(6643, $vote->getId()); } diff --git a/tests/CrowdinApiClient/Api/Enterprise/TaskApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/TaskApiTest.php index 8a850a9b..765b8256 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/TaskApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/TaskApiTest.php @@ -12,58 +12,59 @@ public function testList() $this->mockRequest([ 'path' => '/projects/2/tasks', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "vendor": "gengo", - "status": "todo", - "title": "French", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } - ], - "fileIds": [ - 1 + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'vendor' => 'gengo', + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], + ], + 'fileIds' => [ + 1, + ], + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'buyUrl' => 'https://www.paypal.com/cgi-bin/webscr?cmd=...', + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "buyUrl": "https://www.paypal.com/cgi-bin/webscr?cmd=...", - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $tasks = $this->crowdin->task->list(2); + $this->assertInstanceOf(ModelCollection::class, $tasks); $this->assertCount(1, $tasks); $this->assertInstanceOf(Task::class, $tasks[0]); @@ -76,21 +77,18 @@ public function testCreate() 'workflowStepId' => 0, 'title' => 'French', 'languageId' => 'fr', - 'fileIds' => - [ - 0 => 1, - ], + 'fileIds' => [ + 1, + ], 'status' => 'todo', 'description' => 'Proofread all French strings', 'splitFiles' => false, - 'assignees' => + 'assignees' => [ [ - 0 => - [ - 'id' => 1, - 'wordsCount' => 5, - ], + 'id' => 1, + 'wordsCount' => 5, ], + ], 'deadline' => '2019-09-27T07:00:14+00:00', 'dateFrom' => '2019-09-23T07:00:14+00:00', 'dateTo' => '2019-09-27T07:00:14+00:00', @@ -100,141 +98,149 @@ public function testCreate() 'path' => '/projects/2/tasks', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "vendor": "gengo", - "status": "todo", - "title": "French", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } + 'response' => json_encode([ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'vendor' => 'gengo', + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], ], - "fileIds": [ - 1 + 'fileIds' => [ + 1, ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "buyUrl": "https://www.paypal.com/cgi-bin/webscr?cmd=...", - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }' - + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, + ], + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'buyUrl' => 'https://www.paypal.com/cgi-bin/webscr?cmd=...', + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]), ]); $task = $this->crowdin->task->create(2, $params); + $this->assertInstanceOf(Task::class, $task); $this->assertEquals(2, $task->getId()); } public function testGetAndUpdate() { - $this->mockRequestGet('/projects/2/tasks/2', '{ - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "vendor": "gengo", - "status": "todo", - "title": "French", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } + $this->mockRequestGet( + '/projects/2/tasks/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'vendor' => 'gengo', + 'status' => 'todo', + 'title' => 'French', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], + ], + 'fileIds' => [ + 1, ], - "fileIds": [ - 1 + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "buyUrl": "https://www.paypal.com/cgi-bin/webscr?cmd=...", - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }'); + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'buyUrl' => 'https://www.paypal.com/cgi-bin/webscr?cmd=...', + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]) + ); $task = $this->crowdin->task->get(2, 2); + $this->assertInstanceOf(Task::class, $task); $this->assertEquals(2, $task->getId()); - $this->mockRequestPatch('/projects/2/tasks/2', '{ - "data": { - "id": 2, - "projectId": 2, - "creatorId": 6, - "type": 1, - "vendor": "gengo", - "status": "todo", - "title": "test edit", - "assignees": [ - { - "id": 1, - "wordsCount": 5 - } + $this->mockRequestPatch( + '/projects/2/tasks/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'projectId' => 2, + 'creatorId' => 6, + 'type' => 1, + 'vendor' => 'gengo', + 'status' => 'todo', + 'title' => 'test edit', + 'assignees' => [ + [ + 'id' => 1, + 'wordsCount' => 5, + ], + ], + 'fileIds' => [ + 1, ], - "fileIds": [ - 1 + 'progress' => [ + 'total' => 24, + 'done' => 15, + 'percent' => 62, ], - "progress": { - "total": 24, - "done": 15, - "percent": 62 - }, - "sourceLanguageId": "en", - "targetLanguageId": "fr", - "description": "Proofread all French strings", - "hash": "dac37aff364d83899128e68afe0de4994", - "translationUrl": "/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994", - "wordsCount": 24, - "filesCount": 2, - "commentsCount": 0, - "deadline": "2019-09-27T07:00:14+00:00", - "timeRange": "string", - "workflowStepId": 10, - "buyUrl": "https://www.paypal.com/cgi-bin/webscr?cmd=...", - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }'); + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'fr', + 'description' => 'Proofread all French strings', + 'hash' => 'dac37aff364d83899128e68afe0de4994', + 'translationUrl' => '/proofread/9092638ac9f2a2d1b5571d08edc53763/all/en-fr/10?task=dac37aff364d83899128e68afe0de4994', + 'wordsCount' => 24, + 'filesCount' => 2, + 'commentsCount' => 0, + 'deadline' => '2019-09-27T07:00:14+00:00', + 'timeRange' => 'string', + 'workflowStepId' => 10, + 'buyUrl' => 'https://www.paypal.com/cgi-bin/webscr?cmd=...', + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]) + ); $task->setTitle('test edit'); $task = $this->crowdin->task->update($task); + $this->assertInstanceOf(Task::class, $task); $this->assertEquals(2, $task->getId()); $this->assertEquals('test edit', $task->getTitle()); diff --git a/tests/CrowdinApiClient/Api/Enterprise/VendorApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/VendorApiTest.php index dc6d8dc6..c85d4b92 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/VendorApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/VendorApiTest.php @@ -12,27 +12,28 @@ public function testList() $this->mockRequest([ 'path' => '/vendors', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 52760, - "name": "John Smith Translation Agency", - "description": "John Smith Translation Agency provides services for software and game localization as well as translation into 70+ languages.", - "status": "pending" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 52760, + 'name' => 'John Smith Translation Agency', + 'description' => 'John Smith Translation Agency provides services for software and game localization as well as translation into 70+ languages.', + 'status' => 'pending', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]) ]); $vendors = $this->crowdin->vendor->list(); + $this->assertInstanceOf(ModelCollection::class, $vendors); $this->assertCount(1, $vendors); $this->assertInstanceOf(Vendor::class, $vendors[0]); diff --git a/tests/CrowdinApiClient/Api/Enterprise/WorkflowTemplateApiTest.php b/tests/CrowdinApiClient/Api/Enterprise/WorkflowTemplateApiTest.php index 4c8f4071..6473b37c 100644 --- a/tests/CrowdinApiClient/Api/Enterprise/WorkflowTemplateApiTest.php +++ b/tests/CrowdinApiClient/Api/Enterprise/WorkflowTemplateApiTest.php @@ -12,25 +12,25 @@ public function testList() $this->mockRequest([ 'path' => '/workflow-templates', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 2, - "title": "In-house + Machine Translation", - "description": "Combine the efforts of human translators and Machine Translation technology.\\n• Pre-translation - Translation Memory\\n• Pre-translation - Machine Translation\\n• Translation - in-house translators\\n• Proofreading - in-house translators", - "groupId": 2, - "isDefault": true - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'title' => 'In-house + Machine Translation', + 'description' => "Combine the efforts of human translators and Machine Translation technology.\n• Pre-translation - Translation Memory\n• Pre-translation - Machine Translation\n• Translation - in-house translators\n• Proofreading - in-house translators", + 'groupId' => 2, + 'isDefault' => true, + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $workflowTemplates = $this->crowdin->workflowTemplate->list(); @@ -43,17 +43,21 @@ public function testList() public function testGet() { - $this->mockRequestGet('/workflow-templates/2', '{ - "data": { - "id": 2, - "title": "In-house + Machine Translation", - "description": "Combine the efforts of human translators and Machine Translation technology.\\n• Pre-translation - Translation Memory\\n• Pre-translation - Machine Translation\\n• Translation - in-house translators\\n• Proofreading - in-house translators", - "groupId": 2, - "isDefault": true - } - }'); + $this->mockRequestGet( + '/workflow-templates/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'title' => 'In-house + Machine Translation', + 'description' => "Combine the efforts of human translators and Machine Translation technology.\n• Pre-translation - Translation Memory\n• Pre-translation - Machine Translation\n• Translation - in-house translators\n• Proofreading - in-house translators", + 'groupId' => 2, + 'isDefault' => true, + ], + ]) + ); $workflowTemplate = $this->crowdin->workflowTemplate->get(2); + $this->assertInstanceOf(WorkflowTemplate::class, $workflowTemplate); $this->assertEquals(2, $workflowTemplate->getId()); } diff --git a/tests/CrowdinApiClient/Api/IssueApiTest.php b/tests/CrowdinApiClient/Api/IssueApiTest.php index 29c9165b..2f196d2f 100644 --- a/tests/CrowdinApiClient/Api/IssueApiTest.php +++ b/tests/CrowdinApiClient/Api/IssueApiTest.php @@ -11,41 +11,44 @@ class IssueApiTest extends AbstractTestApi { public function testListReportedIssues() { - $this->mockRequestGet('/projects/1/issues', '{ - "data": [ - { - "data": { - "id": 2, - "text": "@BeMyEyes Please provide more details on where the text will be used", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title\\r\\nXPath: /html/head/title", - "fileId": 22 - }, - "languageId": "bg", - "type": "source_mistake", - "status": "unresolved", - "createdAt": "2019-09-20T11:05:24+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }'); + $this->mockRequestGet( + '/projects/1/issues', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'text' => '@BeMyEyes Please provide more details on where the text will be used', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => "Document Title\r\nXPath: /html/head/title", + 'fileId' => 22, + ], + 'languageId' => 'bg', + 'type' => 'source_mistake', + 'status' => 'unresolved', + 'createdAt' => '2019-09-20T11:05:24+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]) + ); $issues = $this->crowdin->issue->listReportedIssues(1); @@ -57,41 +60,44 @@ public function testListReportedIssues() public function testGetAndUpdate() { - $this->mockRequestGet('/projects/1/issues', '{ - "data": [ - { - "data": { - "id": 2, - "text": "@BeMyEyes Please provide more details on where the text will be used", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title", - "fileId": 22 - }, - "languageId": "bg", - "type": "source_mistake", - "status": "unresolved", - "createdAt": "2019-09-20T11:05:24+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }'); + $this->mockRequestGet( + '/projects/1/issues', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'text' => '@BeMyEyes Please provide more details on where the text will be used', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => 'Document Title', + 'fileId' => 22, + ], + 'languageId' => 'bg', + 'type' => 'source_mistake', + 'status' => 'unresolved', + 'createdAt' => '2019-09-20T11:05:24+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]) + ); $issues = $this->crowdin->issue->listReportedIssues(1); @@ -100,36 +106,40 @@ public function testGetAndUpdate() $this->assertInstanceOf(Issue::class, $issue); $this->assertEquals(2, $issue->getId()); - $this->mockRequestPatch('/projects/1/issues/2', '{ - "data": { - "id": 2, - "text": "@BeMyEyes Please provide more details on where the text will be used", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title", - "fileId": 22 - }, - "languageId": "bg", - "type": "source_mistake", - "status": "resolved", - "createdAt": "2019-09-20T11:05:24+00:00" - } - }'); + $this->mockRequestPatch( + '/projects/1/issues/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'text' => '@BeMyEyes Please provide more details on where the text will be used', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => 'Document Title', + 'fileId' => 22, + ], + 'languageId' => 'bg', + 'type' => 'source_mistake', + 'status' => 'resolved', + 'createdAt' => '2019-09-20T11:05:24+00:00', + ], + ]) + ); $issue->setStatus('resolved'); $issue = $this->crowdin->issue->update(1, $issue); + $this->assertInstanceOf(Issue::class, $issue); $this->assertEquals(2, $issue->getId()); $this->assertEquals('resolved', $issue->getStatus()); diff --git a/tests/CrowdinApiClient/Api/LanguageApiTest.php b/tests/CrowdinApiClient/Api/LanguageApiTest.php index 53931e7b..33476095 100644 --- a/tests/CrowdinApiClient/Api/LanguageApiTest.php +++ b/tests/CrowdinApiClient/Api/LanguageApiTest.php @@ -12,41 +12,42 @@ public function testList() $this->mockRequest([ 'uri' => 'https://api.crowdin.com/api/v2/languages', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": "es", - "name": "Spanish", - "editorCode": "es", - "twoLettersCode": "es", - "threeLettersCode": "spa", - "locale": "es-ES", - "androidCode": "es-rES", - "osxCode": "es.lproj", - "osxLocale": "es", - "pluralCategoryNames": [ - "one" + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 'es', + 'name' => 'Spanish', + 'editorCode' => 'es', + 'twoLettersCode' => 'es', + 'threeLettersCode' => 'spa', + 'locale' => 'es-ES', + 'androidCode' => 'es-rES', + 'osxCode' => 'es.lproj', + 'osxLocale' => 'es', + 'pluralCategoryNames' => [ + 'one', + ], + 'pluralRules' => '(n != 1)', + 'pluralExamples' => [ + '0, 2-999; 1.2, 2.07...', + ], + 'textDirection' => 'ltr', + 'dialectOf' => 'string', ], - "pluralRules": "(n != 1)", - "pluralExamples": [ - "0, 2-999; 1.2, 2.07..." - ], - "textDirection": "ltr", - "dialectOf": "string" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $languages = $this->crowdin->language->list(); + $this->assertInstanceOf(ModelCollection::class, $languages); $this->assertCount(1, $languages); $this->assertInstanceOf(Language::class, $languages[0]); @@ -57,28 +58,28 @@ public function testCreate() $this->mockRequest([ 'uri' => 'https://api.crowdin.com/api/v2/languages', 'method' => 'post', - 'response' => '{ - "data": { - "id": "es", - "name": "Spanish", - "editorCode": "es", - "twoLettersCode": "es", - "threeLettersCode": "spa", - "locale": "es-ES", - "androidCode": "es-rES", - "osxCode": "es.lproj", - "osxLocale": "es", - "pluralCategoryNames": [ - "one" + 'response' => json_encode([ + 'data' => [ + 'id' => 'es', + 'name' => 'Spanish', + 'editorCode' => 'es', + 'twoLettersCode' => 'es', + 'threeLettersCode' => 'spa', + 'locale' => 'es-ES', + 'androidCode' => 'es-rES', + 'osxCode' => 'es.lproj', + 'osxLocale' => 'es', + 'pluralCategoryNames' => [ + 'one', + ], + 'pluralRules' => '(n != 1)', + 'pluralExamples' => [ + '0, 2-999; 1.2, 2.07...', + ], + 'textDirection' => 'ltr', + 'dialectOf' => 'string', ], - "pluralRules": "(n != 1)", - "pluralExamples": [ - "0, 2-999; 1.2, 2.07..." - ], - "textDirection": "ltr", - "dialectOf": "string" - } - }' + ]), ]); $language = $this->crowdin->language->create([ @@ -97,28 +98,31 @@ public function testCreate() public function testGetUpdate() { - $this->mockRequestGet('/languages/es', '{ - "data": { - "id": "es", - "name": "Spanish", - "editorCode": "es", - "twoLettersCode": "es", - "threeLettersCode": "spa", - "locale": "es-ES", - "androidCode": "es-rES", - "osxCode": "es.lproj", - "osxLocale": "es", - "pluralCategoryNames": [ - "one" - ], - "pluralRules": "(n != 1)", - "pluralExamples": [ - "0, 2-999; 1.2, 2.07..." + $this->mockRequestGet( + '/languages/es', + json_encode([ + 'data' => [ + 'id' => 'es', + 'name' => 'Spanish', + 'editorCode' => 'es', + 'twoLettersCode' => 'es', + 'threeLettersCode' => 'spa', + 'locale' => 'es-ES', + 'androidCode' => 'es-rES', + 'osxCode' => 'es.lproj', + 'osxLocale' => 'es', + 'pluralCategoryNames' => [ + 'one', + ], + 'pluralRules' => '(n != 1)', + 'pluralExamples' => [ + '0, 2-999; 1.2, 2.07...', + ], + 'textDirection' => 'ltr', + 'dialectOf' => 'string', ], - "textDirection": "ltr", - "dialectOf": "string" - } - }'); + ]) + ); $language = $this->crowdin->language->get('es'); @@ -127,28 +131,31 @@ public function testGetUpdate() $language->setName('edit test'); - $this->mockRequestPatch('/languages/es', '{ - "data": { - "id": "es", - "name": "Spanish", - "editorCode": "es", - "twoLettersCode": "es", - "threeLettersCode": "spa", - "locale": "es-ES", - "androidCode": "es-rES", - "osxCode": "es.lproj", - "osxLocale": "es", - "pluralCategoryNames": [ - "one" - ], - "pluralRules": "(n != 1)", - "pluralExamples": [ - "0, 2-999; 1.2, 2.07..." + $this->mockRequestPatch( + '/languages/es', + json_encode([ + 'data' => [ + 'id' => 'es', + 'name' => 'Spanish', + 'editorCode' => 'es', + 'twoLettersCode' => 'es', + 'threeLettersCode' => 'spa', + 'locale' => 'es-ES', + 'androidCode' => 'es-rES', + 'osxCode' => 'es.lproj', + 'osxLocale' => 'es', + 'pluralCategoryNames' => [ + 'one', + ], + 'pluralRules' => '(n != 1)', + 'pluralExamples' => [ + '0, 2-999; 1.2, 2.07...', + ], + 'textDirection' => 'ltr', + 'dialectOf' => 'string', ], - "textDirection": "ltr", - "dialectOf": "string" - } - }'); + ]) + ); $this->crowdin->language->update($language); diff --git a/tests/CrowdinApiClient/Api/MachineTranslationEngineApiTest.php b/tests/CrowdinApiClient/Api/MachineTranslationEngineApiTest.php index 76411e1f..68ada6c0 100644 --- a/tests/CrowdinApiClient/Api/MachineTranslationEngineApiTest.php +++ b/tests/CrowdinApiClient/Api/MachineTranslationEngineApiTest.php @@ -13,31 +13,31 @@ public function testList() $this->mockRequest([ 'path' => '/mts?groupId=2', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 2, - "groupId": 2, - "name": "Crowdin Translate (beta)", - "type": "crowdin", - "credentials": { - "crowdin_nmt": 1, - "crowdin_nmt_multi_translations": 1 - }, - "projectIds": [ - 1 - ] - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'groupId' => 2, + 'name' => 'Crowdin Translate (beta)', + 'type' => 'crowdin', + 'credentials' => [ + 'crowdin_nmt' => 1, + 'crowdin_nmt_multi_translations' => 1, + ], + 'projectIds' => [ + 1, + ], + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $machineTranslationEngines = $this->crowdin->machineTranslationEngine->list(['groupId' => 2]); @@ -49,23 +49,27 @@ public function testList() public function testGet() { - $this->mockRequestGet('/mts/2', '{ - "data": { - "id": 2, - "groupId": 2, - "name": "Crowdin Translate (beta)", - "type": "crowdin", - "credentials": { - "crowdin_nmt": 1, - "crowdin_nmt_multi_translations": 1 - }, - "projectIds": [ - 1 - ] - } - }'); + $this->mockRequestGet( + '/mts/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'groupId' => 2, + 'name' => 'Crowdin Translate (beta)', + 'type' => 'crowdin', + 'credentials' => [ + 'crowdin_nmt' => 1, + 'crowdin_nmt_multi_translations' => 1, + ], + 'projectIds' => [ + 1, + ], + ], + ]) + ); $machineTranslationEngine = $this->crowdin->machineTranslationEngine->get(2); + $this->assertInstanceOf(MachineTranslationEngine::class, $machineTranslationEngine); $this->assertEquals(2, $machineTranslationEngine->getId()); } @@ -80,7 +84,7 @@ public function testTranslateViaMT() 'Welcome!', 'Save as...', 'View', - 'About...' + 'About...', ], ]; @@ -88,43 +92,48 @@ public function testTranslateViaMT() 'path' => '/mts/2/translations', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "sourceLanguageId": "en", - "targetLanguageId": "de", - "strings": - [ - "Welcome!", - "Save as...", - "View", - "About..." + 'response' => json_encode([ + 'data' => [ + 'sourceLanguageId' => 'en', + 'targetLanguageId' => 'de', + 'strings' => [ + 'Welcome!', + 'Save as...', + 'View', + 'About...', ], - "translations": - [ - "Herzlich willkommen!", - "Speichern als...", - "Aussicht", - "Etwa..." - ] - } - }' + 'translations' => [ + 'Herzlich willkommen!', + 'Speichern als...', + 'Aussicht', + 'Etwa...', + ], + ], + ]), ]); $machineTranslation = $this->crowdin->machineTranslationEngine->translateViaMT('2', $params); + $this->assertInstanceOf(MachineTranslation::class, $machineTranslation); $this->assertEquals('en', $machineTranslation->getSourceLanguageId()); $this->assertEquals('de', $machineTranslation->getTargetLanguageId()); - $this->assertEquals([ - "Welcome!", - "Save as...", - "View", - "About..." - ], $machineTranslation->getStrings()); - $this->assertEquals([ - "Herzlich willkommen!", - "Speichern als...", - "Aussicht", - "Etwa..." - ], $machineTranslation->getTranslations()); + $this->assertEquals( + [ + "Welcome!", + "Save as...", + "View", + "About...", + ], + $machineTranslation->getStrings() + ); + $this->assertEquals( + [ + "Herzlich willkommen!", + "Speichern als...", + "Aussicht", + "Etwa...", + ], + $machineTranslation->getTranslations() + ); } } diff --git a/tests/CrowdinApiClient/Api/OrganizationWebhookApiTest.php b/tests/CrowdinApiClient/Api/OrganizationWebhookApiTest.php index 50164118..98a5e1e6 100644 --- a/tests/CrowdinApiClient/Api/OrganizationWebhookApiTest.php +++ b/tests/CrowdinApiClient/Api/OrganizationWebhookApiTest.php @@ -9,40 +9,44 @@ class OrganizationWebhookApiTest extends AbstractTestApi { public function testList() { - $this->mockRequestGet('/webhooks', '{ - "data": [ - { - "data": { - "id": 4, - "name": "Proofread", - "url": "https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9", - "events": [ - "project.created" + $this->mockRequestGet( + '/webhooks', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 4, + 'name' => 'Proofread', + 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', + 'events' => [ + 'project.created', + ], + 'headers' => [ + 'Authorization' => 'Bearer ef231f493cafe336f98d486f596282205b3c2a41710f746cd1d37e905df85f696f5858701aa0b700', + ], + 'payload' => [ + 'project.created' => [ + 'event' => 'test', + ], + ], + 'isActive' => true, + 'batchingEnabled' => true, + 'requestType' => 'GET', + 'contentType' => 'application/json', + 'createdAt' => '2019-09-23T09:19:07+00:00', + 'updatedAt' => '2019-09-23T09:19:07+00:00', + ], + ], ], - "headers": { - "Authorization": "Bearer ef231f493cafe336f98d486f596282205b3c2a41710f746cd1d37e905df85f696f5858701aa0b700" - }, - "payload": { - "project.created": { - "event": "test" - } - }, - "isActive": true, - "batchingEnabled": true, - "requestType": "GET", - "contentType": "application/json", - "createdAt": "2019-09-23T09:19:07+00:00", - "updatedAt": "2019-09-23T09:19:07+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }'); + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]) + ); $webhooks = $this->crowdin->organizationWebhook->list(); + $this->assertInstanceOf(ModelCollection::class, $webhooks); $this->assertCount(1, $webhooks); $this->assertInstanceOf(OrganizationWebhook::class, $webhooks[0]); @@ -55,51 +59,47 @@ public function testCreate() $params = [ 'name' => 'Proofread', 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', - 'events' => - [ - 'project.created', - ], + 'events' => [ + 'project.created', + ], 'requestType' => 'POST', 'isActive' => true, 'batchingEnabled' => false, 'contentType' => 'multipart/form-data', - 'headers' => - [ - ], - 'payload' => - [ - ], + 'headers' => [], + 'payload' => [], ]; $this->mockRequest([ 'path' => '/webhooks', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 4, - "name": "Proofread", - "url": "https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9", - "events": [ - "project.created" - ], - "headers": [ - "string" + 'response' => json_encode([ + 'data' => [ + 'id' => 4, + 'name' => 'Proofread', + 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', + 'events' => [ + 'project.created', + ], + 'headers' => [ + 'string', + ], + 'payload' => [ + 'string', + ], + 'isActive' => true, + 'batchingEnabled' => false, + 'requestType' => 'POST', + 'contentType' => 'multipart/form-data', + 'createdAt' => '2019-09-23T09:19:07+00:00', + 'updatedAt' => '2019-09-23T09:19:07+00:00', ], - "payload": [ - "string" - ], - "isActive": true, - "batchingEnabled": false, - "requestType": "POST", - "contentType": "multipart/form-data", - "createdAt": "2019-09-23T09:19:07+00:00", - "updatedAt": "2019-09-23T09:19:07+00:00" - } - }' + ]), ]); $webhook = $this->crowdin->organizationWebhook->create($params); + $this->assertInstanceOf(OrganizationWebhook::class, $webhook); $this->assertEquals(4, $webhook->getId()); $this->assertEquals(false, $webhook->isBatchingEnabled()); @@ -107,59 +107,68 @@ public function testCreate() public function testGetAndUpdate() { - $this->mockRequestGet('/webhooks/4', '{ - "data": { - "id": 4, - "name": "Proofread", - "url": "https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9", - "events": [ - "project.created" + $this->mockRequestGet( + '/webhooks/4', + json_encode([ + 'data' => [ + 'id' => 4, + 'name' => 'Proofread', + 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', + 'events' => [ + 'project.created', + ], + 'headers' => [ + 'string', + ], + 'payload' => [ + 'string', + ], + 'isActive' => true, + 'batchingEnabled' => false, + 'requestType' => 'POST', + 'contentType' => 'multipart/form-data', + 'createdAt' => '2019-09-23T09:19:07+00:00', + 'updatedAt' => '2019-09-23T09:19:07+00:00', ], - "headers": [ - "string" - ], - "payload": [ - "string" - ], - "isActive": true, - "batchingEnabled": false, - "requestType": "POST", - "contentType": "multipart/form-data", - "createdAt": "2019-09-23T09:19:07+00:00", - "updatedAt": "2019-09-23T09:19:07+00:00" - } - }'); + ]) + ); + $webhook = $this->crowdin->organizationWebhook->get(4); + $this->assertInstanceOf(OrganizationWebhook::class, $webhook); $this->assertEquals(4, $webhook->getId()); $webhook->setName('test'); $webhook->setBatchingEnabled(true); - $this->mockRequestPatch('/webhooks/4', '{ - "data": { - "id": 4, - "name": "test", - "url": "https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9", - "events": [ - "project.created" + $this->mockRequestPatch( + '/webhooks/4', + json_encode([ + 'data' => [ + 'id' => 4, + 'name' => 'test', + 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', + 'events' => [ + 'project.created', + ], + 'headers' => [ + 'string', + ], + 'payload' => [ + 'string', + ], + 'isActive' => true, + 'batchingEnabled' => true, + 'requestType' => 'POST', + 'contentType' => 'multipart/form-data', + 'createdAt' => '2019-09-23T09:19:07+00:00', + 'updatedAt' => '2019-09-23T09:19:07+00:00', ], - "headers": [ - "string" - ], - "payload": [ - "string" - ], - "isActive": true, - "batchingEnabled": true, - "requestType": "POST", - "contentType": "multipart/form-data", - "createdAt": "2019-09-23T09:19:07+00:00", - "updatedAt": "2019-09-23T09:19:07+00:00" - } - }'); + ]) + ); $webhook = $this->crowdin->organizationWebhook->update($webhook); + $this->assertInstanceOf(OrganizationWebhook::class, $webhook); $this->assertEquals(4, $webhook->getId()); $this->assertEquals('test', $webhook->getName()); diff --git a/tests/CrowdinApiClient/Api/ProjectApiTest.php b/tests/CrowdinApiClient/Api/ProjectApiTest.php index d453981b..a0dec8a3 100644 --- a/tests/CrowdinApiClient/Api/ProjectApiTest.php +++ b/tests/CrowdinApiClient/Api/ProjectApiTest.php @@ -61,7 +61,7 @@ public function testCreate(): void 'type' => 1, 'sourceLanguageId' => 'uk', 'targetLanguageIds' => [ - 0 => 'es', + 'es', ], 'visibility' => 'private', 'languageAccessPolicy' => 'moderate', diff --git a/tests/CrowdinApiClient/Api/ReportArchiveApiTest.php b/tests/CrowdinApiClient/Api/ReportArchiveApiTest.php index 85a8fd9a..a4732a97 100644 --- a/tests/CrowdinApiClient/Api/ReportArchiveApiTest.php +++ b/tests/CrowdinApiClient/Api/ReportArchiveApiTest.php @@ -6,38 +6,39 @@ use CrowdinApiClient\Model\ReportArchive; use CrowdinApiClient\Model\ReportArchiveExport; use CrowdinApiClient\ModelCollection; +use stdClass; class ReportArchiveApiTest extends AbstractTestApi { - public function testList() { $this->mockRequest([ 'path' => '/users/1/reports/archives', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 12, - "scopeType": "project", - "scopeId": 35, - "userId": 35, - "name": "string", - "webUrl": "https://crowdin.com/project/project-identifier/reports/archive/1", - "scheme": {}, - "createdAt": "2019-09-23T11:26:54+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 12, + 'scopeType' => 'project', + 'scopeId' => 35, + 'userId' => 35, + 'name' => 'string', + 'webUrl' => 'https://crowdin.com/project/project-identifier/reports/archive/1', + 'scheme' => new stdClass(), + 'createdAt' => '2019-09-23T11:26:54+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]), ]); $reportArchives = $this->crowdin->reportArchive->list(1); + $this->assertInstanceOf(ModelCollection::class, $reportArchives); $this->assertCount(1, $reportArchives); $this->assertInstanceOf(ReportArchive::class, $reportArchives[0]); @@ -49,21 +50,22 @@ public function testGet() $this->mockRequest([ 'path' => '/users/1/reports/archives/12', 'method' => 'get', - 'response' => '{ - "data": { - "id": 12, - "scopeType": "project", - "scopeId": 35, - "userId": 35, - "name": "report archive name", - "webUrl": "https://crowdin.com/project/project-identifier/reports/archive/1", - "scheme": {}, - "createdAt": "2019-09-23T11:26:54+00:00" - } - }', + 'response' => json_encode([ + 'data' => [ + 'id' => 12, + 'scopeType' => 'project', + 'scopeId' => 35, + 'userId' => 35, + 'name' => 'report archive name', + 'webUrl' => 'https://crowdin.com/project/project-identifier/reports/archive/1', + 'scheme' => new stdClass(), + 'createdAt' => '2019-09-23T11:26:54+00:00', + ], + ]), ]); $reportArchive = $this->crowdin->reportArchive->get(1, 12); + $this->assertInstanceOf(ReportArchive::class, $reportArchive); $this->assertEquals(12, $reportArchive->getId()); $this->assertEquals('report archive name', $reportArchive->getName()); @@ -77,27 +79,26 @@ public function testDelete() public function testExport() { - $params = []; $this->mockRequest([ 'path' => '/users/1/reports/archives/12/exports', 'method' => 'post', - 'body' => json_encode($params), - 'response' => '{ - "data": { - "identifier": "50fb3506-4127-4ba8-8296-f97dc7e3e0c3", - "status": "finished", - "progress": 100, - "attributes": { - "format": "xlsx", - "reportName": "costs-estimation", - "schema": {} - }, - "createdAt": "2019-09-23T11:26:54+00:00", - "updatedAt": "2019-09-23T11:26:54+00:00", - "startedAt": "2019-09-23T11:26:54+00:00", - "finishedAt": "2019-09-23T11:26:54+00:00" - } - }' + 'body' => json_encode([]), + 'response' => json_encode([ + 'data' => [ + 'identifier' => '50fb3506-4127-4ba8-8296-f97dc7e3e0c3', + 'status' => 'finished', + 'progress' => 100, + 'attributes' => [ + 'format' => 'xlsx', + 'reportName' => 'costs-estimation', + 'schema' => new stdClass(), + ], + 'createdAt' => '2019-09-23T11:26:54+00:00', + 'updatedAt' => '2019-09-23T11:26:54+00:00', + 'startedAt' => '2019-09-23T11:26:54+00:00', + 'finishedAt' => '2019-09-23T11:26:54+00:00', + ], + ]), ]); $export = $this->crowdin->reportArchive->export(1, 12); @@ -106,31 +107,37 @@ public function testExport() $this->assertEquals('50fb3506-4127-4ba8-8296-f97dc7e3e0c3', $export->getIdentifier()); $this->assertEquals('2019-09-23T11:26:54+00:00', $export->getCreatedAt()); $this->assertEquals('2019-09-23T11:26:54+00:00', $export->getStartedAt()); - $this->assertEquals([ - 'format' => 'xlsx', - 'reportName' => 'costs-estimation', - 'schema' => [], - ], $export->getAttributes()); + $this->assertEquals( + [ + 'format' => 'xlsx', + 'reportName' => 'costs-estimation', + 'schema' => [], + ], + $export->getAttributes() + ); } public function testCheckExportStatus() { - $this->mockRequestGet('/users/1/reports/archives/12/exports/50fb3506-4127-4ba8-8296-f97dc7e3e0c3', '{ - "data": { - "identifier": "50fb3506-4127-4ba8-8296-f97dc7e3e0c3", - "status": "finished", - "progress": 100, - "attributes": { - "format": "xlsx", - "reportName": "costs-estimation", - "schema": {} - }, - "createdAt": "2019-09-23T11:26:54+00:00", - "updatedAt": "2019-09-23T11:26:54+00:00", - "startedAt": "2019-09-23T11:26:54+00:00", - "finishedAt": "2019-09-23T11:26:54+00:00" - } - }'); + $this->mockRequestGet( + '/users/1/reports/archives/12/exports/50fb3506-4127-4ba8-8296-f97dc7e3e0c3', + json_encode([ + 'data' => [ + 'identifier' => '50fb3506-4127-4ba8-8296-f97dc7e3e0c3', + 'status' => 'finished', + 'progress' => 100, + 'attributes' => [ + 'format' => 'xlsx', + 'reportName' => 'costs-estimation', + 'schema' => new stdClass(), + ], + 'createdAt' => '2019-09-23T11:26:54+00:00', + 'updatedAt' => '2019-09-23T11:26:54+00:00', + 'startedAt' => '2019-09-23T11:26:54+00:00', + 'finishedAt' => '2019-09-23T11:26:54+00:00', + ], + ]) + ); $export = $this->crowdin->reportArchive->checkExportStatus(1, 12, '50fb3506-4127-4ba8-8296-f97dc7e3e0c3'); @@ -144,16 +151,26 @@ public function testCheckExportStatus() public function testDownloadReportArchive() { - $this->mockRequestGet('/users/1/reports/archives/12/exports/50fb3506-4127-4ba8-8296-f97dc7e3e0c3/download', '{ - "data": { - "url": "https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62", - "expireIn": "2019-09-20T10:31:21+00:00" - } - }'); - - $downloadFile = $this->crowdin->reportArchive->downloadReportArchive(1, 12, '50fb3506-4127-4ba8-8296-f97dc7e3e0c3'); + $this->mockRequestGet( + '/users/1/reports/archives/12/exports/50fb3506-4127-4ba8-8296-f97dc7e3e0c3/download', + json_encode([ + 'data' => [ + 'url' => 'https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', + 'expireIn' => '2019-09-20T10:31:21+00:00', + ], + ]) + ); + + $downloadFile = $this->crowdin->reportArchive->downloadReportArchive( + 1, + 12, + '50fb3506-4127-4ba8-8296-f97dc7e3e0c3' + ); $this->assertInstanceOf(DownloadFile::class, $downloadFile); - $this->assertEquals('https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', $downloadFile->getUrl()); + $this->assertEquals( + 'https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', + $downloadFile->getUrl() + ); } } diff --git a/tests/CrowdinApiClient/Api/ScreenshotApiTest.php b/tests/CrowdinApiClient/Api/ScreenshotApiTest.php index 48daff85..f272b1e6 100644 --- a/tests/CrowdinApiClient/Api/ScreenshotApiTest.php +++ b/tests/CrowdinApiClient/Api/ScreenshotApiTest.php @@ -13,46 +13,49 @@ public function testList() $this->mockRequest([ 'path' => '/projects/2/screenshots', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 2, - "userId": 6, - "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", - "name": "translate_with_siri.jpg", - "size": { - "width": 267, - "height": 176 - }, - "tagsCount": 0, - "tags": [ - { - "id": 98, - "screenshotId": 2, - "stringId": 2822, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'userId' => 6, + 'url' => 'https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73', + 'name' => 'translate_with_siri.jpg', + 'size' => [ + 'width' => 267, + 'height' => 176, + ], + 'tagsCount' => 0, + 'tags' => [ + [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], + ], + 'createdAt' => '2019-09-23T09:29:19+00:00', + 'updatedAt' => '2019-09-23T09:29:19+00:00', + 'labelIds' => [ + 100, + 200, + ], + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, ], - "createdAt": "2019-09-23T09:29:19+00:00", - "updatedAt": "2019-09-23T09:29:19+00:00", - "labelIds": [100, 200] - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + ], + ]), ]); $screenshots = $this->crowdin->screenshot->list(2); @@ -74,114 +77,131 @@ public function testCreate() 'path' => '/projects/2/screenshots', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 2, - "userId": 6, - "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", - "name": "translate_with_siri.jpg", - "size": { - "width": 267, - "height": 176 - }, - "tagsCount": 0, - "tags": [ - { - "id": 98, - "screenshotId": 2, - "stringId": 2822, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } + 'response' => json_encode([ + 'data' => [ + 'id' => 2, + 'userId' => 6, + 'url' => 'https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73', + 'name' => 'translate_with_siri.jpg', + 'size' => [ + 'width' => 267, + 'height' => 176, + ], + 'tagsCount' => 0, + 'tags' => [ + [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], ], - "createdAt": "2019-09-23T09:29:19+00:00", - "updatedAt": "2019-09-23T09:29:19+00:00", - "labelIds": [100, 200] - } - }' + 'createdAt' => '2019-09-23T09:29:19+00:00', + 'updatedAt' => '2019-09-23T09:29:19+00:00', + 'labelIds' => [ + 100, + 200, + ], + ], + ]), ]); $screenshot = $this->crowdin->screenshot->create(2, $params); + $this->assertInstanceOf(Screenshot::class, $screenshot); $this->assertEquals(2, $screenshot->getId()); } public function testGetAndUpdate() { - $this->mockRequestGet('/projects/2/screenshots/2', '{ - "data": { - "id": 2, - "userId": 6, - "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", - "name": "translate_with_siri.jpg", - "size": { - "width": 267, - "height": 176 - }, - "tagsCount": 0, - "tags": [ - { - "id": 98, - "screenshotId": 2, - "stringId": 2822, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } + $this->mockRequestGet( + '/projects/2/screenshots/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'userId' => 6, + 'url' => 'https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73', + 'name' => 'translate_with_siri.jpg', + 'size' => [ + 'width' => 267, + 'height' => 176, + ], + 'tagsCount' => 0, + 'tags' => [ + [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], + ], + 'createdAt' => '2019-09-23T09:29:19+00:00', + 'updatedAt' => '2019-09-23T09:29:19+00:00', + 'labelIds' => [ + 100, + 200, + ], ], - "createdAt": "2019-09-23T09:29:19+00:00", - "updatedAt": "2019-09-23T09:29:19+00:00", - "labelIds": [100, 200] - } - }'); + ]) + ); $screenshot = $this->crowdin->screenshot->get(2, 2); + $this->assertInstanceOf(Screenshot::class, $screenshot); $this->assertEquals(2, $screenshot->getId()); - $this->mockRequestPatch('/projects/2/screenshots/2', '{ - "data": { - "id": 2, - "userId": 6, - "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", - "name": "test_edit.jpg", - "size": { - "width": 267, - "height": 176 - }, - "tagsCount": 0, - "tags": [ - { - "id": 98, - "screenshotId": 2, - "stringId": 2822, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } + $this->mockRequestPatch( + '/projects/2/screenshots/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'userId' => 6, + 'url' => 'https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73', + 'name' => 'test_edit.jpg', + 'size' => [ + 'width' => 267, + 'height' => 176, + ], + 'tagsCount' => 0, + 'tags' => [ + [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], + ], + 'createdAt' => '2019-09-23T09:29:19+00:00', + 'updatedAt' => '2019-09-23T09:29:19+00:00', + 'labelIds' => [ + 100, + 200, + ], ], - "createdAt": "2019-09-23T09:29:19+00:00", - "updatedAt": "2019-09-23T09:29:19+00:00", - "labelIds": [100, 200] - } - }'); + ]) + ); $screenshot->setName('test_edit.jpg'); - $screenshot = $this->crowdin->screenshot->update(2, $screenshot); + $this->assertInstanceOf(Screenshot::class, $screenshot); $this->assertEquals(2, $screenshot->getId()); $this->assertEquals('test_edit.jpg', $screenshot->getName()); @@ -189,48 +209,50 @@ public function testGetAndUpdate() public function testReplace() { - $params = [ - 'storageId' => 0, - 'name' => 'string' - ]; - $this->mockRequest([ 'path' => '/projects/2/screenshots/2', 'method' => 'put', - 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 2, - "userId": 6, - "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", - "name": "translate_with_siri.jpg", - "size": { - "width": 267, - "height": 176 - }, - "tagsCount": 0, - "tags": [ - { - "id": 98, - "screenshotId": 2, - "stringId": 2822, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } + 'body' => json_encode([ + 'storageId' => 0, + 'name' => 'string', + ]), + 'response' => json_encode([ + 'data' => [ + 'id' => 2, + 'userId' => 6, + 'url' => 'https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73', + 'name' => 'translate_with_siri.jpg', + 'size' => [ + 'width' => 267, + 'height' => 176, + ], + 'tagsCount' => 0, + 'tags' => [ + [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], + ], + 'createdAt' => '2019-09-23T09:29:19+00:00', + 'updatedAt' => '2019-09-23T09:29:19+00:00', + 'labelIds' => [ + 100, + 200, + ], ], - "createdAt": "2019-09-23T09:29:19+00:00", - "updatedAt": "2019-09-23T09:29:19+00:00", - "labelIds": [100, 200] - } - }' + ]), ]); $screenshot = $this->crowdin->screenshot->replace(2, 2, 0, 'string'); + $this->assertInstanceOf(Screenshot::class, $screenshot); $this->assertEquals(2, $screenshot->getId()); } @@ -244,70 +266,72 @@ public function testDelete() public function testCreateTag() { $params = [ - 0 => - [ - 'stringId' => 0, - 'position' => - [ - 'x' => 0, - 'y' => 0, - 'width' => 0, - 'height' => 0, - ], + [ + 'stringId' => 0, + 'position' => [ + 'x' => 0, + 'y' => 0, + 'width' => 0, + 'height' => 0, ], + ], ]; $this->mockRequest([ 'path' => '/projects/2/screenshots/2/tags', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 98, - "screenshotId": 2, - "stringId": 2822, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], + ]), ]); $tag = $this->crowdin->screenshot->addTag(2, 2, $params); + $this->assertInstanceOf(Tag::class, $tag); $this->assertEquals(98, $tag->getId()); } public function testListTags() { - $this->mockRequestGet('/projects/2/screenshots/2/tags', '{ - "data": [ - { - "data": { - "id": 98, - "screenshotId": 2, - "stringId": 2822, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }'); + $this->mockRequestGet( + '/projects/2/screenshots/2/tags', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]) + ); $tags = $this->crowdin->screenshot->tags(2, 2); @@ -325,54 +349,61 @@ public function testClearTag() public function testGetAndUpdateTag() { - $this->mockRequestGet('/projects/2/screenshots/2/tags/98', '{ - "data": { - "id": 98, - "screenshotId": 2, - "stringId": 2822, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } - }'); + $this->mockRequestGet( + '/projects/2/screenshots/2/tags/98', + json_encode([ + 'data' => [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], + ]) + ); $tag = $this->crowdin->screenshot->getTag(2, 2, 98); + $this->assertInstanceOf(Tag::class, $tag); $this->assertEquals(98, $tag->getId()); - $this->mockRequestPatch('/projects/2/screenshots/2/tags/98', '{ - "data": { - "id": 2, - "userId": 6, - "url": "https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73", - "name": "translate_with_siri.jpg", - "size": { - "width": 267, - "height": 176 - }, - "tagsCount": 0, - "tags": [ - { - "id": 98, - "screenshotId": 2, - "stringId": 22, - "position": { - "x": 474, - "y": 147, - "width": 490, - "height": 99 - }, - "createdAt": "2019-09-23T09:35:31+00:00" - } + $this->mockRequestPatch( + '/projects/2/screenshots/2/tags/98', + json_encode([ + 'data' => [ + 'id' => 2, + 'userId' => 6, + 'url' => 'https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73', + 'name' => 'translate_with_siri.jpg', + 'size' => [ + 'width' => 267, + 'height' => 176, ], - "createdAt": "2019-09-23T09:29:19+00:00", - "updatedAt": "2019-09-23T09:29:19+00:00" - } - }'); + 'tagsCount' => 0, + 'tags' => [ + [ + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 22, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', + ], + ], + 'createdAt' => '2019-09-23T09:29:19+00:00', + 'updatedAt' => '2019-09-23T09:29:19+00:00', + ], + ]) + ); $tag->setStringId(22); $screenshot = $this->crowdin->screenshot->updateTag(2, $tag); @@ -390,23 +421,21 @@ public function testDeleteTag() public function testReplaceTags() { $params = [ - 0 => - [ - 'stringId' => 0, - 'position' => - [ - 'x' => 0, - 'y' => 0, - 'width' => 0, - 'height' => 0, - ], + [ + 'stringId' => 0, + 'position' => [ + 'x' => 0, + 'y' => 0, + 'width' => 0, + 'height' => 0, ], + ], ]; $this->mockRequest([ 'path' => '/projects/2/screenshots/2/tags', 'method' => 'put', - 'body' => json_encode($params) + 'body' => json_encode($params), ]); $this->crowdin->screenshot->replaceTags(2, 2, $params); diff --git a/tests/CrowdinApiClient/Api/SecurityLogApiTest.php b/tests/CrowdinApiClient/Api/SecurityLogApiTest.php index 3aa42f5b..ec60b73a 100644 --- a/tests/CrowdinApiClient/Api/SecurityLogApiTest.php +++ b/tests/CrowdinApiClient/Api/SecurityLogApiTest.php @@ -9,33 +9,38 @@ class SecurityLogApiTest extends AbstractTestApi { public function testList() { - $this->mockRequestGet('/users/4/security-logs', '{ - "data": [ - { - "data": { - "id": 2, - "event": "Some event", - "info": "Some info", - "userId": 4, - "location": "USA", - "ipAddress": "127.0.0.1", - "deviceName": "MacOs on MacBook", - "createdAt": "2019-09-19T15:10:43+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }'); + $this->mockRequestGet( + '/users/4/security-logs', + json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'event' => 'Some event', + 'info' => 'Some info', + 'userId' => 4, + 'location' => 'USA', + 'ipAddress' => '127.0.0.1', + 'deviceName' => 'MacOs on MacBook', + 'createdAt' => '2019-09-19T15:10:43+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]) + ); $securityLogs = $this->crowdin->securityLog->listUserSecurityLogs(4); + $this->assertInstanceOf(ModelCollection::class, $securityLogs); $this->assertCount(1, $securityLogs); /** @var SecurityLog $securityLog */ $securityLog = $securityLogs[0]; + $this->assertInstanceOf(SecurityLog::class, $securityLog); $this->assertEquals(2, $securityLog->getId()); $this->assertEquals('Some event', $securityLog->getEvent()); @@ -49,20 +54,24 @@ public function testList() public function testGet() { - $this->mockRequestGet('/users/4/security-logs/2', '{ - "data": { - "id": 2, - "event": "Some event", - "info": "Some info", - "userId": 4, - "location": "USA", - "ipAddress": "127.0.0.1", - "deviceName": "MacOs on MacBook", - "createdAt": "2019-09-19T15:10:43+00:00" - } - }'); + $this->mockRequestGet( + '/users/4/security-logs/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'event' => 'Some event', + 'info' => 'Some info', + 'userId' => 4, + 'location' => 'USA', + 'ipAddress' => '127.0.0.1', + 'deviceName' => 'MacOs on MacBook', + 'createdAt' => '2019-09-19T15:10:43+00:00', + ], + ]) + ); $securityLog = $this->crowdin->securityLog->getUserSecurityLog(4, 2); + $this->assertInstanceOf(SecurityLog::class, $securityLog); $this->assertEquals(2, $securityLog->getId()); $this->assertEquals('Some event', $securityLog->getEvent()); diff --git a/tests/CrowdinApiClient/Api/SourceStringApiTest.php b/tests/CrowdinApiClient/Api/SourceStringApiTest.php index 64b9b4ee..142d0fa5 100644 --- a/tests/CrowdinApiClient/Api/SourceStringApiTest.php +++ b/tests/CrowdinApiClient/Api/SourceStringApiTest.php @@ -13,35 +13,35 @@ public function testList() $this->mockRequest([ 'path' => '/projects/2/strings', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 2814, - "projectId": 2, - "fileId": 48, - "branchId": 12, - "identifier": "6a1821e6499ebae94de4b880fd93b985", - "text": "Not all videos are shown to users. See more", - "type": "text", - "context": "shown on main page", - "maxLength": 35, - "isHidden": false, - "revision": 1, - "hasPlurals": false, - "isIcu": false, - "createdAt": "2019-09-20T12:43:57+00:00", - "updatedAt": "2019-09-20T13:24:01+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2814, + 'projectId' => 2, + 'fileId' => 48, + 'branchId' => 12, + 'identifier' => '6a1821e6499ebae94de4b880fd93b985', + 'text' => 'Not all videos are shown to users. See more', + 'type' => 'text', + 'context' => 'shown on main page', + 'maxLength' => 35, + 'isHidden' => false, + 'revision' => 1, + 'hasPlurals' => false, + 'isIcu' => false, + 'createdAt' => '2019-09-20T12:43:57+00:00', + 'updatedAt' => '2019-09-20T13:24:01+00:00', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $sourceStrings = $this->crowdin->sourceString->list(2); @@ -101,54 +101,61 @@ public function testSearch(): void public function testGetAndUpdate() { - $this->mockRequestGet('/projects/2/strings/2814', '{ - "data": { - "id": 2814, - "projectId": 2, - "fileId": 48, - "branchId": 12, - "identifier": "6a1821e6499ebae94de4b880fd93b985", - "text": "Not all videos are shown to users. See more", - "type": "text", - "context": "shown on main page", - "maxLength": 35, - "isHidden": false, - "revision": 1, - "hasPlurals": false, - "isIcu": false, - "createdAt": "2019-09-20T12:43:57+00:00", - "updatedAt": "2019-09-20T13:24:01+00:00" - } - }'); + $this->mockRequestGet( + '/projects/2/strings/2814', + json_encode([ + 'data' => [ + 'id' => 2814, + 'projectId' => 2, + 'fileId' => 48, + 'branchId' => 12, + 'identifier' => '6a1821e6499ebae94de4b880fd93b985', + 'text' => 'Not all videos are shown to users. See more', + 'type' => 'text', + 'context' => 'shown on main page', + 'maxLength' => 35, + 'isHidden' => false, + 'revision' => 1, + 'hasPlurals' => false, + 'isIcu' => false, + 'createdAt' => '2019-09-20T12:43:57+00:00', + 'updatedAt' => '2019-09-20T13:24:01+00:00', + ], + ]) + ); $sourceString = $this->crowdin->sourceString->get(2, 2814); + $this->assertInstanceOf(SourceString::class, $sourceString); $this->assertEquals(2814, $sourceString->getId()); - $this->mockRequestPatch('/projects/2/strings/2814', '{ - "data": { - "id": 2814, - "projectId": 2, - "fileId": 48, - "branchId": 12, - "identifier": "6a1821e6499ebae94de4b880fd93b985", - "text": "test edit", - "type": "text", - "context": "shown on main page", - "maxLength": 35, - "isHidden": false, - "revision": 1, - "hasPlurals": false, - "isIcu": false, - "createdAt": "2019-09-20T12:43:57+00:00", - "updatedAt": "2019-09-20T13:24:01+00:00", - "isDuplicate": false, - } - }' + $this->mockRequestPatch( + '/projects/2/strings/2814', + json_encode([ + 'data' => [ + 'id' => 2814, + 'projectId' => 2, + 'fileId' => 48, + 'branchId' => 12, + 'identifier' => '6a1821e6499ebae94de4b880fd93b985', + 'text' => 'test edit', + 'type' => 'text', + 'context' => 'shown on main page', + 'maxLength' => 35, + 'isHidden' => false, + 'revision' => 1, + 'hasPlurals' => false, + 'isIcu' => false, + 'createdAt' => '2019-09-20T12:43:57+00:00', + 'updatedAt' => '2019-09-20T13:24:01+00:00', + 'isDuplicate' => false, + ], + ]) ); $sourceString->setText('test edit'); $this->crowdin->sourceString->update($sourceString); + $this->assertInstanceOf(SourceString::class, $sourceString); $this->assertEquals(2814, $sourceString->getId()); $this->assertEquals('test edit', $sourceString->getText()); @@ -159,32 +166,32 @@ public function testCreate() { $params = [ 'identifier' => 'identifier', - 'text' => 'Not all videos are shown to users. See more' + 'text' => 'Not all videos are shown to users. See more', ]; $this->mockRequest([ 'path' => '/projects/2/strings', 'method' => 'post', - 'response' => '{ - "data": { - "id": 2814, - "projectId": 2, - "fileId": 48, - "branchId": 12, - "identifier": "6a1821e6499ebae94de4b880fd93b985", - "text": "Not all videos are shown to users. See more", - "type": "text", - "context": "shown on main page", - "maxLength": 35, - "isHidden": false, - "revision": 1, - "hasPlurals": false, - "isIcu": false, - "createdAt": "2019-09-20T12:43:57+00:00", - "updatedAt": "2019-09-20T13:24:01+00:00" - } - }', - 'body' => json_encode($params) + 'response' => json_encode([ + 'data' => [ + 'id' => 2814, + 'projectId' => 2, + 'fileId' => 48, + 'branchId' => 12, + 'identifier' => '6a1821e6499ebae94de4b880fd93b985', + 'text' => 'Not all videos are shown to users. See more', + 'type' => 'text', + 'context' => 'shown on main page', + 'maxLength' => 35, + 'isHidden' => false, + 'revision' => 1, + 'hasPlurals' => false, + 'isIcu' => false, + 'createdAt' => '2019-09-20T12:43:57+00:00', + 'updatedAt' => '2019-09-20T13:24:01+00:00', + ], + ]), + 'body' => json_encode($params), ]); $sourceString = $this->crowdin->sourceString->create(2, $params); @@ -208,63 +215,66 @@ public function testBatch() $this->mockRequest([ 'path' => '/projects/2/strings', 'method' => 'patch', - 'response' => '{ - "data":[ - { - "data":{ - "id":2814, - "projectId": 2, - "branchId":null, - "identifier":"a.b.c", - "text":"new added string", - "type":"text", - "context":"a.b.c\ncontext for new string", - "maxLength":0, - "isHidden":false, - "isDuplicate":false, - "masterStringId":null, - "hasPlurals":false, - "isIcu":false, - "labelIds":[], - "webUrl":"https://example.crowdin.com/editor/1/all/en-pl?filter=basic&value=0&view=comfortable#2", - "createdAt":"2024-11-13T16:56:18+00:00", - "updatedAt":null, - "fileId":48, - "directoryId":null, - "revision":1 - } - } - ] - }' - ]); + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2814, + 'projectId' => 2, + 'branchId' => null, + 'identifier' => 'a.b.c', + 'text' => 'new added string', + 'type' => 'text', + 'context' => "a.b.c\ncontext for new string", + 'maxLength' => 0, + 'isHidden' => false, + 'isDuplicate' => false, + 'masterStringId' => null, + 'hasPlurals' => false, + 'isIcu' => false, + 'labelIds' => [], + 'webUrl' => 'https://example.crowdin.com/editor/1/all/en-pl?filter=basic&value=0&view=comfortable#2', + 'createdAt' => '2024-11-13T16:56:18+00:00', + 'updatedAt' => null, + 'fileId' => 48, + 'directoryId' => null, + 'revision' => 1, + ], + ], + ], + ]), + ]); - $batchResult = $this->crowdin->sourceString->batchOperations(2, [ - [ - 'op' => 'replace', - 'path' => '/2814/isHidden', - 'value' => true - ], - [ - 'op' => 'replace', - 'path' => '/2814/context', - 'value' => 'some context' - ], + $batchResult = $this->crowdin->sourceString->batchOperations( + 2, [ - 'op' => 'add', - 'path' => '/-', - 'value' => [ - 'text' => 'new added string', - 'identifier' => 'a.b.c', - 'context' => 'context for new string', - 'fileId' => 8, - 'isHidden' => false - ] - ], - [ - 'op' => 'remove', - 'path' => '/2814' + [ + 'op' => 'replace', + 'path' => '/2814/isHidden', + 'value' => true, + ], + [ + 'op' => 'replace', + 'path' => '/2814/context', + 'value' => 'some context', + ], + [ + 'op' => 'add', + 'path' => '/-', + 'value' => [ + 'text' => 'new added string', + 'identifier' => 'a.b.c', + 'context' => 'context for new string', + 'fileId' => 8, + 'isHidden' => false, + ], + ], + [ + 'op' => 'remove', + 'path' => '/2814', + ], ] - ]); + ); $this->assertInstanceOf(SourceString::class, $batchResult); } diff --git a/tests/CrowdinApiClient/Api/StorageApiTest.php b/tests/CrowdinApiClient/Api/StorageApiTest.php index be944ce9..8e3f39b4 100644 --- a/tests/CrowdinApiClient/Api/StorageApiTest.php +++ b/tests/CrowdinApiClient/Api/StorageApiTest.php @@ -13,21 +13,21 @@ public function testList() $this->mockRequest([ 'method' => 'get', 'uri' => 'https://api.crowdin.com/api/v2/storages', - 'response' => '{ - "data": [ - { - "data": { - "id": 1 - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 1, + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $storages = $this->crowdin->storage->list(); @@ -39,21 +39,24 @@ public function testList() * @var Storage $storage */ $storage = $storages[0]; + $this->assertInstanceOf(Storage::class, $storage); } public function testGet() { - $this->mockRequestGet('/storages/1', '{ - "data": { - "id": 1 - } - }'); + $this->mockRequestGet( + '/storages/1', + json_encode([ + 'data' => [ + 'id' => 1, + ], + ]) + ); $storage = $this->crowdin->storage->get(1); $this->assertInstanceOf(Storage::class, $storage); - $this->assertEquals(1, $storage->getId()); } @@ -62,7 +65,7 @@ public function testDelete() $this->mockRequest([ 'method' => 'delete', 'uri' => 'https://api.crowdin.com/api/v2/storages/1', - 'response' => null + 'response' => null, ]); $this->crowdin->storage->delete(1); @@ -77,8 +80,8 @@ public function testCreate(): void 'uri' => 'https://api.crowdin.com/api/v2/storages', 'response' => json_encode([ 'data' => [ - 'id' => 1 - ] + 'id' => 1, + ], ]), 'headers' => [ 'Content-Type' => 'application/octet-stream', diff --git a/tests/CrowdinApiClient/Api/StringCommentApiTest.php b/tests/CrowdinApiClient/Api/StringCommentApiTest.php index 38093620..a01c50e7 100644 --- a/tests/CrowdinApiClient/Api/StringCommentApiTest.php +++ b/tests/CrowdinApiClient/Api/StringCommentApiTest.php @@ -12,50 +12,50 @@ public function testList() $this->mockRequest([ 'path' => '/projects/1/comments', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 2, - "text": "@BeMyEyes Please provide more details on where the text will be used", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title\\r\\nXPath: /html/head/title", - "fileId": 22 - }, - "languageId": "bg", - "type": "issue", - "issueType": "source_mistake", - "issueStatus": "unresolved", - "resolverId": 6, - "resolver": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "resolvedAt": "2019-09-20T11:05:24+00:00", - "createdAt": "2019-09-20T11:05:24+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'text' => '@BeMyEyes Please provide more details on where the text will be used', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => "Document Title\r\nXPath: /html/head/title", + 'fileId' => 22, + ], + 'languageId' => 'bg', + 'type' => 'issue', + 'issueType' => 'source_mistake', + 'issueStatus' => 'unresolved', + 'resolverId' => 6, + 'resolver' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'resolvedAt' => '2019-09-20T11:05:24+00:00', + 'createdAt' => '2019-09-20T11:05:24+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]), ]); $comments = $this->crowdin->stringComment->list(1); @@ -72,47 +72,48 @@ public function testCreate() 'text' => '@BeMyEyes Please provide more details on where the text will be used', 'stringId' => 742, 'targetLanguageId' => 'en', - 'type' => 'comment' + 'type' => 'comment', ]; $this->mockRequest([ 'path' => '/projects/1/comments', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 2, - "text": "@BeMyEyes Please provide more details on where the text will be used", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title\\r\\nXPath: /html/head/title", - "fileId": 22 - }, - "languageId": "en", - "type": "comment", - "issueType": null, - "issueStatus": null, - "resolverId": null, - "resolver": {}, - "resolvedAt": null, - "createdAt": "2019-09-20T11:05:24+00:00" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 2, + 'text' => '@BeMyEyes Please provide more details on where the text will be used', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => "Document Title\r\nXPath: /html/head/title", + 'fileId' => 22, + ], + 'languageId' => 'en', + 'type' => 'comment', + 'issueType' => null, + 'issueStatus' => null, + 'resolverId' => null, + 'resolver' => new \stdClass(), + 'resolvedAt' => null, + 'createdAt' => '2019-09-20T11:05:24+00:00', + ], + ]), ]); $stringComment = $this->crowdin->stringComment->create(1, $params); + $this->assertInstanceOf(StringComment::class, $stringComment); $this->assertEquals(2, $stringComment->getId()); $this->assertEquals('en', $stringComment->getLanguageId()); @@ -125,42 +126,44 @@ public function testCreate() public function testGetAndUpdate() { - $this->mockRequestGet('/projects/8/comments/2', '{ - "data": { - "id": 2, - "text": "@BeMyEyes Please provide more details on where the text will be used", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title\\r\\nXPath: /html/head/title", - "fileId": 22 - }, - "languageId": "bg", - "type": "issue", - "issueType": "source_mistake", - "issueStatus": "unresolved", - "resolverId": 6, - "resolver": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "resolvedAt": "2019-09-20T11:05:24+00:00", - "createdAt": "2019-09-20T11:05:24+00:00" - } - }' + $this->mockRequestGet( + '/projects/8/comments/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'text' => '@BeMyEyes Please provide more details on where the text will be used', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => "Document Title\r\nXPath: /html/head/title", + 'fileId' => 22, + ], + 'languageId' => 'bg', + 'type' => 'issue', + 'issueType' => 'source_mistake', + 'issueStatus' => 'unresolved', + 'resolverId' => 6, + 'resolver' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'resolvedAt' => '2019-09-20T11:05:24+00:00', + 'createdAt' => '2019-09-20T11:05:24+00:00', + ], + ]) ); $stringComment = $this->crowdin->stringComment->get(8, 2); @@ -169,42 +172,46 @@ public function testGetAndUpdate() $this->assertEquals(2, $stringComment->getId()); $stringComment->setText('edit test'); - $this->mockRequestPatch('/projects/8/comments/2', '{ - "data": { - "id": 2, - "text": "edit test", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title\\r\\nXPath: /html/head/title", - "fileId": 22 - }, - "languageId": "bg", - "type": "issue", - "issueType": "source_mistake", - "issueStatus": "unresolved", - "resolverId": 6, - "resolver": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "resolvedAt": "2019-09-20T11:05:24+00:00", - "createdAt": "2019-09-20T11:05:24+00:00" - } - }'); + + $this->mockRequestPatch( + '/projects/8/comments/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'text' => 'edit test', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => "Document Title\r\nXPath: /html/head/title", + 'fileId' => 22, + ], + 'languageId' => 'bg', + 'type' => 'issue', + 'issueType' => 'source_mistake', + 'issueStatus' => 'unresolved', + 'resolverId' => 6, + 'resolver' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'resolvedAt' => '2019-09-20T11:05:24+00:00', + 'createdAt' => '2019-09-20T11:05:24+00:00', + ], + ]) + ); $stringComment = $this->crowdin->stringComment->update(8, $stringComment); @@ -224,41 +231,42 @@ public function testDeleteAttachment() $this->mockRequest([ 'path' => '/projects/1/comments/2/attachments/10', 'method' => 'delete', - 'response' => '{ - "data": { - "id": 2, - "text": "@BeMyEyes Please provide more details on where the text will be used", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title\\r\\nXPath: /html/head/title", - "fileId": 22 - }, - "languageId": "bg", - "type": "comment", - "issueType": null, - "issueStatus": null, - "resolverId": null, - "resolver": {}, - "resolvedAt": null, - "createdAt": "2019-09-20T11:05:24+00:00", - "attachments": [] - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 2, + 'text' => '@BeMyEyes Please provide more details on where the text will be used', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => "Document Title\r\nXPath: /html/head/title", + 'fileId' => 22, + ], + 'languageId' => 'bg', + 'type' => 'comment', + 'issueType' => null, + 'issueStatus' => null, + 'resolverId' => null, + 'resolver' => new \stdClass(), + 'resolvedAt' => null, + 'createdAt' => '2019-09-20T11:05:24+00:00', + 'attachments' => [], + ], + ]), ]); $stringComment = $this->crowdin->stringComment->deleteAttachment(1, 2, 10); + $this->assertInstanceOf(StringComment::class, $stringComment); $this->assertEquals(2, $stringComment->getId()); $this->assertEquals([], $stringComment->getAttachments()); @@ -269,60 +277,63 @@ public function testBatchOperations() $this->mockRequest([ 'path' => '/projects/1/comments', 'method' => 'patch', - 'response' => '{ - "data": [ - { - "data": { - "id": 2, - "text": "Updated comment text", - "userId": 6, - "stringId": 742, - "user": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "string": { - "id": 123, - "text": "HTML page example", - "type": "text", - "hasPlurals": false, - "isIcu": false, - "context": "Document Title\\r\\nXPath: /html/head/title", - "fileId": 22 - }, - "languageId": "bg", - "type": "issue", - "issueType": "source_mistake", - "issueStatus": "resolved", - "resolverId": 6, - "resolver": { - "id": 12, - "username": "john_smith", - "fullName": "John Smith", - "avatarUrl": "" - }, - "resolvedAt": "2019-09-20T11:05:24+00:00", - "createdAt": "2019-09-20T11:05:24+00:00" - } - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'text' => 'Updated comment text', + 'userId' => 6, + 'stringId' => 742, + 'user' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'string' => [ + 'id' => 123, + 'text' => 'HTML page example', + 'type' => 'text', + 'hasPlurals' => false, + 'isIcu' => false, + 'context' => "Document Title\r\nXPath: /html/head/title", + 'fileId' => 22, + ], + 'languageId' => 'bg', + 'type' => 'issue', + 'issueType' => 'source_mistake', + 'issueStatus' => 'resolved', + 'resolverId' => 6, + 'resolver' => [ + 'id' => 12, + 'username' => 'john_smith', + 'fullName' => 'John Smith', + 'avatarUrl' => '', + ], + 'resolvedAt' => '2019-09-20T11:05:24+00:00', + 'createdAt' => '2019-09-20T11:05:24+00:00', + ], + ], + ], + ]), ]); - $batchResult = $this->crowdin->stringComment->batchOperations(1, [ + $batchResult = $this->crowdin->stringComment->batchOperations( + 1, [ - 'op' => 'replace', - 'path' => '/2/text', - 'value' => 'Updated comment text' - ], - [ - 'op' => 'replace', - 'path' => '/2/issueStatus', - 'value' => 'resolved' + [ + 'op' => 'replace', + 'path' => '/2/text', + 'value' => 'Updated comment text', + ], + [ + 'op' => 'replace', + 'path' => '/2/issueStatus', + 'value' => 'resolved', + ], ] - ]); + ); $this->assertInstanceOf(StringComment::class, $batchResult); } diff --git a/tests/CrowdinApiClient/Api/StringsExporterSettingApiTest.php b/tests/CrowdinApiClient/Api/StringsExporterSettingApiTest.php index 7aa68b11..9328ee0f 100644 --- a/tests/CrowdinApiClient/Api/StringsExporterSettingApiTest.php +++ b/tests/CrowdinApiClient/Api/StringsExporterSettingApiTest.php @@ -10,39 +10,37 @@ class StringsExporterSettingApiTest extends AbstractTestApi public function testList() { $this->mockRequest([ - 'path' => '/projects/2/strings-exporter-settings', - 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 2, - "format": "android", - "settings": { - "convertPlaceholders": false - }, - "createdAt": "2019-09-19T15:10:43+00:00", - "updatedAt": "2019-09-19T15:10:46+00:00" - } - } - ], - "pagination": { - "offset": 0, - "limit": 25 - } - }' + 'path' => '/projects/2/strings-exporter-settings', + 'method' => 'get', + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 2, + 'format' => 'android', + 'settings' => [ + 'convertPlaceholders' => false, + ], + 'createdAt' => '2019-09-19T15:10:43+00:00', + 'updatedAt' => '2019-09-19T15:10:46+00:00', + ], + ], + ], + 'pagination' => [ + 'offset' => 0, + 'limit' => 25, + ], + ]), ]); $data = $this->crowdin->stringsExporterSetting->list(2); $this->assertInstanceOf(ModelCollection::class, $data); $this->assertCount(1, $data); - /** - * @var StringsExporterSetting $stringsExporterSetting - */ + + /** @var StringsExporterSetting $stringsExporterSetting */ $stringsExporterSetting = $data[0]; $this->assertInstanceOf(StringsExporterSetting::class, $stringsExporterSetting); - $this->assertEquals(2, $stringsExporterSetting->getId()); $this->assertEquals('android', $stringsExporterSetting->getFormat()); } @@ -51,23 +49,22 @@ public function testGet() { $this->mockRequestGet( '/projects/2/strings-exporter-settings/2', - '{ - "data": { - "id": 2, - "format": "android", - "settings": { - "convertPlaceholders": false - }, - "createdAt": "2019-09-19T15:10:43+00:00", - "updatedAt": "2019-09-19T15:10:46+00:00" - } - }' + json_encode([ + 'data' => [ + 'id' => 2, + 'format' => 'android', + 'settings' => [ + 'convertPlaceholders' => false, + ], + 'createdAt' => '2019-09-19T15:10:43+00:00', + 'updatedAt' => '2019-09-19T15:10:46+00:00', + ], + ]) ); $stringsExporterSetting = $this->crowdin->stringsExporterSetting->get(2, 2); $this->assertInstanceOf(StringsExporterSetting::class, $stringsExporterSetting); - $this->assertEquals(2, $stringsExporterSetting->getId()); $this->assertEquals('android', $stringsExporterSetting->getFormat()); } @@ -75,27 +72,27 @@ public function testGet() public function testCreate() { $params = [ - 'format' => 'android', - "settings" => [ - "convertPlaceholders" => false - ] + 'format' => 'android', + "settings" => [ + "convertPlaceholders" => false, + ], ]; $this->mockRequest([ - 'path' => '/projects/2/strings-exporter-settings', - 'method' => 'post', - 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 2, - "format": "android", - "settings": { - "convertPlaceholders": false - }, - "createdAt": "2019-09-19T15:10:43+00:00", - "updatedAt": "2019-09-19T15:10:46+00:00" - } - }' + 'path' => '/projects/2/strings-exporter-settings', + 'method' => 'post', + 'body' => json_encode($params), + 'response' => json_encode([ + 'data' => [ + 'id' => 2, + 'format' => 'android', + 'settings' => [ + 'convertPlaceholders' => false, + ], + 'createdAt' => '2019-09-19T15:10:43+00:00', + 'updatedAt' => '2019-09-19T15:10:46+00:00', + ], + ]), ]); $stringsExporterSetting = $this->crowdin->stringsExporterSetting->create(2, $params); @@ -108,8 +105,8 @@ public function testCreate() public function testDelete() { $this->mockRequest([ - 'path' => '/projects/2/strings-exporter-settings/2', - 'method' => 'delete', + 'path' => '/projects/2/strings-exporter-settings/2', + 'method' => 'delete', ]); $this->crowdin->stringsExporterSetting->delete(2, 2); @@ -117,17 +114,20 @@ public function testDelete() public function testGetAndUpdate() { - $this->mockRequestGet('/projects/2/strings-exporter-settings/2', '{ - "data": { - "id": 2, - "format": "android", - "settings": { - "convertPlaceholders": false - }, - "createdAt": "2019-09-19T15:10:43+00:00", - "updatedAt": "2019-09-19T15:10:46+00:00" - } - }'); + $this->mockRequestGet( + '/projects/2/strings-exporter-settings/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'format' => 'android', + 'settings' => [ + 'convertPlaceholders' => false, + ], + 'createdAt' => '2019-09-19T15:10:43+00:00', + 'updatedAt' => '2019-09-19T15:10:46+00:00', + ], + ]) + ); $stringsExporterSetting = $this->crowdin->stringsExporterSetting->get(2, 2); @@ -137,19 +137,23 @@ public function testGetAndUpdate() $stringsExporterSetting->setFormat('macosx'); - $this->mockRequestPatch('/projects/2/strings-exporter-settings/2', '{ - "data": { - "id": 2, - "format": "macosx", - "settings": { - "convertPlaceholders": false - }, - "createdAt": "2019-09-19T15:10:43+00:00", - "updatedAt": "2019-09-19T15:10:46+00:00" - } - }'); + $this->mockRequestPatch( + '/projects/2/strings-exporter-settings/2', + json_encode([ + 'data' => [ + 'id' => 2, + 'format' => 'macosx', + 'settings' => [ + 'convertPlaceholders' => false, + ], + 'createdAt' => '2019-09-19T15:10:43+00:00', + 'updatedAt' => '2019-09-19T15:10:46+00:00', + ], + ]) + ); $stringsExporterSetting = $this->crowdin->stringsExporterSetting->update(2, $stringsExporterSetting); + $this->assertInstanceOf(StringsExporterSetting::class, $stringsExporterSetting); $this->assertEquals(2, $stringsExporterSetting->getId()); $this->assertEquals('macosx', $stringsExporterSetting->getFormat()); diff --git a/tests/CrowdinApiClient/Api/TaskCommentApiTest.php b/tests/CrowdinApiClient/Api/TaskCommentApiTest.php index 7ec92e0c..6b612673 100644 --- a/tests/CrowdinApiClient/Api/TaskCommentApiTest.php +++ b/tests/CrowdinApiClient/Api/TaskCommentApiTest.php @@ -12,30 +12,31 @@ public function testList() $this->mockRequest([ 'path' => '/projects/2/tasks/203/comments', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 1233, - "userId": 5, - "taskId": 203, - "text": "translate task", - "timeSpent": 3600, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 1233, + 'userId' => 5, + 'taskId' => 203, + 'text' => 'translate task', + 'timeSpent' => 3600, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ], + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, + ], + ], + ]), ]); $taskComments = $this->crowdin->taskComment->list(2, 203); + $this->assertInstanceOf(ModelCollection::class, $taskComments); $this->assertCount(1, $taskComments); $this->assertInstanceOf(TaskComment::class, $taskComments[0]); @@ -47,20 +48,21 @@ public function testGet() $this->mockRequest([ 'path' => '/projects/2/tasks/203/comments/1233', 'method' => 'get', - 'response' => '{ - "data": { - "id": 1233, - "userId": 5, - "taskId": 203, - "text": "translate task", - "timeSpent": 3600, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 1233, + 'userId' => 5, + 'taskId' => 203, + 'text' => 'translate task', + 'timeSpent' => 3600, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]), ]); $taskComment = $this->crowdin->taskComment->get(2, 203, 1233); + $this->assertInstanceOf(TaskComment::class, $taskComment); $this->assertEquals(1233, $taskComment->getId()); } @@ -76,20 +78,21 @@ public function testCreate() 'path' => '/projects/2/tasks/203/comments', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 1233, - "userId": 5, - "taskId": 203, - "text": "Work in task", - "timeSpent": 3600, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 1233, + 'userId' => 5, + 'taskId' => 203, + 'text' => 'Work in task', + 'timeSpent' => 3600, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]), ]); $taskComment = $this->crowdin->taskComment->create(2, 203, $params); + $this->assertInstanceOf(TaskComment::class, $taskComment); $this->assertEquals(1233, $taskComment->getId()); } @@ -99,39 +102,44 @@ public function testUpdate() $this->mockRequest([ 'path' => '/projects/2/tasks/203/comments/1233', 'method' => 'get', - 'response' => '{ - "data": { - "id": 1233, - "userId": 5, - "taskId": 203, - "text": "translate task", - "timeSpent": 3600, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }' + 'response' => json_encode([ + 'data' => [ + 'id' => 1233, + 'userId' => 5, + 'taskId' => 203, + 'text' => 'translate task', + 'timeSpent' => 3600, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]), ]); $taskComment = $this->crowdin->taskComment->get(2, 203, 1233); + $this->assertInstanceOf(TaskComment::class, $taskComment); $this->assertEquals(1233, $taskComment->getId()); $this->assertEquals('translate task', $taskComment->getText()); $taskComment->setText('updated comment'); - $this->mockRequestPatch('/projects/2/tasks/203/comments/1233', '{ - "data": { - "id": 1233, - "userId": 5, - "taskId": 203, - "text": "updated comment", - "timeSpent": 3600, - "createdAt": "2019-09-23T09:04:29+00:00", - "updatedAt": "2019-09-23T09:04:29+00:00" - } - }'); + $this->mockRequestPatch( + '/projects/2/tasks/203/comments/1233', + json_encode([ + 'data' => [ + 'id' => 1233, + 'userId' => 5, + 'taskId' => 203, + 'text' => 'updated comment', + 'timeSpent' => 3600, + 'createdAt' => '2019-09-23T09:04:29+00:00', + 'updatedAt' => '2019-09-23T09:04:29+00:00', + ], + ]) + ); $taskComment = $this->crowdin->taskComment->update(2, 203, $taskComment); + $this->assertInstanceOf(TaskComment::class, $taskComment); $this->assertEquals('updated comment', $taskComment->getText()); } diff --git a/tests/CrowdinApiClient/Api/TranslationApiTest.php b/tests/CrowdinApiClient/Api/TranslationApiTest.php index ec07ed09..35fb0bba 100644 --- a/tests/CrowdinApiClient/Api/TranslationApiTest.php +++ b/tests/CrowdinApiClient/Api/TranslationApiTest.php @@ -345,10 +345,9 @@ public function testBuildProject(): void $params = [ 'branchId' => 2, - 'targetLanguageIds' => - [ - 0 => 'uk', - ], + 'targetLanguageIds' => [ + 'uk', + ], 'skipUntranslatedStrings' => false, 'skipUntranslatedFiles' => false, 'exportApprovedOnly' => false, diff --git a/tests/CrowdinApiClient/Api/TranslationMemoryApiTest.php b/tests/CrowdinApiClient/Api/TranslationMemoryApiTest.php index d655fe38..2bf59ad0 100644 --- a/tests/CrowdinApiClient/Api/TranslationMemoryApiTest.php +++ b/tests/CrowdinApiClient/Api/TranslationMemoryApiTest.php @@ -131,12 +131,15 @@ public function testDelete() public function testDownload() { - $this->mockRequestGet('/tms/4/exports/1/download', json_encode([ - 'data' => [ - 'url' => 'https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', - 'expireIn' => '2019-09-20T10:31:21+00:00', - ], - ])); + $this->mockRequestGet( + '/tms/4/exports/1/download', + json_encode([ + 'data' => [ + 'url' => 'https://production-enterprise-importer.downloads.crowdin.com/992000002/2/14.xliff?response-content-disposition=attachment%3B%20filename%3D%22APP.xliff%22&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190920%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190920T093121Z&X-Amz-SignedHeaders=host&X-Amz-Expires=3600&X-Amz-Signature=439ebd69a1b7e4c23e6d17891a491c94f832e0c82e4692dedb35a6cd1e624b62', + 'expireIn' => '2019-09-20T10:31:21+00:00', + ], + ]) + ); $downloadFile = $this->crowdin->translationMemory->download(4, 1); diff --git a/tests/CrowdinApiClient/Api/WebhookApiTest.php b/tests/CrowdinApiClient/Api/WebhookApiTest.php index c95c1edb..d9481a81 100644 --- a/tests/CrowdinApiClient/Api/WebhookApiTest.php +++ b/tests/CrowdinApiClient/Api/WebhookApiTest.php @@ -12,42 +12,43 @@ public function testList() $this->mockRequest([ 'path' => '/projects/2/webhooks', 'method' => 'get', - 'response' => '{ - "data": [ - { - "data": { - "id": 4, - "projectId": 2, - "name": "Proofread", - "url": "https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9", - "events": [ - "file.approved" + 'response' => json_encode([ + 'data' => [ + [ + 'data' => [ + 'id' => 4, + 'projectId' => 2, + 'name' => 'Proofread', + 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', + 'events' => [ + 'file.approved', + ], + 'headers' => [ + 'string', + ], + 'payload' => [ + 'string', + ], + 'isActive' => true, + 'batchingEnabled' => true, + 'requestType' => 'GET', + 'contentType' => 'multipart/form-data', + 'createdAt' => '2019-09-23T09:19:07+00:00', + 'updatedAt' => '2019-09-23T09:19:07+00:00', + ], ], - "headers": [ - "string" - ], - "payload": [ - "string" + ], + 'pagination' => [ + [ + 'offset' => 0, + 'limit' => 0, ], - "isActive": true, - "batchingEnabled": true, - "requestType": "GET", - "contentType": "multipart/form-data", - "createdAt": "2019-09-23T09:19:07+00:00", - "updatedAt": "2019-09-23T09:19:07+00:00" - } - } - ], - "pagination": [ - { - "offset": 0, - "limit": 0 - } - ] - }' + ], + ]), ]); $webhooks = $this->crowdin->webhook->list(2); + $this->assertInstanceOf(ModelCollection::class, $webhooks); $this->assertCount(1, $webhooks); $this->assertInstanceOf(Webhook::class, $webhooks[0]); @@ -60,52 +61,48 @@ public function testCreate() $params = [ 'name' => 'Proofread', 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', - 'events' => - [ - 0 => 'file.approved', - ], + 'events' => [ + 'file.approved', + ], 'requestType' => 'POST', 'isActive' => true, 'batchingEnabled' => false, 'contentType' => 'multipart/form-data', - 'headers' => - [ - ], - 'payload' => - [ - ], + 'headers' => [], + 'payload' => [], ]; $this->mockRequest([ 'path' => '/projects/2/webhooks', 'method' => 'post', 'body' => json_encode($params), - 'response' => '{ - "data": { - "id": 4, - "projectId": 2, - "name": "Proofread", - "url": "https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9", - "events": [ - "file.approved" - ], - "headers": [ - "string" - ], - "payload": [ - "string" + 'response' => json_encode([ + 'data' => [ + 'id' => 4, + 'projectId' => 2, + 'name' => 'Proofread', + 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', + 'events' => [ + 'file.approved', + ], + 'headers' => [ + 'string', + ], + 'payload' => [ + 'string', + ], + 'isActive' => true, + 'batchingEnabled' => false, + 'requestType' => 'GET', + 'contentType' => 'multipart/form-data', + 'createdAt' => '2019-09-23T09:19:07+00:00', + 'updatedAt' => '2019-09-23T09:19:07+00:00', ], - "isActive": true, - "batchingEnabled": false, - "requestType": "GET", - "contentType": "multipart/form-data", - "createdAt": "2019-09-23T09:19:07+00:00", - "updatedAt": "2019-09-23T09:19:07+00:00" - } - }' + ]), ]); $webhook = $this->crowdin->webhook->create(2, $params); + $this->assertInstanceOf(Webhook::class, $webhook); $this->assertEquals(4, $webhook->getId()); $this->assertEquals(false, $webhook->isBatchingEnabled()); @@ -113,61 +110,70 @@ public function testCreate() public function testGetAndUpdate() { - $this->mockRequestGet('/projects/2/webhooks/4', '{ - "data": { - "id": 4, - "projectId": 2, - "name": "Proofread", - "url": "https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9", - "events": [ - "file.approved" - ], - "headers": [ - "string" - ], - "payload": [ - "string" + $this->mockRequestGet( + '/projects/2/webhooks/4', + json_encode([ + 'data' => [ + 'id' => 4, + 'projectId' => 2, + 'name' => 'Proofread', + 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', + 'events' => [ + 'file.approved', + ], + 'headers' => [ + 'string', + ], + 'payload' => [ + 'string', + ], + 'isActive' => true, + 'batchingEnabled' => true, + 'requestType' => 'GET', + 'contentType' => 'multipart/form-data', + 'createdAt' => '2019-09-23T09:19:07+00:00', + 'updatedAt' => '2019-09-23T09:19:07+00:00', ], - "isActive": true, - "batchingEnabled": true, - "requestType": "GET", - "contentType": "multipart/form-data", - "createdAt": "2019-09-23T09:19:07+00:00", - "updatedAt": "2019-09-23T09:19:07+00:00" - } - }'); + ]) + ); $webhook = $this->crowdin->webhook->get(2, 4); + $this->assertInstanceOf(Webhook::class, $webhook); $this->assertEquals(4, $webhook->getId()); $webhook->setName('test edit'); $webhook->setBatchingEnabled(false); - $this->mockRequestPatch('/projects/2/webhooks/4', '{ - "data": { - "id": 4, - "projectId": 2, - "name": "test edit", - "url": "https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9", - "events": [ - "file.approved" - ], - "headers": [ - "string" - ], - "payload": [ - "string" + + $this->mockRequestPatch( + '/projects/2/webhooks/4', + json_encode([ + 'data' => [ + 'id' => 4, + 'projectId' => 2, + 'name' => 'test edit', + 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', + 'events' => [ + 'file.approved', + ], + 'headers' => [ + 'string', + ], + 'payload' => [ + 'string', + ], + 'isActive' => true, + 'batchingEnabled' => false, + 'requestType' => 'GET', + 'contentType' => 'multipart/form-data', + 'createdAt' => '2019-09-23T09:19:07+00:00', + 'updatedAt' => '2019-09-23T09:19:07+00:00', ], - "isActive": true, - "batchingEnabled": false, - "requestType": "GET", - "contentType": "multipart/form-data", - "createdAt": "2019-09-23T09:19:07+00:00", - "updatedAt": "2019-09-23T09:19:07+00:00" - } - }'); + ]) + ); $webhook = $this->crowdin->webhook->update($webhook); + $this->assertInstanceOf(Webhook::class, $webhook); $this->assertEquals(4, $webhook->getId()); $this->assertEquals('test edit', $webhook->getName()); diff --git a/tests/CrowdinApiClient/Model/LanguageTest.php b/tests/CrowdinApiClient/Model/LanguageTest.php index 4589ef2d..722e7f6b 100644 --- a/tests/CrowdinApiClient/Model/LanguageTest.php +++ b/tests/CrowdinApiClient/Model/LanguageTest.php @@ -25,15 +25,13 @@ class LanguageTest extends TestCase 'androidCode' => 'es-rES', 'osxCode' => 'es.lproj', 'osxLocale' => 'es', - 'pluralCategoryNames' => - [ - 0 => 'one', - ], + 'pluralCategoryNames' => [ + 'one', + ], 'pluralRules' => '(n != 1)', - 'pluralExamples' => - [ - 0 => '0, 2-999; 1.2, 2.07...', - ], + 'pluralExamples' => [ + '0, 2-999; 1.2, 2.07...', + ], 'textDirection' => 'ltr', 'dialectOf' => 'string', ]; diff --git a/tests/CrowdinApiClient/Model/ScreenshotTest.php b/tests/CrowdinApiClient/Model/ScreenshotTest.php index 51b66c13..25b32d8b 100644 --- a/tests/CrowdinApiClient/Model/ScreenshotTest.php +++ b/tests/CrowdinApiClient/Model/ScreenshotTest.php @@ -21,29 +21,25 @@ class ScreenshotTest extends TestCase 'url' => 'https://production-enterprise-screenshots.downloads.crowdin.com/992000002/6/2/middle.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIGJKLQV66ZXPMMEA%2F20190923%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190923T093016Z&X-Amz-SignedHeaders=host&X-Amz-Expires=120&X-Amz-Signature=8df06f57594f7d1804b7c037629f6916224415e9b935c4f6619fbe002fb25e73', 'webUrl' => 'https://crowdin.com/project/example/screenshots/2', 'name' => 'translate_with_siri.jpg', - 'size' => - [ - 'width' => 267, - 'height' => 176, - ], + 'size' => [ + 'width' => 267, + 'height' => 176, + ], 'tagsCount' => 0, - 'tags' => + 'tags' => [ [ - 0 => - [ - 'id' => 98, - 'screenshotId' => 2, - 'stringId' => 2822, - 'position' => - [ - 'x' => 474, - 'y' => 147, - 'width' => 490, - 'height' => 99, - ], - 'createdAt' => '2019-09-23T09:35:31+00:00', - ], + 'id' => 98, + 'screenshotId' => 2, + 'stringId' => 2822, + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], + 'createdAt' => '2019-09-23T09:35:31+00:00', ], + ], 'createdAt' => '2019-09-23T09:29:19+00:00', 'updatedAt' => '2019-09-23T09:29:19+00:00', 'labelIds' => [ diff --git a/tests/CrowdinApiClient/Model/TagTest.php b/tests/CrowdinApiClient/Model/TagTest.php index 1b5487f8..fabe2853 100644 --- a/tests/CrowdinApiClient/Model/TagTest.php +++ b/tests/CrowdinApiClient/Model/TagTest.php @@ -16,13 +16,12 @@ class TagTest extends TestCase 'id' => 98, 'screenshotId' => 2, 'stringId' => 2822, - 'position' => - [ - 'x' => 474, - 'y' => 147, - 'width' => 490, - 'height' => 99, - ], + 'position' => [ + 'x' => 474, + 'y' => 147, + 'width' => 490, + 'height' => 99, + ], 'createdAt' => '2019-09-23T09:35:31+00:00', ]; diff --git a/tests/CrowdinApiClient/Model/TranslationMemoryTest.php b/tests/CrowdinApiClient/Model/TranslationMemoryTest.php index 0dafd0cc..5f515a1c 100644 --- a/tests/CrowdinApiClient/Model/TranslationMemoryTest.php +++ b/tests/CrowdinApiClient/Model/TranslationMemoryTest.php @@ -13,17 +13,15 @@ class TranslationMemoryTest extends TestCase 'id' => 4, 'groupId' => 2, 'name' => 'Knowledge Base\'s TM', - 'languageIds' => - [ - 0 => 'el', + 'languageIds' => [ + 'el', ], 'segmentsCount' => 21, 'defaultProjectIds' => [0], - 'projectIds' => - [ - 0 => 2, + 'projectIds' => [ + 2, ], - 'createdAt' => '2019-09-23T09:04:29+00:00' + 'createdAt' => '2019-09-23T09:04:29+00:00', ]; public function testLoadData() diff --git a/tests/CrowdinApiClient/Model/WebhookTest.php b/tests/CrowdinApiClient/Model/WebhookTest.php index df3c798b..94ed70d6 100644 --- a/tests/CrowdinApiClient/Model/WebhookTest.php +++ b/tests/CrowdinApiClient/Model/WebhookTest.php @@ -14,18 +14,15 @@ class WebhookTest extends TestCase 'projectId' => 2, 'name' => 'Proofread', 'url' => 'https://webhook.site/1c20d9b5-6e6a-4522-974d-9da7ea7595c9', - 'events' => - [ - 0 => 'file.approved', - ], - 'headers' => - [ - 0 => 'string', - ], - 'payload' => - [ - 0 => 'string', - ], + 'events' => [ + 'file.approved', + ], + 'headers' => [ + 'string', + ], + 'payload' => [ + 'string', + ], 'isActive' => true, 'requestType' => 'GET', 'contentType' => 'multipart/form-data',