You are here

public function LingotekCliServiceTest::testDownloadTranslationsSome in Lingotek Translation 3.7.x

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

File

tests/src/Unit/Cli/LingotekCliServiceTest.php, line 614

Class

LingotekCliServiceTest
@coversDefaultClass \Drupal\lingotek\Cli\LingotekCliService @group lingotek @preserveGlobalState disabled

Namespace

Drupal\Tests\lingotek\Unit\Cli

Code

public function testDownloadTranslationsSome() {

  /** @var \Drupal\Core\Entity\EntityInterface|\PHPUnit_Framework_MockObject_MockObject $entity */
  $entity = $this
    ->createMock(ContentEntityInterface::class);
  $entityStorage = $this
    ->createMock(EntityStorageInterface::class);
  $entityStorage
    ->expects($this
    ->once())
    ->method('load')
    ->with(1)
    ->willReturn($entity);
  $this->entityTypeManager
    ->expects($this
    ->once())
    ->method('hasDefinition')
    ->with('node')
    ->willReturn(TRUE);
  $this->entityTypeManager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->with('node')
    ->willReturn($entityStorage);
  $this->languageLocaleMapper
    ->expects($this
    ->any())
    ->method('getLocaleForLangcode')
    ->will($this
    ->returnValueMap([
    [
      'es',
      'es_ES',
    ],
    [
      'de',
      'de_DE',
    ],
  ]));
  $this->translationService
    ->expects($this
    ->at(0))
    ->method('downloadDocument')
    ->with($entity, 'es_ES')
    ->willReturn(TRUE);
  $this->translationService
    ->expects($this
    ->at(1))
    ->method('downloadDocument')
    ->with($entity, 'de_DE')
    ->willReturn(TRUE);
  $result = $this->cliService
    ->downloadTranslations('node', 1, [
    'es',
    'de',
  ]);
  $this
    ->assertEquals($this->cliService::COMMAND_SUCCEDED, $result);
}