You are here

public function JobsApiTest::testUpdateJob 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::testUpdateJob()

@covers \Smartling\Jobs\JobsApi::updateJob

File

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

Class

JobsApiTest
Test class for Smartling\Jobs\JobsApi.

Namespace

Smartling\Tests\Unit

Code

public function testUpdateJob() {
  $jobId = 'Some job id';
  $name = 'Test Job Name Updated';
  $description = 'Test Job Description Updated';
  $dueDate = DateTime::createFromFormat('Y-m-d H:i:s', '2030-01-01 19:19:17', new DateTimeZone('UTC'));
  $params = new UpdateJobParameters();
  $params
    ->setName($name);
  $params
    ->setDescription($description);
  $params
    ->setDueDate($dueDate);
  $endpointUrl = vsprintf('%s/%s/jobs/%s', [
    JobsApi::ENDPOINT_URL,
    $this->projectId,
    $jobId,
  ]);
  $this->client
    ->expects(self::once())
    ->method('request')
    ->with('put', $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'),
    ],
  ])
    ->willReturn($this->responseMock);
  $this->object
    ->updateJob($jobId, $params);
}