3 namespace Drupal\Tests\path\Functional;
6 * Tests the Path admin UI.
10 class PathAdminTest extends PathTestBase {
17 public static $modules = ['path'];
19 protected function setUp() {
22 // Create test user and log in.
23 $web_user = $this->drupalCreateUser(['create page content', 'edit own page content', 'administer url aliases', 'create url aliases']);
24 $this->drupalLogin($web_user);
28 * Tests the filtering aspect of the Path UI.
30 public function testPathFiltering() {
32 $node1 = $this->drupalCreateNode();
33 $node2 = $this->drupalCreateNode();
34 $node3 = $this->drupalCreateNode();
37 $alias1 = '/' . $this->randomMachineName(8);
39 'source' => '/node/' . $node1->id(),
42 $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
44 $alias2 = '/' . $this->randomMachineName(8);
46 'source' => '/node/' . $node2->id(),
49 $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
51 $alias3 = '/' . $this->randomMachineName(4) . '/' . $this->randomMachineName(4);
53 'source' => '/node/' . $node3->id(),
56 $this->drupalPostForm('admin/config/search/path/add', $edit, t('Save'));
58 // Filter by the first alias.
62 $this->drupalPostForm(NULL, $edit, t('Filter'));
63 $this->assertLinkByHref($alias1);
64 $this->assertNoLinkByHref($alias2);
65 $this->assertNoLinkByHref($alias3);
67 // Filter by the second alias.
71 $this->drupalPostForm(NULL, $edit, t('Filter'));
72 $this->assertNoLinkByHref($alias1);
73 $this->assertLinkByHref($alias2);
74 $this->assertNoLinkByHref($alias3);
76 // Filter by the third alias which has a slash.
80 $this->drupalPostForm(NULL, $edit, t('Filter'));
81 $this->assertNoLinkByHref($alias1);
82 $this->assertNoLinkByHref($alias2);
83 $this->assertLinkByHref($alias3);
85 // Filter by a random string with a different length.
87 'filter' => $this->randomMachineName(10),
89 $this->drupalPostForm(NULL, $edit, t('Filter'));
90 $this->assertNoLinkByHref($alias1);
91 $this->assertNoLinkByHref($alias2);
95 $this->drupalPostForm(NULL, $edit, t('Reset'));
96 $this->assertLinkByHref($alias1);
97 $this->assertLinkByHref($alias2);