diff --git a/.gitignore b/.gitignore index 1c203fb6..dfc291c3 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ clients/php/test/Model clients/php/test/Api/* !clients/php/test/Api/LocalesApiTest.php !clients/php/test/Api/UploadsApiTest.php +!clients/php/test/Api/KeysApiTest.php clients/cli/cmd/api_*.go clients/cli/phrase-cli diff --git a/clients/php/test/Api/KeysApiTest.php b/clients/php/test/Api/KeysApiTest.php new file mode 100644 index 00000000..174717c9 --- /dev/null +++ b/clients/php/test/Api/KeysApiTest.php @@ -0,0 +1,218 @@ +mock = new MockHandler(); + $history = Middleware::history($this->history); + $handlerStack = HandlerStack::create($this->mock); + $handlerStack->push($history); + $client = new Client(['handler' => $handlerStack]); + + $config = Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY'); + $config = Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); + + $this->apiInstance = new Api($client, $config); + } + + /** + * Clean up after running each test case + */ + public function tearDown() + { + } + + /** + * Clean up after running all test cases + */ + public static function tearDownAfterClass() + { + } + + /** + * Test case for keyCreate + * + * Create a key. + * + */ + public function testKeyCreate() + { + } + + /** + * Test case for keyDelete + * + * Delete a key. + * + */ + public function testKeyDelete() + { + } + + /** + * Test case for keyShow + * + * Get a single key. + * + */ + public function testKeyShow() + { + $this->mock->append(new Response(200, [], '{"id":"KEY_ID","name":"five","description":null,"name_hash":"NAME_HASH","plural":false,"tags":["upload-20231101_143051","fas"],"default_translation_content":"","created_at":"2023-11-01T14:31:01Z","updated_at":"2024-03-20T21:10:44Z","name_plural":null,"comments_count":0,"data_type":"string","max_characters_allowed":0,"screenshot_url":null,"unformatted":false,"xml_space_preserve":false,"original_file":null,"format_value_type":null,"localized_format_key":null,"localized_format_string":null,"custom_metadata":{"Name":"my name"},"creator":{"id":"CREATOR_ID","username":"username","name":"NAME","gravatar_uid":"UID"}}')); + + $projectId = "project_id_example"; + $id = "key_id"; + $result = $this->apiInstance->keyShow($projectId, $id); + + $this->assertNotNull($result); + $this->assertInstanceOf('\Phrase\Model\TranslationKeyDetails', $result); + $this->assertEquals('KEY_ID', $result->getId()); + $this->assertEquals('five', $result->getName()); + $this->assertEquals('my name', $result->getCustomMetadata()['Name']); + + $lastRequest = $this->history[count($this->history)-1]['request']; + $this->assertEquals('GET', $lastRequest->getMethod()); + $this->assertEquals('/v2/projects/'.$projectId.'/keys/'.$id, $lastRequest->getUri()->getPath()); + } + + /** + * Test case for keyUpdate + * + * Update a key. + * + */ + public function testKeyUpdate() + { + } + + /** + * Test case for keysDeleteCollection + * + * Delete collection of keys. + * + */ + public function testKeysDeleteCollection() + { + } + + /** + * Test case for keysExclude + * + * Exclude a locale on a collection of keys. + * + */ + public function testKeysExclude() + { + } + + /** + * Test case for keysInclude + * + * Include a locale on a collection of keys. + * + */ + public function testKeysInclude() + { + } + + /** + * Test case for keysList + * + * List keys. + * + */ + public function testKeysList() + { + } + + /** + * Test case for keysSearch + * + * Search keys. + * + */ + public function testKeysSearch() + { + } + + /** + * Test case for keysTag + * + * Add tags to collection of keys. + * + */ + public function testKeysTag() + { + } + + /** + * Test case for keysUntag + * + * Remove tags from collection of keys. + * + */ + public function testKeysUntag() + { + } +} diff --git a/openapi-generator/templates/php/ObjectSerializer.mustache b/openapi-generator/templates/php/ObjectSerializer.mustache index aa4f3302..8b8e1bd4 100644 --- a/openapi-generator/templates/php/ObjectSerializer.mustache +++ b/openapi-generator/templates/php/ObjectSerializer.mustache @@ -271,7 +271,7 @@ class ObjectSerializer $values[] = self::deserialize($value, $subClass, null); } return $values; - } elseif ($class === 'object') { + } elseif ($class === 'object' || $class === 'array') { settype($data, 'array'); return $data; } elseif ($class === '\DateTime') {