You are here

public function LingotekManagementFormTest::testGenerateBulkOptions in Lingotek Translation 3.8.x

Same name and namespace in other branches
  1. 4.0.x tests/src/Unit/Form/LingotekManagementFormTest.php \Drupal\Tests\lingotek\Unit\Form\LingotekManagementFormTest::testGenerateBulkOptions()

@covers ::generateBulkOptions

File

tests/src/Unit/Form/LingotekManagementFormTest.php, line 372

Class

LingotekManagementFormTest
@coversDefaultClass \Drupal\lingotek\Form\LingotekManagementForm @group lingotek @preserveGlobalState disabled

Namespace

Drupal\Tests\lingotek\Unit\Form

Code

public function testGenerateBulkOptions() {
  $entityType = $this
    ->createMock(EntityTypeInterface::class);
  $entityType
    ->expects($this
    ->any())
    ->method('hasLinkTemplate')
    ->with('delete-multiple-form')
    ->willReturn(FALSE);
  $this->entityTypeManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->with('node')
    ->willReturn($entityType);
  $this->lingotekConfiguration
    ->expects($this
    ->any())
    ->method('getProfileOptions')
    ->willReturn([
    'manual',
  ]);
  $languageEnabled = $this
    ->createMock(ConfigurableLanguageInterface::class);
  $languageDisabled = $this
    ->createMock(ConfigurableLanguageInterface::class);
  $languageEnabled
    ->expects($this
    ->any())
    ->method('getId')
    ->willReturn('en');
  $languageDisabled
    ->expects($this
    ->any())
    ->method('getId')
    ->willReturn('di');
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getLanguages')
    ->willReturn([
    'en' => $languageEnabled,
    'di' => $languageDisabled,
  ]);
  $this->lingotekConfiguration
    ->expects($this
    ->any())
    ->method('isLanguageEnabled')
    ->withConsecutive([
    $languageEnabled,
  ], [
    $languageDisabled,
  ])
    ->willReturnOnConsecutiveCalls(TRUE, FALSE);
  $languageStorage = $this
    ->createMock(EntityStorageInterface::class);
  $languageStorage
    ->expects($this
    ->exactly(2))
    ->method('load')
    ->withConsecutive([
    'en',
  ], [
    'di',
  ])
    ->willReturnOnConsecutiveCalls($languageEnabled, $languageDisabled);
  $this->entityTypeManager
    ->expects($this
    ->any())
    ->method('getStorage')
    ->with('configurable_language')
    ->willReturn($languageStorage);
  $options = $this->form
    ->generateBulkOptions();
  $this
    ->assertArrayHasKey('request_translations', $options['Request translations']);
  $this
    ->assertArrayHasKey('request_translation:en', $options['Request translations']);
  $this
    ->assertArrayNotHasKey('request_translation:di', $options['Request translations']);
}