public function ContentFullViewFiltersFieldsTest::testSorting in Translation Views 8
Test the sorting.
File
- tests/
src/ Functional/ ContentFullViewFiltersFieldsTest.php, line 225
Class
- ContentFullViewFiltersFieldsTest
- Tests for fields, filters and sorting for content entity.
Namespace
Drupal\Tests\translation_views\FunctionalCode
public function testSorting() {
// Title.
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'title',
'sort' => 'asc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', '002_fr_title_node1');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', '003_de_title_node1');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', '004_de_title_node2');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', '005_fr_title_node2');
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'title',
'sort' => 'desc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', '002_fr_title_node1');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', '003_de_title_node1');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', '004_de_title_node2');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', '005_fr_title_node2');
// Translation language.
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'langcode',
'sort' => 'asc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'German');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'German');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'French');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', 'French');
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'langcode',
'sort' => 'desc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', 'German');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'German');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'French');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'French');
// Target language equals default language.
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'translation_default',
'sort' => 'asc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'No');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'No');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'Yes');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', 'Yes');
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'translation_default',
'sort' => 'desc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', 'No');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'No');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'Yes');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'Yes');
// Translation changed time.
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'translation_changed',
'sort' => 'asc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextNotContains('css', 'table > tbody > tr:nth-child(1)', ':');
$this
->assertSession()
->elementTextNotContains('css', 'table > tbody > tr:nth-child(2)', ':');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', ':');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', ':');
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'translation_changed',
'sort' => 'desc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextNotContains('css', 'table > tbody > tr:nth-child(4)', ':');
$this
->assertSession()
->elementTextNotContains('css', 'table > tbody > tr:nth-child(3)', ':');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', ':');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', ':');
// Translation counter.
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'translation_count',
'sort' => 'asc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', '1');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', '1');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', '2');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', '2');
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'translation_count',
'sort' => 'desc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', '1');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', '1');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', '2');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', '2');
// Translation counter.
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'translation_status',
'sort' => 'asc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'Not translated');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'Not translated');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'Translated');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', 'Translated');
$this
->drupalGet('translation-views-all-filters-and-fields', [
'query' => [
'content_translation_source' => 'All',
'translation_target_language' => '***LANGUAGE_site_default***',
'translation_default' => 'All',
'translation_status' => 'All',
'order' => 'translation_status',
'sort' => 'desc',
],
]);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(4)', 'Not translated');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(3)', 'Not translated');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(2)', 'Translated');
$this
->assertSession()
->elementTextContains('css', 'table > tbody > tr:nth-child(1)', 'Translated');
}