You are here

public function ContextApiTest::testMatchContext in TMGMT Translator Smartling 8.3

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

@covers \Smartling\Context\ContextApi::uploadContext

File

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

Class

ContextApiTest
Test class for Smartling\Context\ContextApi.

Namespace

Smartling\Tests

Code

public function testMatchContext() {
  $fileUri = './tests/resources/context.html';
  $contextUid = 'someContextUid';
  $params = new MatchContextParameters();
  $params
    ->setContentFileUri($fileUri);
  $endpointUrl = vsprintf('%s/%s/contexts/%s/match/async', [
    ContextApi::ENDPOINT_URL,
    $this->projectId,
    $contextUid,
  ]);
  $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,
    'json' => [
      'contentFileUri' => $fileUri,
    ],
  ])
    ->willReturn($this->responseMock);
  $this->object
    ->matchContext($contextUid, $params);
}