You are here

public function ContextApiTest::testUploadResource in TMGMT Translator Smartling 8.2

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

@covers \Smartling\Context\ContextApi::uploadResource

File

api-sdk-php/tests/unit/ContextApiTest.php, line 230

Class

ContextApiTest
Test class for Smartling\Context\ContextApi.

Namespace

Smartling\Tests

Code

public function testUploadResource() {
  $resourceId = 'some_resource_id';
  $params = new UploadResourceParameters();
  $params
    ->setFile('./tests/resources/test.png');
  $endpointUrl = vsprintf('%s/%s/resources/%s', [
    ContextApi::ENDPOINT_URL,
    $this->projectId,
    $resourceId,
  ]);
  $this->client
    ->expects(self::once())
    ->method('request')
    ->with('put', $endpointUrl, [
    'headers' => [
      'Accept' => 'application/json',
      'Authorization' => vsprintf('%s %s', [
        $this->authProvider
          ->getTokenType(),
        $this->authProvider
          ->getAccessToken(),
      ]),
      'X-SL-Context-Source' => $this
        ->invokeMethod($this->object, 'getXSLContextSourceHeader'),
    ],
    'exceptions' => FALSE,
    'multipart' => [
      [
        'name' => 'resource',
        'contents' => $this->streamPlaceholder,
      ],
    ],
  ])
    ->willReturn($this->responseMock);
  $this->object
    ->uploadResource($resourceId, $params);
}