github.com/phrase/openapi@v0.0.0-20240514140800-49e8a106740e/clients/php/test/Api/LocalesApiTest.php (about) 1 <?php 2 /** 3 * LocalesApiTest 4 * PHP version 5 5 * 6 * @category Class 7 * @package Phrase 8 * @author OpenAPI Generator team 9 * @link https://openapi-generator.tech 10 */ 11 12 /** 13 * Phrase Strings API Reference 14 * 15 * The version of the OpenAPI document: 2.0.0 16 * Contact: support@phrase.com 17 * Generated by: https://openapi-generator.tech 18 * OpenAPI Generator version: 4.3.1 19 */ 20 21 /** 22 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). 23 * https://openapi-generator.tech 24 * Please update the test case below to test the endpoint. 25 */ 26 27 namespace Phrase; 28 29 use \Phrase\Configuration as Configuration; 30 use \Phrase\ApiException; 31 use \Phrase\ObjectSerializer; 32 33 use \Phrase\Api\LocalesApi as Api; 34 35 use PHPUnit\Framework\TestCase; 36 37 use GuzzleHttp\Client; 38 use GuzzleHttp\Handler\MockHandler; 39 use GuzzleHttp\HandlerStack; 40 use GuzzleHttp\Middleware; 41 use GuzzleHttp\Psr7\Response; 42 43 /** 44 * LocalesApiTest Class Doc Comment 45 * 46 * @category Class 47 * @package Phrase 48 * @author OpenAPI Generator team 49 * @link https://openapi-generator.tech 50 */ 51 class LocalesApiTest extends TestCase 52 { 53 private $apiInstance; 54 private $mock; 55 private $history = []; 56 57 /** 58 * Setup before running any test cases 59 */ 60 public static function setUpBeforeClass() 61 { 62 } 63 64 /** 65 * Setup before running each test case 66 */ 67 public function setUp() 68 { 69 $this->mock = new MockHandler(); 70 $history = Middleware::history($this->history); 71 $handlerStack = HandlerStack::create($this->mock); 72 $handlerStack->push($history); 73 $client = new Client(['handler' => $handlerStack]); 74 75 $config = Configuration::getDefaultConfiguration()->setApiKey('Authorization', 'YOUR_API_KEY'); 76 $config = Configuration::getDefaultConfiguration()->setApiKeyPrefix('Authorization', 'token'); 77 78 $this->apiInstance = new Api($client, $config); 79 } 80 81 /** 82 * Clean up after running each test case 83 */ 84 public function tearDown() 85 { 86 } 87 88 /** 89 * Clean up after running all test cases 90 */ 91 public static function tearDownAfterClass() 92 { 93 } 94 95 /** 96 * Test case for accountLocales 97 * 98 * List locales used in account. 99 * 100 */ 101 public function testAccountLocales() 102 { 103 } 104 105 /** 106 * Test case for localeCreate 107 * 108 * Create a locale. 109 * 110 */ 111 public function testLocaleCreate() 112 { 113 } 114 115 /** 116 * Test case for localeDelete 117 * 118 * Delete a locale. 119 * 120 */ 121 public function testLocaleDelete() 122 { 123 } 124 125 /** 126 * Test case for localeDownload 127 * 128 * Download a locale. 129 * 130 */ 131 public function testLocaleDownload() 132 { 133 $this->mock->append(new Response(200, [], 'foo')); 134 135 $projectId = "project_id_example"; 136 $id = "locale_id"; 137 $result = $this->apiInstance->localeDownload($projectId, $id); 138 139 $this->assertNotNull($result); 140 $this->assertEquals('foo', $result); 141 142 $lastRequest = $this->history[count($this->history)-1]['request']; 143 $this->assertEquals('GET', $lastRequest->getMethod()); 144 $this->assertEquals('/v2/projects/'.$projectId.'/locales/'.$id.'/download', $lastRequest->getUri()->getPath()); 145 } 146 147 /** 148 * Test case for localeShow 149 * 150 * Get a single locale. 151 * 152 */ 153 public function testLocaleShow() 154 { 155 } 156 157 /** 158 * Test case for localeUpdate 159 * 160 * Update a locale. 161 * 162 */ 163 public function testLocaleUpdate() 164 { 165 } 166 167 /** 168 * Test case for localesList 169 * 170 * List locales. 171 * 172 */ 173 public function testLocalesList() 174 { 175 $this->mock->append(new Response(200, [], '[{"id":"locale_id","name":"locale_name","code":"locale_code","default":true,"main":true,"rtl":true,"plural_forms":["plural_forms"]}]')); 176 177 $projectId = "project_id_example"; 178 179 $result = $this->apiInstance->localesList($projectId); 180 181 $lastRequest = $this->history[count($this->history)-1]['request']; 182 $this->assertNotNull($result); 183 $this->assertEquals(1, count($result)); 184 $this->assertEquals('locale_id', $result[0]['id']); 185 $this->assertEquals('locale_name', $result[0]['name']); 186 187 $this->assertEquals('GET', $lastRequest->getMethod()); 188 $this->assertEquals('/v2/projects/'.$projectId.'/locales', $lastRequest->getUri()->getPath()); 189 190 } 191 }