3 namespace Drupal\pathauto\Tests;
5 use Drupal\simpletest\WebTestBase;
6 use Drupal\views\Views;
9 * Tests pathauto user UI integration.
13 class PathautoUserWebTest extends WebTestBase {
15 use PathautoTestHelperTrait;
22 public static $modules = array('pathauto', 'views');
27 * @var \Drupal\user\UserInterface
37 // Allow other modules to add additional permissions for the admin user.
39 'administer pathauto',
40 'administer url aliases',
44 $this->adminUser = $this->drupalCreateUser($permissions);
45 $this->drupalLogin($this->adminUser);
47 $this->createPattern('user', '/users/[user:name]');
51 * Basic functional testing of Pathauto with users.
53 function testUserEditing() {
54 // There should be no Pathauto checkbox on user forms.
55 $this->drupalGet('user/' . $this->adminUser->id() . '/edit');
56 $this->assertNoFieldById('path[0][pathauto]');
60 * Test user operations.
62 function testUserOperations() {
63 $account = $this->drupalCreateUser();
65 // Delete all current URL aliases.
66 $this->deleteAllAliases();
68 // Find the position of just created account in the user_admin_people view.
69 $view = Views::getView('user_admin_people');
71 $view->preview('page_1');
73 foreach ($view->result as $key => $row) {
74 if ($view->field['name']->getValue($row) == $account->getUsername()) {
80 'action' => 'pathauto_update_alias_user',
81 "user_bulk_form[$key]" => TRUE,
83 $this->drupalPostForm('admin/people', $edit, t('Apply to selected items'));
84 $this->assertText('Update URL alias was applied to 1 item.');
86 $this->assertEntityAlias($account, '/users/' . mb_strtolower($account->getUsername()));
87 $this->assertEntityAlias($this->adminUser, '/user/' . $this->adminUser->id());