public function LingotekUnitTest::testGetDocumentTranslationStatus in Lingotek Translation 8
Same name and namespace in other branches
- 8.2 tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 4.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.0.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.1.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.2.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.3.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.4.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.5.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.6.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.7.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
- 3.8.x tests/src/Unit/LingotekUnitTest.php \Drupal\Tests\lingotek\Unit\LingotekUnitTest::testGetDocumentTranslationStatus()
@covers ::getDocumentTranslationStatus
File
- tests/
src/ Unit/ LingotekUnitTest.php, line 539
Class
- LingotekUnitTest
- @coversDefaultClass \Drupal\lingotek\Lingotek @group lingotek @preserveGlobalState disabled
Namespace
Drupal\Tests\lingotek\UnitCode
public function testGetDocumentTranslationStatus() {
$response = $this
->getMockBuilder('\\Psr\\Http\\Message\\ResponseInterface')
->disableOriginalConstructor()
->getMock();
$response
->expects($this
->any())
->method('getStatusCode')
->willReturn(Response::HTTP_OK);
$response
->expects($this
->any())
->method('getBody')
->willReturn(json_encode([
'entities' => [
[
'properties' => [
'locale_code' => 'es-ES',
'percent_complete' => 100,
],
],
[
'properties' => [
'locale_code' => 'de-DE',
'percent_complete' => 50,
],
],
],
]));
$this->api
->expects($this
->at(0))
->method('getDocumentTranslationStatus')
->with('my_doc_id', 'es_ES')
->will($this
->returnValue($response));
$this->api
->expects($this
->at(1))
->method('getDocumentTranslationStatus')
->with('my_doc_id', 'de_DE')
->will($this
->returnValue($response));
$this->api
->expects($this
->at(2))
->method('getDocumentTranslationStatus')
->with('my_doc_id', 'ca_ES')
->will($this
->returnValue($response));
// Assert that a complete translation is reported as completed.
$result = $this->lingotek
->getDocumentTranslationStatus('my_doc_id', 'es_ES');
$this
->assertEquals(TRUE, $result);
// Assert that an incomplete translation is reported as not completed.
$result = $this->lingotek
->getDocumentTranslationStatus('my_doc_id', 'de_DE');
$this
->assertEquals(FALSE, $result);
// Assert that an unrequested translation is reported as not completed.
$result = $this->lingotek
->getDocumentTranslationStatus('my_doc_id', 'ca_ES');
$this
->assertEquals(FALSE, $result);
}