3 namespace Drupal\pathauto\Tests;
4 use Drupal\Component\Utility\Unicode;
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]');
52 * Basic functional testing of Pathauto with users.
54 function testUserEditing() {
55 // There should be no Pathauto checkbox on user forms.
56 $this->drupalGet('user/' . $this->adminUser->id() . '/edit');
57 $this->assertNoFieldById('path[0][pathauto]');
61 * Test user operations.
63 function testUserOperations() {
64 $account = $this->drupalCreateUser();
66 // Delete all current URL aliases.
67 $this->deleteAllAliases();
69 // Find the position of just created account in the user_admin_people view.
70 $view = Views::getView('user_admin_people');
72 $view->preview('page_1');
75 foreach ($view->result as $key => $row) {
76 if ($view->field['name']->getValue($row) == $account->getUsername()) {
82 'action' => 'pathauto_update_alias_user',
83 "user_bulk_form[$key]" => TRUE,
85 $this->drupalPostForm('admin/people', $edit, t('Apply to selected items'));
86 $this->assertText('Update URL alias was applied to 1 item.');
88 $this->assertEntityAlias($account, '/users/' . Unicode::strtolower($account->getUsername()));
89 $this->assertEntityAlias($this->adminUser, '/user/' . $this->adminUser->id());