function ConfigSourceListTest::testNodeTypeFilter

File

sources/tmgmt_config/tests/src/Functional/ConfigSourceListTest.php, line 166

Class

ConfigSourceListTest
Tests the user interface for entity translation lists.

Namespace

Drupal\Tests\tmgmt_config\Functional

Code

function testNodeTypeFilter() {
  $this
    ->drupalGet('admin/tmgmt/sources/config/node_type');
  $this
    ->assertSession()
    ->pageTextContains('Content type overview (Config Entity)');

  // Simple filtering.
  $this
    ->drupalGet('admin/tmgmt/sources/config/node_type');
  $filters = array(
    'search[name]' => '',
    'search[langcode]' => '',
    'search[target_language]' => '',
  );
  $this
    ->submitForm($filters, 'Search');

  // Random text in the name label.
  $this
    ->drupalGet('admin/tmgmt/sources/config/node_type');
  $filters = array(
    'search[name]' => $this
      ->randomMachineName(5),
    'search[langcode]' => '',
    'search[target_language]' => '',
  );
  $this
    ->submitForm($filters, 'Search');
  $this
    ->assertSession()
    ->pageTextContains('No source items matching given criteria have been found.');

  // Searching for article.
  $this
    ->drupalGet('admin/tmgmt/sources/config/node_type');
  $filters = array(
    'search[name]' => 'article',
    'search[langcode]' => '',
    'search[target_language]' => '',
  );
  $this
    ->submitForm($filters, 'Search');
  $rows = $this
    ->xpath('//tbody/tr/td[2]/a');
  foreach ($rows as $value) {
    $this
      ->assertEquals('Article', $value
      ->getText());
  }

  // Searching for article, with english source language and italian target language.
  $this
    ->drupalGet('admin/tmgmt/sources/config/node_type');
  $filters = array(
    'search[name]' => 'article',
    'search[langcode]' => 'en',
    'search[target_language]' => 'it',
  );
  $this
    ->submitForm($filters, 'Search');
  $rows = $this
    ->xpath('//tbody/tr/td[2]/a');
  foreach ($rows as $value) {
    $this
      ->assertEquals('Article', $value
      ->getText());
  }

  // Searching by keywords (shorter terms).
  $this
    ->drupalGet('admin/tmgmt/sources/config/node_type');
  $filters = array(
    'search[name]' => 'art',
    'search[langcode]' => 'en',
    'search[target_language]' => 'it',
  );
  $this
    ->submitForm($filters, 'Search');
  $rows = $this
    ->xpath('//tbody/tr/td[2]/a');
  foreach ($rows as $value) {
    $this
      ->assertEquals('Article', $value
      ->getText());
  }
}