Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
218 changes: 218 additions & 0 deletions clients/php/test/Api/KeysApiTest.php
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: support@phrase.com
* 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()
{
}
}
2 changes: 1 addition & 1 deletion openapi-generator/templates/php/ObjectSerializer.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ class ObjectSerializer
$values[] = self::deserialize($value, $subClass, null);
}
return $values;
} elseif ($class === 'object') {
} elseif ($class === 'object' || $class === 'array<string,string>') {
settype($data, 'array');
return $data;
} elseif ($class === '\DateTime') {
Expand Down