You are here

public function FileApiTest::testImport in TMGMT Translator Smartling 8.3

Same name and namespace in other branches
  1. 8.4 vendor/smartling/api-sdk-php/tests/unit/FileApiTest.php \Smartling\Tests\Unit\FileApiTest::testImport()
  2. 8.2 api-sdk-php/tests/unit/FileApiTest.php \Smartling\Tests\Unit\FileApiTest::testImport()
  3. 8.2 vendor/smartling/api-sdk-php/tests/unit/FileApiTest.php \Smartling\Tests\Unit\FileApiTest::testImport()

@covers \Smartling\File\FileApi::import

File

vendor/smartling/api-sdk-php/tests/unit/FileApiTest.php, line 917

Class

FileApiTest
Test class for Smartling\File\FileApi.

Namespace

Smartling\Tests\Unit

Code

public function testImport() {
  $this
    ->prepareClientResponseMock();
  $locale = 'en-EN';
  $endpointUrl = vsprintf('%s/%s/locales/%s/file/import', [
    FileApi::ENDPOINT_URL,
    $this->projectId,
    $locale,
  ]);
  $this->client
    ->expects($this
    ->once())
    ->method('request')
    ->with('post', $endpointUrl, [
    'headers' => [
      'Accept' => 'application/json',
      'Authorization' => vsprintf('%s %s', [
        $this->authProvider
          ->getTokenType(),
        $this->authProvider
          ->getAccessToken(),
      ]),
    ],
    'exceptions' => false,
    'multipart' => [
      [
        'name' => 'fileUri',
        'contents' => 'test.xml',
      ],
      [
        'name' => 'fileType',
        'contents' => 'xml',
      ],
      [
        'name' => 'file',
        'contents' => $this->streamPlaceholder,
      ],
      [
        'name' => 'translationState',
        'contents' => 'PUBLISHED',
      ],
      [
        'name' => 'overwrite',
        'contents' => '0',
      ],
    ],
  ])
    ->willReturn($this->responseMock);
  $this->object
    ->import($locale, 'test.xml', 'xml', 'tests/resources/test.xml', 'PUBLISHED', false);
}