public function LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter in Lingotek Translation 3.8.x
Same name and namespace in other branches
- 4.0.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
- 3.0.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
- 3.1.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
- 3.2.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
- 3.3.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
- 3.4.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
- 3.5.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
- 3.6.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
- 3.7.x tests/src/Functional/Form/LingotekNodeBulkFormWithGroupModuleTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekNodeBulkFormWithGroupModuleTest::testGroupFilter()
Tests that the bulk management group filtering works correctly.
File
- tests/
src/ Functional/ Form/ LingotekNodeBulkFormWithGroupModuleTest.php, line 189
Class
- LingotekNodeBulkFormWithGroupModuleTest
- Tests the bulk management form when the group module is enabled.
Namespace
Drupal\Tests\lingotek\Functional\FormCode
public function testGroupFilter() {
$assert_session = $this
->assertSession();
$nodes = [];
// Create some nodes and relate them with groups.
for ($i = 1; $i < 15; $i++) {
$group = 1;
if ($i % 2 == 0) {
$group = 2;
}
elseif ($i % 3 == 0) {
$group = 3;
}
$edit = [];
$edit['title[0][value]'] = new FormattableMarkup('Llamas are cool @i at Group @group', [
'@group' => $this->groups[$group],
'@i' => $i,
]);
$edit['body[0][value]'] = $edit['title[0][value]'];
$edit['lingotek_translation_management[lingotek_translation_profile]'] = 'manual';
$this
->saveAndPublishNodeForm($edit);
$this
->relateNodeToGroup($i, $group, $edit['title[0][value]']);
$nodes[$i] = $edit;
}
$this
->goToContentBulkManagementForm();
// Assert there is a pager.
$assert_session
->linkByHrefExists('?page=1');
// After we filter by first group, there is no pager and the rows selected
// are the ones expected.
$edit = [
'filters[wrapper][group]' => '1',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
1,
5,
7,
11,
13,
] as $j) {
$assert_session
->linkExists('Llamas are cool ' . $j . ' at Group My Product 1.0');
}
$assert_session
->linkByHrefNotExists('?page=1');
$assert_session
->linkNotExists('Llamas are cool 2 at Group My Product 2.0');
// After we filter by second group, there is no pager and the rows selected
// are the ones expected.
$edit = [
'filters[wrapper][group]' => '2',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
2,
4,
6,
8,
10,
12,
14,
] as $j) {
$assert_session
->linkExists('Llamas are cool ' . $j . ' at Group My Product 2.0');
}
$assert_session
->linkNotExists('Page 2');
$assert_session
->linkNotExists('Llamas are cool 1 at Group My Product 1.0');
// After we filter by third group, there is no pager and the rows selected
// are the ones expected.
$edit = [
'filters[wrapper][group]' => '3',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
3,
9,
] as $j) {
$assert_session
->linkExists('Llamas are cool ' . $j . ' at Group My Product 2.4');
}
$assert_session
->linkByHrefNotExists('?page=1');
$assert_session
->linkNotExists('Llamas are cool 5 at Group My Product 1.0');
// 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 ' . $j . ' at Group My Product 1.0');
}
foreach ([
2,
4,
6,
8,
10,
] as $j) {
$assert_session
->linkExists('Llamas are cool ' . $j . ' at Group My Product 2.0');
}
foreach ([
3,
9,
] as $j) {
$assert_session
->linkExists('Llamas are cool ' . $j . ' at Group My Product 2.4');
}
$assert_session
->linkByHrefExists('?page=1');
}