You are here

public function LingotekManagementFormTest::testQueryExcludesUndefinedLanguageContent in Lingotek Translation 8

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

@covers ::buildForm

File

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

Class

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

Namespace

Drupal\Tests\lingotek\Unit\Form

Code

public function testQueryExcludesUndefinedLanguageContent() {
  $query = $this
    ->getMock(QueryInterface::class);
  $this->entityQuery
    ->expects($this
    ->once())
    ->method('get')
    ->with('node')
    ->willReturn($query);
  $query
    ->expects($this
    ->once())
    ->method('pager')
    ->with(10, NULL)
    ->willReturn($query);

  // Assert that condition is called filtering by the undefined language.
  $query
    ->expects($this
    ->once())
    ->method('condition')
    ->with('langcode', 'und', '!=', NULL)
    ->willReturn($query);
  $tempStore = $this
    ->getMockBuilder(PrivateTempStore::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->tempStoreFactory
    ->expects($this
    ->at(0))
    ->method('get')
    ->with('lingotek.management.items_per_page')
    ->willReturn($tempStore);
  $this->tempStoreFactory
    ->expects($this
    ->at(1))
    ->method('get')
    ->with('lingotek.management.filter.node')
    ->willReturn($tempStore);
  $entityType = $this
    ->getMock(EntityTypeInterface::class);
  $this->entityManager
    ->expects($this
    ->once())
    ->method('getDefinition')
    ->with('node')
    ->willReturn($entityType);
  $entityType
    ->expects($this
    ->any())
    ->method('getKey')
    ->will($this
    ->returnArgument(0));
  $storage = $this
    ->getMock(EntityStorageInterface::class);
  $this->entityManager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->with('node')
    ->willReturn($storage);
  $storage
    ->expects($this
    ->once())
    ->method('loadMultiple')
    ->willReturn([]);
  $this->entityManager
    ->expects($this
    ->once())
    ->method('getBundleInfo')
    ->willReturn([]);
  $language = $this
    ->getMock(ConfigurableLanguageInterface::class);
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getLanguages')
    ->willReturn([
    'en' => $language,
  ]);
  $this->lingotekConfiguration
    ->expects($this
    ->any())
    ->method('getProfileOptions')
    ->willReturn([
    'manual',
  ]);
  $this->state
    ->expects($this
    ->once())
    ->method('get')
    ->with('lingotek.enable_debug_utilities')
    ->willReturn(FALSE);
  $this->form
    ->buildForm([], new FormState());
}