-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(PHP): Fix deserializing custom metadata values in key response (#607
- Loading branch information
Showing
3 changed files
with
220 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,218 @@ | ||
<?php | ||
/** | ||
* KeysApiTest | ||
* PHP version 5 | ||
* | ||
* @category Class | ||
* @package Phrase | ||
* @author OpenAPI Generator team | ||
* @link https://openapi-generator.tech | ||
*/ | ||
|
||
/** | ||
* Phrase Strings API Reference | ||
* | ||
* The version of the OpenAPI document: 2.0.0 | ||
* Contact: [email protected] | ||
* Generated by: https://openapi-generator.tech | ||
* OpenAPI Generator version: 7.0.1 | ||
*/ | ||
|
||
/** | ||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). | ||
* https://openapi-generator.tech | ||
* Please update the test case below to test the endpoint. | ||
*/ | ||
|
||
namespace Phrase; | ||
|
||
use \Phrase\Configuration as Configuration; | ||
use \Phrase\ApiException; | ||
use \Phrase\ObjectSerializer; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
use \Phrase\Api\KeysApi as Api; | ||
|
||
use GuzzleHttp\Client; | ||
use GuzzleHttp\Handler\MockHandler; | ||
use GuzzleHttp\HandlerStack; | ||
use GuzzleHttp\Middleware; | ||
use GuzzleHttp\Psr7\Response; | ||
|
||
/** | ||
* KeysApiTest Class Doc Comment | ||
* | ||
* @category Class | ||
* @package Phrase | ||
* @author OpenAPI Generator team | ||
* @link https://openapi-generator.tech | ||
*/ | ||
class KeysApiTest extends TestCase | ||
{ | ||
private $apiInstance; | ||
private $mock; | ||
private $history = []; | ||
|
||
/** | ||
* Setup before running any test cases | ||
*/ | ||
public static function setUpBeforeClass() | ||
{ | ||
} | ||
|
||
/** | ||
* Setup before running each test case | ||
*/ | ||
public function setUp() | ||
{ | ||
$this->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() | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters