public function TranslationRequestsApiTest::testCreateTranslationRequest in TMGMT Translator Smartling 8.3
Same name and namespace in other branches
- 8.4 vendor/smartling/api-sdk-php/tests/unit/TranslationRequestsApiTest.php \Smartling\Tests\Unit\TranslationRequestsApiTest::testCreateTranslationRequest()
@covers \Smartling\TranslationRequests\TranslationRequestsApi::createTranslationRequest
File
- vendor/
smartling/ api-sdk-php/ tests/ unit/ TranslationRequestsApiTest.php, line 65
Class
Namespace
Smartling\Tests\UnitCode
public function testCreateTranslationRequest() {
$createParams = (new CreateTranslationRequestParams())
->setOriginalAssetKey([
'a' => '1',
])
->setTitle('Submission 1')
->setFileUri('/posts/hello-world_1_1_post.xml')
->setOriginalLocaleId('en-US');
$testRawResponse = json_encode([
"response" => [
"code" => "SUCCESS",
"data" => [
"translationRequestUid" => "8264fd9133d3",
"projectId" => $this->projectId,
"bucketName" => "name",
"originalAssetId" => [
"a" => "1",
],
"title" => "Submission 1",
"fileUri" => "/posts/hello-world_1_1_post.xml",
"totalWordCount" => "0",
"totalStringCount" => "0",
"contentHash" => null,
"originalLocaleId" => "en-US",
"outdated" => "0",
"customOriginalData" => null,
"createdDate" => "2018-07-31T10:37:20.839Z",
"modifiedDate" => "2018-07-31T10:37:20.839Z",
"translationSubmissions" => [],
],
],
]);
$this
->mockClientResponse(200, $testRawResponse);
$testExpectedResponse = json_decode($testRawResponse, true)['response']['data'];
$bucketName = 'name';
$endpointUrl = vsprintf('%s/%s/buckets/%s/translation-requests', [
TranslationRequestsApi::ENDPOINT_URL,
$this->projectId,
$bucketName,
]);
$requestStructure = [
'headers' => [
'Accept' => 'application/json',
'Authorization' => vsprintf('%s %s', [
$this->authProvider
->getTokenType(),
$this->authProvider
->getAccessToken(),
]),
],
'exceptions' => false,
'json' => $createParams
->exportToArray(),
];
$this->client
->expects(self::once())
->method('request')
->with('post', $endpointUrl, $requestStructure)
->willReturn($this->responseMock);
$response = $this->object
->createTranslationRequest($bucketName, $createParams);
self::assertEquals($testExpectedResponse, $response);
}