You are here

public function LingotekUnitTest::testCancelDocumentTarget in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 4.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  2. 3.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  3. 3.1.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  4. 3.2.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  5. 3.3.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  6. 3.4.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  7. 3.5.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  8. 3.6.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  9. 3.7.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()
  10. 3.8.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocumentTarget()

@covers ::cancelDocumentTarget

File

tests/src/Unit/LingotekUnitTest.php, line 1024

Class

LingotekUnitTest
@coversDefaultClass \Drupal\lingotek\Lingotek @group lingotek @preserveGlobalState disabled

Namespace

Drupal\Tests\lingotek\Unit

Code

public function testCancelDocumentTarget() {
  $response = $this
    ->getMockBuilder(ResponseInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $response
    ->expects($this
    ->at(0))
    ->method('getStatusCode')
    ->willReturn(Response::HTTP_NO_CONTENT);

  // Test returning an error.
  $response
    ->expects($this
    ->at(1))
    ->method('getStatusCode')
    ->willReturn(Response::HTTP_INTERNAL_SERVER_ERROR);
  $response
    ->expects($this
    ->at(2))
    ->method('getStatusCode')
    ->willReturn(Response::HTTP_NOT_FOUND);
  $this->api
    ->expects($this
    ->any())
    ->method('cancelDocumentTarget')
    ->with('my_doc_id', 'es_ES')
    ->will($this
    ->returnValue($response));
  $this
    ->assertTrue($this->lingotek
    ->cancelDocumentTarget('my_doc_id', 'es_ES'));
  $this
    ->assertFalse($this->lingotek
    ->cancelDocumentTarget('my_doc_id', 'es_ES'));
  $this
    ->assertFalse($this->lingotek
    ->cancelDocumentTarget('my_doc_id', 'es_ES'));
}