You are here

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

@covers ::addTarget

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Unit

Code

public function testAddTargetGone() {
  $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->config
    ->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));
  $this->api
    ->expects($this
    ->at(0))
    ->method('addTranslation')
    ->with('my_doc_id', 'es_ES', NULL)
    ->will($this
    ->returnValue($response));
  $this
    ->assertFalse($this->lingotek
    ->addTarget('my_doc_id', 'es_ES', NULL));
}