You are here

public function LingotekManagementFormTest::testQueryExcludesUndefinedLanguageContent in Lingotek Translation 8.2

Same name and namespace in other branches
  1. 8 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 201

Class

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

Namespace

Drupal\Tests\lingotek\Unit\Form

Code

public function testQueryExcludesUndefinedLanguageContent() {
  $select = $this
    ->getMockBuilder(PagerSelectExtender::class)
    ->disableOriginalConstructor()
    ->getMock();
  $select
    ->expects($this
    ->any())
    ->method('extend')
    ->with('\\Drupal\\Core\\Database\\Query\\PagerSelectExtender')
    ->willReturnSelf();
  $select
    ->expects($this
    ->any())
    ->method('fields')
    ->with('entity_table', [
    'id',
  ])
    ->willReturnSelf();
  $statement = $this
    ->createMock(StatementInterface::class);

  // Assert that condition is called filtering by the undefined language.
  $select
    ->expects($this
    ->any())
    ->method('condition')
    ->with('entity_table.langcode', 'und', '!=')
    ->willReturnSelf();
  $select
    ->expects($this
    ->once())
    ->method('limit')
    ->with(10)
    ->willReturnSelf();
  $select
    ->expects($this
    ->once())
    ->method('execute')
    ->willReturn($statement);
  $statement
    ->expects($this
    ->once())
    ->method('fetchCol')
    ->with(0)
    ->willReturn([]);
  $this->connection
    ->expects($this
    ->once())
    ->method('select')
    ->willReturn($select);
  $tempStore = $this
    ->getMockBuilder(PrivateTempStoreFactory::class)
    ->disableOriginalConstructor()
    ->getMock();
  $this->tempStoreFactory
    ->expects($this
    ->at(0))
    ->method('get')
    ->with('lingotek.management.filter.node')
    ->willReturn($tempStore);
  $this->tempStoreFactory
    ->expects($this
    ->at(1))
    ->method('get')
    ->with('lingotek.management.filter.node')
    ->willReturn($tempStore);
  $this->tempStoreFactory
    ->expects($this
    ->at(2))
    ->method('get')
    ->with('lingotek.management.items_per_page')
    ->willReturn($tempStore);
  $this->tempStoreFactory
    ->expects($this
    ->at(3))
    ->method('get')
    ->with('lingotek.management.filter.node')
    ->willReturn($tempStore);
  $this->tempStoreFactory
    ->expects($this
    ->at(4))
    ->method('get')
    ->with('lingotek.management.items_per_page')
    ->willReturn($tempStore);
  $tempStore
    ->expects($this
    ->at(0))
    ->method('get')
    ->with('label')
    ->willReturn(NULL);
  $tempStore
    ->expects($this
    ->at(1))
    ->method('get')
    ->with('bundle')
    ->willReturn(NULL);
  $tempStore
    ->expects($this
    ->at(2))
    ->method('get')
    ->with('job')
    ->willReturn(NULL);
  $tempStore
    ->expects($this
    ->at(3))
    ->method('get')
    ->with('document_id')
    ->willReturn(NULL);
  $tempStore
    ->expects($this
    ->at(4))
    ->method('get')
    ->with('entity_id')
    ->willReturn(NULL);
  $tempStore
    ->expects($this
    ->at(5))
    ->method('get')
    ->with('source_language')
    ->willReturn(NULL);
  $tempStore
    ->expects($this
    ->at(6))
    ->method('get')
    ->with('source_status')
    ->willReturn(NULL);
  $tempStore
    ->expects($this
    ->at(7))
    ->method('get')
    ->with('target_status')
    ->willReturn(NULL);
  $tempStore
    ->expects($this
    ->at(8))
    ->method('get')
    ->with('profile')
    ->willReturn(NULL);
  $entityType = $this
    ->createMock(EntityTypeInterface::class);
  $entityType
    ->expects($this
    ->any())
    ->method('get')
    ->with('bundle_entity_type')
    ->willReturn('node');
  $this->entityTypeManager
    ->expects($this
    ->any())
    ->method('getDefinition')
    ->with('node')
    ->willReturn($entityType);
  $entityType
    ->expects($this
    ->any())
    ->method('getKey')
    ->will($this
    ->returnArgument(0));
  $storage = $this
    ->createMock(EntityStorageInterface::class);
  $this->entityTypeManager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->with('node')
    ->willReturn($storage);
  $storage
    ->expects($this
    ->once())
    ->method('loadMultiple')
    ->willReturn([]);
  $this->entityTypeBundleInfo
    ->expects($this
    ->once())
    ->method('getBundleInfo')
    ->willReturn([]);
  $language = $this
    ->createMock(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->moduleHandler
    ->expects($this
    ->at(0))
    ->method('moduleExists')
    ->with('group')
    ->willReturn(FALSE);
  $this->form
    ->buildForm([], new FormState());
}