You are here

public function BatchApiTest::testCreateBatch in TMGMT Translator Smartling 8.4

Same name and namespace in other branches
  1. 8.3 vendor/smartling/api-sdk-php/tests/unit/BatchApiTest.php \Smartling\Tests\Unit\BatchApiTest::testCreateBatch()

@covers \Smartling\Batch\BatchApi::createBatch

File

vendor/smartling/api-sdk-php/tests/unit/BatchApiTest.php, line 52

Class

BatchApiTest
Test class for Smartling\Batch\BatchApi.

Namespace

Smartling\Tests\Unit

Code

public function testCreateBatch() {
  $jobId = 'test_job_id';
  $authorize = false;
  $callbackUrl = 'test_callback_url';
  $params = new CreateBatchParameters();
  $params
    ->setTranslationJobUid($jobId);
  $params
    ->setAuthorize($authorize);
  $params
    ->setCallbackUrl($callbackUrl);
  $endpointUrl = vsprintf('%s/%s/batches', [
    BatchApi::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(),
      ]),
    ],
    'exceptions' => FALSE,
    'json' => [
      'translationJobUid' => $jobId,
      'authorize' => $authorize,
      'callbackUrl' => $callbackUrl,
    ],
  ])
    ->willReturn($this->responseMock);
  $this->object
    ->createBatch($params);
}