public function LingotekNodeBulkFormTest::testLanguageFilter in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 4.0.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 3.0.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 3.1.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 3.2.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 3.3.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 3.4.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 3.5.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 3.6.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
- 3.7.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testLanguageFilter()
Tests that the bulk management language filtering works correctly.
File
- tests/
src/ Functional/ Form/ LingotekNodeBulkFormTest.php, line 421
Class
- LingotekNodeBulkFormTest
- Tests the bulk management form.
Namespace
Drupal\Tests\lingotek\Functional\FormCode
public function testLanguageFilter() {
$assert_session = $this
->assertSession();
// Add a language.
ConfigurableLanguage::createFromLangcode('it')
->setThirdPartySetting('lingotek', 'locale', 'it_IT')
->save();
$nodes = [];
// Create a node.
for ($i = 1; $i < 15; $i++) {
$langcode = 'es';
if ($i % 2 == 0) {
$langcode = 'it';
}
elseif ($i % 3 == 0) {
$langcode = 'en';
}
$edit = [];
$edit['title[0][value]'] = new FormattableMarkup('Llamas are cool @langcode @i', [
'@langcode' => strtoupper($langcode),
'@i' => $i,
]);
$edit['body[0][value]'] = $edit['title[0][value]'];
$edit['langcode[0][value]'] = $langcode;
$edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
$this
->saveAndPublishNodeForm($edit);
$nodes[$i] = $edit;
}
$this
->goToContentBulkManagementForm();
// Assert there is a pager.
$assert_session
->linkByHrefExists('?page=1');
// After we filter by Spanish source language, there is no pager and the
// rows selected are the ones expected.
$edit = [
'filters[advanced_options][source_language]' => 'es',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
1,
5,
7,
11,
13,
] as $j) {
$assert_session
->linkExists('Llamas are cool ES ' . $j);
}
$assert_session
->linkByHrefNotExists('?page=1');
$assert_session
->linkNotExists('Llamas are cool IT 2');
$this
->assertFieldByName('filters[advanced_options][source_language]', 'es', 'The value is retained in the filter.');
// After we filter by Italian source language, there is no pager and the
// rows selected are the ones expected.
$edit = [
'filters[advanced_options][source_language]' => 'it',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
2,
4,
6,
8,
10,
12,
14,
] as $j) {
$assert_session
->linkExists('Llamas are cool IT ' . $j);
}
$assert_session
->linkNotExists('Page 2');
$assert_session
->linkNotExists('Llamas are cool ES 1');
$this
->assertFieldByName('filters[advanced_options][source_language]', 'it', 'The value is retained in the filter.');
// After we filter by English source language, there is no pager and the
// rows selected are the ones expected.
$edit = [
'filters[advanced_options][source_language]' => 'en',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
3,
9,
] as $j) {
$assert_session
->linkExists('Llamas are cool EN ' . $j);
}
$assert_session
->linkByHrefNotExists('?page=1');
$assert_session
->linkNotExists('Llamas are cool ES 5');
$this
->assertFieldByName('filters[advanced_options][source_language]', 'en', 'The value is retained in the filter.');
// After we reset, we get back to having a pager and all the content.
$this
->drupalPostForm(NULL, [], 'Reset');
foreach ([
1,
5,
7,
] as $j) {
$assert_session
->linkExists('Llamas are cool ES ' . $j);
}
foreach ([
2,
4,
6,
8,
10,
] as $j) {
$assert_session
->linkExists('Llamas are cool IT ' . $j);
}
foreach ([
3,
9,
] as $j) {
$assert_session
->linkExists('Llamas are cool EN ' . $j);
}
$assert_session
->linkByHrefExists('?page=1');
}