You are here

public function FileApiTest::testUploadFile in TMGMT Translator Smartling 8.2

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

@covers \Smartling\File\FileApi::uploadFile

File

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

Class

FileApiTest
Test class for Smartling\File\FileApi.

Namespace

Smartling\Tests\Unit

Code

public function testUploadFile() {
  $this->client
    ->expects($this
    ->once())
    ->method('request')
    ->with('post', FileApi::ENDPOINT_URL . '/' . $this->projectId . '/file', [
    'headers' => [
      'Accept' => 'application/json',
      'Authorization' => vsprintf('%s %s', [
        $this->authProvider
          ->getTokenType(),
        $this->authProvider
          ->getAccessToken(),
      ]),
    ],
    'exceptions' => false,
    'multipart' => [
      [
        'name' => 'authorize',
        'contents' => 0,
      ],
      [
        'name' => 'smartling.client_lib_id',
        'contents' => '{"client":"smartling-api-sdk-php","version":"3.0.0"}',
      ],
      [
        'name' => 'localeIdsToAuthorize[]',
        'contents' => 'es',
      ],
      [
        'name' => 'file',
        'contents' => $this->streamPlaceholder,
      ],
      [
        'name' => 'fileUri',
        'contents' => 'test.xml',
      ],
      [
        'name' => 'fileType',
        'contents' => 'xml',
      ],
    ],
  ])
    ->willReturn($this->responseMock);
  $params = new UploadFileParameters();
  $params
    ->setAuthorized(true);
  $params
    ->setLocalesToApprove('es');
  $this->object
    ->uploadFile('tests/resources/test.xml', 'test.xml', 'xml', $params);
}