public function PathAdminTest::testPathFiltering in Drupal 8
Same name and namespace in other branches
- 9 core/modules/path/tests/src/Functional/PathAdminTest.php \Drupal\Tests\path\Functional\PathAdminTest::testPathFiltering()
- 10 core/modules/path/tests/src/Functional/PathAdminTest.php \Drupal\Tests\path\Functional\PathAdminTest::testPathFiltering()
Tests the filtering aspect of the Path UI.
File
- core/
modules/ path/ tests/ src/ Functional/ PathAdminTest.php, line 40
Class
- PathAdminTest
- Tests the Path admin UI.
Namespace
Drupal\Tests\path\FunctionalCode
public function testPathFiltering() {
// Create test nodes.
$node1 = $this
->drupalCreateNode();
$node2 = $this
->drupalCreateNode();
$node3 = $this
->drupalCreateNode();
// Create aliases.
$alias1 = '/' . $this
->randomMachineName(8);
$edit = [
'path[0][value]' => '/node/' . $node1
->id(),
'alias[0][value]' => $alias1,
];
$this
->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$alias2 = '/' . $this
->randomMachineName(8);
$edit = [
'path[0][value]' => '/node/' . $node2
->id(),
'alias[0][value]' => $alias2,
];
$this
->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
$alias3 = '/' . $this
->randomMachineName(4) . '/' . $this
->randomMachineName(4);
$edit = [
'path[0][value]' => '/node/' . $node3
->id(),
'alias[0][value]' => $alias3,
];
$this
->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
// Filter by the first alias.
$edit = [
'filter' => $alias1,
];
$this
->drupalPostForm(NULL, $edit, t('Filter'));
$this
->assertLinkByHref($alias1);
$this
->assertNoLinkByHref($alias2);
$this
->assertNoLinkByHref($alias3);
// Filter by the second alias.
$edit = [
'filter' => $alias2,
];
$this
->drupalPostForm(NULL, $edit, t('Filter'));
$this
->assertNoLinkByHref($alias1);
$this
->assertLinkByHref($alias2);
$this
->assertNoLinkByHref($alias3);
// Filter by the third alias which has a slash.
$edit = [
'filter' => $alias3,
];
$this
->drupalPostForm(NULL, $edit, t('Filter'));
$this
->assertNoLinkByHref($alias1);
$this
->assertNoLinkByHref($alias2);
$this
->assertLinkByHref($alias3);
// Filter by a random string with a different length.
$edit = [
'filter' => $this
->randomMachineName(10),
];
$this
->drupalPostForm(NULL, $edit, t('Filter'));
$this
->assertNoLinkByHref($alias1);
$this
->assertNoLinkByHref($alias2);
// Reset the filter.
$edit = [];
$this
->drupalPostForm(NULL, $edit, t('Reset'));
$this
->assertLinkByHref($alias1);
$this
->assertLinkByHref($alias2);
}