You are here

public function LingotekUnitTest::testDownloadDocumentGone in Lingotek Translation 4.0.x

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

@covers ::downloadDocument

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Unit

Code

public function testDownloadDocumentGone() {
  $response = $this
    ->getMockBuilder(ResponseInterface::class)
    ->disableOriginalConstructor()
    ->getMock();
  $response
    ->expects($this
    ->any())
    ->method('getStatusCode')
    ->willReturn(Response::HTTP_GONE);
  $response
    ->expects($this
    ->any())
    ->method('getBody')
    ->willReturn(json_encode([
    'messages' => [
      "Document my_doc_id has been archived.",
    ],
  ]));
  $language = $this
    ->createMock(ConfigurableLanguageInterface::class);
  $language
    ->expects($this
    ->any())
    ->method('getId')
    ->will($this
    ->returnValue('es'));
  $this->accountConfig
    ->expects($this
    ->any())
    ->method('get')
    ->will($this
    ->returnValueMap([
    [
      'default.workflow',
      'default_workflow',
    ],
  ]));
  $this->languageLocaleMapper
    ->expects($this
    ->any())
    ->method('getConfigurableLanguageForLocale')
    ->with('es_ES')
    ->will($this
    ->returnValue($language));

  // Workflow id has the original value.
  $this->api
    ->expects($this
    ->at(0))
    ->method('getTranslation')
    ->with('my_doc_id', 'es_ES')
    ->will($this
    ->returnValue($response));
  $this
    ->assertFalse($this->lingotek
    ->downloadDocument('my_doc_id', 'es_ES'));
}