You are here

public function JobsApiTest::testCreateJob in TMGMT Translator Smartling 8.3

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

@covers \Smartling\Jobs\JobsApi::createJob

File

vendor/smartling/api-sdk-php/tests/unit/JobsApiTest.php, line 61

Class

JobsApiTest
Test class for Smartling\Jobs\JobsApi.

Namespace

Smartling\Tests\Unit

Code

public function testCreateJob() {
  $name = 'Test Job Name';
  $description = 'Test Job Description';
  $dueDate = DateTime::createFromFormat('Y-m-d H:i:s', '2020-01-01 19:19:17', new DateTimeZone('UTC'));
  $locales = [
    'es',
    'fr',
  ];
  $params = new CreateJobParameters();
  $params
    ->setName($name);
  $params
    ->setDescription($description);
  $params
    ->setDueDate($dueDate);
  $params
    ->setTargetLocales($locales);
  $endpointUrl = vsprintf('%s/%s/jobs', [
    JobsApi::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' => [
      'jobName' => $name,
      'description' => $description,
      'dueDate' => $dueDate
        ->format('Y-m-d\\TH:i:s\\Z'),
      'targetLocaleIds' => $locales,
    ],
  ])
    ->willReturn($this->responseMock);
  $this->object
    ->createJob($params);
}