You are here

public function ContextApiTest::testUploadContext in TMGMT Translator Smartling 8.2

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

@covers \Smartling\Context\ContextApi::uploadContext

File

vendor/smartling/api-sdk-php/tests/unit/ContextApiTest.php, line 56

Class

ContextApiTest
Test class for Smartling\Context\ContextApi.

Namespace

Smartling\Tests

Code

public function testUploadContext() {
  $params = new UploadContextParameters();
  $params
    ->setContextFileUri('./tests/resources/context.html');
  $params
    ->setName('test_context.html');
  $endpointUrl = vsprintf('%s/%s/contexts', [
    ContextApi::ENDPOINT_URL,
    $this->projectId,
  ]);
  $this->client
    ->expects(self::once())
    ->method('request')
    ->with('post', $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' => 'content',
        'contents' => $this->streamPlaceholder,
      ],
      [
        'name' => 'name',
        'contents' => 'test_context.html',
      ],
    ],
  ])
    ->willReturn($this->responseMock);
  $this->object
    ->uploadContext($params);
}