public function LingotekNodeBulkFormTest::testProfileFilter in Lingotek Translation 3.6.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 4.0.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 3.0.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 3.1.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 3.2.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 3.3.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 3.4.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 3.5.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 3.7.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
- 3.8.x tests/src/Functional/Form/LingotekNodeBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormTest::testProfileFilter()
Tests that the bulk management profile filtering works correctly.
File
- tests/
src/ Functional/ Form/ LingotekNodeBulkFormTest.php, line 126
Class
- LingotekNodeBulkFormTest
- Tests the bulk management form.
Namespace
Drupal\Tests\lingotek\Functional\FormCode
public function testProfileFilter() {
$assert_session = $this
->assertSession();
$nodes = [];
// See https://www.drupal.org/project/drupal/issues/2925290.
$indexes = "ABCDEFGHIJKLMNOPQ";
// Create a node.
for ($i = 1; $i < 15; $i++) {
$profile = 'automatic';
if ($i % 2 == 0) {
$profile = 'manual';
}
elseif ($i % 3 == 0) {
$profile = Lingotek::PROFILE_DISABLED;
}
$edit = [];
$edit['title[0][value]'] = 'Llamas are cool ' . $indexes[$i];
$edit['body[0][value]'] = 'Llamas are very cool ' . $indexes[$i];
$edit['langcode[0][value]'] = 'en';
$edit['lingotek_translation_management[lingotek_translation_profile]'] = $profile;
$this
->saveAndPublishNodeForm($edit);
$nodes[$i] = $edit;
}
$this
->goToContentBulkManagementForm();
// Assert there is a pager.
$assert_session
->linkByHrefExists('?page=1');
// After we filter by automatic profile, there is no pager and the rows
// listed are the ones expected.
$edit = [
'filters[advanced_options][profile][]' => 'automatic',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
1,
5,
7,
11,
13,
] as $j) {
// The filtered id is shown, but not others.
$assert_session
->linkExists('Llamas are cool ' . $indexes[$j]);
$assert_session
->linkNotExists('Llamas are cool 2');
// The value is retained in the filter.
$this
->assertFieldByName('filters[advanced_options][profile][]', 'automatic', 'The value is retained in the filter.');
}
// After we filter by manual profile, there is no pager and the rows
// listed are the ones expected.
$edit = [
'filters[advanced_options][profile][]' => 'manual',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
2,
4,
6,
8,
10,
12,
14,
] as $j) {
// The filtered id is shown, but not others.
$assert_session
->linkExists('Llamas are cool ' . $indexes[$j]);
$assert_session
->linkNotExists('Llamas are cool 2');
// The value is retained in the filter.
$this
->assertFieldByName('filters[advanced_options][profile][]', 'manual', 'The value is retained in the filter.');
}
// After we filter by disabled profile, there is no pager and the rows
// listed are the ones expected.
$edit = [
'filters[advanced_options][profile][]' => 'disabled',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
3,
9,
] as $j) {
// The filtered id is shown, but not others.
$assert_session
->linkExists('Llamas are cool ' . $indexes[$j]);
$assert_session
->linkNotExists('Llamas are cool 2');
// The value is retained in the filter.
$this
->assertFieldByName('filters[advanced_options][profile][]', 'disabled', 'The value is retained in the filter.');
}
$assert_session
->linkNotExists('Llamas are cool 15');
$assert_session
->linkByHrefNotExists('?page=1');
}