You are here

public function LingotekUnitTest::testCancelDocument 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::testCancelDocument()
  2. 3.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()
  3. 3.1.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()
  4. 3.2.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()
  5. 3.3.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()
  6. 3.4.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()
  7. 3.5.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()
  8. 3.6.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()
  9. 3.7.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()
  10. 3.8.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testCancelDocument()

@covers ::cancelDocument

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Unit

Code

public function testCancelDocument() {
  $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('cancelDocument')
    ->with('my_doc_id')
    ->will($this
    ->returnValue($response));
  $this
    ->assertTrue($this->lingotek
    ->cancelDocument('my_doc_id'));
  $this
    ->assertFalse($this->lingotek
    ->cancelDocument('my_doc_id'));
  $this
    ->assertFalse($this->lingotek
    ->cancelDocument('my_doc_id'));
}