public function LingotekConfigBulkFormTest::testLabelFilter in Lingotek Translation 3.2.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 4.0.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 3.0.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 3.1.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 3.3.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 3.4.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 3.5.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 3.6.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 3.7.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
- 3.8.x tests/src/Functional/Form/LingotekConfigBulkFormTest.php \Drupal\Tests\lingotek\Functional\Form\LingotekConfigBulkFormTest::testLabelFilter()
Tests that the bulk management filtering works correctly.
File
- tests/
src/ Functional/ Form/ LingotekConfigBulkFormTest.php, line 1222
Class
- LingotekConfigBulkFormTest
- Tests the config bulk management form.
Namespace
Drupal\Tests\lingotek\Functional\FormCode
public function testLabelFilter() {
$assert_session = $this
->assertSession();
$this
->goToConfigBulkManagementForm();
$this
->assertNoField('filters[wrapper][label]');
\Drupal::configFactory()
->getEditable('lingotek.settings')
->set('translate.config.node_type.profile', 'manual')
->save();
$node_types = [];
// See https://www.drupal.org/project/drupal/issues/2925290.
$indexes = "ABCDEFGHIJKLMNOPQ";
// Create some nodes.
for ($i = 1; $i < 10; $i++) {
$odd_index = $i % 2 == 0;
$name = 'Content Type ' . $indexes[$i] . ' ' . ($odd_index ? 'odd' : 'even');
$node_types[$i] = $this
->drupalCreateContentType([
'type' => 'content_type_' . $i,
'name' => $name,
]);
}
$this
->goToConfigBulkManagementForm('node_type');
$this
->assertField('filters[wrapper][label]');
$this
->assertNoText('No content available');
// After we filter by an unexisting label, there is no content and no rows.
$edit = [
'filters[wrapper][label]' => 'this label does not exist',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
$this
->assertText('No content available');
// After we reset, we get back to having all the content.
$this
->drupalPostForm(NULL, [], 'Reset');
$this
->goToConfigBulkManagementForm('node_type');
foreach (range(1, 9) as $j) {
$this
->assertText('Content Type ' . $indexes[$j]);
}
// After we filter by prime, there is no pager and the rows
// selected are the ones expected.
$edit = [
'filters[wrapper][label]' => 'even',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
1,
3,
5,
7,
9,
] as $j) {
$this
->assertText('Content Type ' . $indexes[$j]);
}
$this
->assertNoText('Content Type ' . $indexes[2]);
$this
->assertNoText('Content Type ' . $indexes[4]);
$this
->assertNoText('Content Type ' . $indexes[6]);
// After we filter by even, there is no pager and the rows selected are the
// ones expected.
$edit = [
'filters[wrapper][label]' => 'odd',
];
$this
->drupalPostForm(NULL, $edit, 'edit-filters-actions-submit');
foreach ([
2,
4,
6,
8,
] as $j) {
$this
->assertText('Content Type ' . $indexes[$j]);
}
$this
->assertNoText('Content Type ' . $indexes[1]);
$this
->assertNoText('Content Type ' . $indexes[3]);
$this
->assertNoText('Content Type ' . $indexes[5]);
// After we reset, we get back to having all the content.
$this
->drupalPostForm(NULL, [], 'Reset');
$this
->goToConfigBulkManagementForm('node_type');
foreach (range(1, 9) as $j) {
$this
->assertText('Content Type ' . $indexes[$j]);
}
}