diff --git a/core/modules/user/src/Tests/RestRegisterUserTest.php b/core/modules/user/tests/src/Functional/RestRegisterUserTest.php similarity index 99% rename from core/modules/user/src/Tests/RestRegisterUserTest.php rename to core/modules/user/tests/src/Functional/RestRegisterUserTest.php index 62e6bbc687..576bd3e95e 100644 --- a/core/modules/user/src/Tests/RestRegisterUserTest.php +++ b/core/modules/user/tests/src/Functional/RestRegisterUserTest.php @@ -1,6 +1,6 @@ drupalGet('admin/structure/menu/manage/account'); $label = $this->xpath('//label[contains(.,:text)]/@for', [':text' => 'Enable My account menu link']); - $this->assertFieldChecked((string) $label[0], "The 'My account' link is enabled by default."); + $this->assertFieldChecked($label[0]->getText(), "The 'My account' link is enabled by default."); // Disable the 'My account' link. $edit['links[menu_plugin_id:user.page][enabled]'] = FALSE; diff --git a/core/modules/user/src/Tests/UserAdminLanguageTest.php b/core/modules/user/tests/src/Functional/UserAdminLanguageTest.php similarity index 80% rename from core/modules/user/src/Tests/UserAdminLanguageTest.php rename to core/modules/user/tests/src/Functional/UserAdminLanguageTest.php index cd6cc657bf..04b207524f 100644 --- a/core/modules/user/src/Tests/UserAdminLanguageTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminLanguageTest.php @@ -1,16 +1,16 @@ adminUser->id() . '/edit'; $this->drupalGet($path); // Ensure administration pages language settings widget is not available. - $this->assertNoFieldByXPath($this->constructFieldXpath('id', 'edit-preferred-admin-langcode'), NULL, 'Administration pages language selector not available.'); + $attribute = 'id'; + $value = 'edit-preferred-admin-langcode'; + $xpath = '//textarea[@' . $attribute . '=:value]|//input[@' . $attribute . '=:value]|//select[@' . $attribute . '=:value]'; + $constructFieldXpath = $this->assertSession()->buildXPathQuery($xpath, [':value' => $value]); + $this->assertNoFieldByXPath($constructFieldXpath, NULL, 'Administration pages language selector not available.'); } /** @@ -64,13 +68,13 @@ public function testUserAdminLanguageConfigurationAvailableWithAdminLanguageNego // Checks with user administration pages language negotiation disabled. $this->drupalGet($path); // Ensure administration pages language settings widget is not available. - $this->assertNoFieldByXPath($this->constructFieldXpath('id', 'edit-preferred-admin-langcode'), NULL, 'Administration pages language selector not available.'); + $this->assertNoFieldByXPath($this->buildXPathQuery('//textarea[@id=:value]|//input[@id=:value]|//select[@id=:value]', [':value' => 'edit-preferred-admin-langcode']), NULL, 'Administration pages language selector not available.'); // Checks with user administration pages language negotiation enabled. $this->setLanguageNegotiation(); $this->drupalGet($path); // Ensure administration pages language settings widget is available. - $this->assertFieldByXPath($this->constructFieldXpath('id', 'edit-preferred-admin-langcode'), NULL, 'Administration pages language selector is available.'); + $this->assertFieldByXPath($this->buildXPathQuery('//textarea[@id=:value]|//input[@id=:value]|//select[@id=:value]', [':value' => 'edit-preferred-admin-langcode']), NULL, 'Administration pages language selector is available.'); } /** @@ -91,13 +95,13 @@ public function testUserAdminLanguageConfigurationAvailableIfAdminLanguageNegoti $path = 'user/' . $this->adminUser->id() . '/edit'; $this->drupalGet($path); // Ensure administration pages language setting is visible for admin. - $this->assertFieldByXPath($this->constructFieldXpath('id', 'edit-preferred-admin-langcode'), NULL, 'Administration pages language selector available for admins.'); + $this->assertFieldByXPath($this->buildXPathQuery('//textarea[@id=:value]|//input[@id=:value]|//select[@id=:value]', [':value' => 'edit-preferred-admin-langcode']), NULL, 'Administration pages language selector available for admins.'); // Ensure administration pages language setting is hidden for non-admins. $this->drupalLogin($this->regularUser); $path = 'user/' . $this->regularUser->id() . '/edit'; $this->drupalGet($path); - $this->assertNoFieldByXPath($this->constructFieldXpath('id', 'edit-preferred-admin-langcode'), NULL, 'Administration pages language selector not available for regular user.'); + $this->assertNoFieldByXPath($this->buildXPathQuery('//textarea[@id=:value]|//input[@id=:value]|//select[@id=:value]', [':value' => 'edit-preferred-admin-langcode']), NULL, 'Administration pages language selector not available for regular user.'); } /** diff --git a/core/modules/user/src/Tests/UserAdminListingTest.php b/core/modules/user/tests/src/Functional/UserAdminListingTest.php similarity index 88% rename from core/modules/user/src/Tests/UserAdminListingTest.php rename to core/modules/user/tests/src/Functional/UserAdminListingTest.php index 9ec95060bf..8127a1dcd5 100644 --- a/core/modules/user/src/Tests/UserAdminListingTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminListingTest.php @@ -1,8 +1,8 @@ xpath('//table[contains(@class, "responsive-enabled")]/tbody/tr'); $result_accounts = []; foreach ($result as $account) { - $name = (string) $account->td[0]->span; + $span = $this->xpath('//table/tbody/tr/td[1]/span'); + $name = $span[0]->getText(); $roles = []; if (isset($account->td[2]->div->ul)) { foreach ($account->td[2]->div->ul->li as $element) { @@ -72,10 +73,10 @@ public function testUserListing() { } $result_accounts[$name] = [ 'name' => $name, - 'status' => (string) $account->td[1], + 'status' => $account->getAttribute('td'), 'roles' => $roles, - 'member_for' => (string) $account->td[3], - 'last_access' => (string) $account->td[4], + 'member_for' => $account->getAttribute('td'), + 'last_access' => $account->getAttribute('td'), ]; } diff --git a/core/modules/user/src/Tests/UserAdminSettingsFormTest.php b/core/modules/user/tests/src/Functional/UserAdminSettingsFormTest.php similarity index 97% rename from core/modules/user/src/Tests/UserAdminSettingsFormTest.php rename to core/modules/user/tests/src/Functional/UserAdminSettingsFormTest.php index b77411154c..a197d6cc07 100644 --- a/core/modules/user/src/Tests/UserAdminSettingsFormTest.php +++ b/core/modules/user/tests/src/Functional/UserAdminSettingsFormTest.php @@ -1,6 +1,6 @@ drupalGet('admin/people', ['query' => ['user' => $user_a->getUsername()]]); $result = $this->xpath('//table/tbody/tr'); $this->assertEqual(1, count($result), 'Filter by username returned the right amount.'); - $this->assertEqual($user_a->getUsername(), (string) $result[0]->td[1]->span, 'Filter by username returned the right user.'); + $span = $this->xpath('//table/tbody/tr/td[1]/span'); + $this->assertEqual($user_a->getUsername(), $span[0]->getText(), 'Filter by username returned the right user.'); $this->drupalGet('admin/people', ['query' => ['user' => $user_a->getEmail()]]); $result = $this->xpath('//table/tbody/tr'); $this->assertEqual(1, count($result), 'Filter by username returned the right amount.'); - $this->assertEqual($user_a->getUsername(), (string) $result[0]->td[1]->span, 'Filter by username returned the right user.'); + $span2 = $this->xpath('//table/tbody/tr/td[2]/span'); + $this->assertEqual($user_a->getUsername(), $span2[1]->getText(), 'Filter by username returned the right user.'); // Filter the users by permission 'administer taxonomy'. $this->drupalGet('admin/people', ['query' => ['permission' => 'administer taxonomy']]); @@ -180,7 +185,7 @@ public function testNotificationEmailAddress() { $subject = 'Account details for ' . $edit['name'] . ' at ' . $system->get('name') . ' (pending admin approval)'; // Ensure that admin notification mail is sent to the configured // Notification Email address. - $admin_mail = $this->drupalGetMails([ + $admin_mail = $this->getMails([ 'to' => $notify_address, 'from' => $server_address, 'subject' => $subject, @@ -188,7 +193,7 @@ public function testNotificationEmailAddress() { $this->assertTrue(count($admin_mail), 'New user mail to admin is sent to configured Notification Email address'); // Ensure that user notification mail is sent from the configured // Notification Email address. - $user_mail = $this->drupalGetMails([ + $user_mail = $this->getMails([ 'to' => $edit['mail'], 'from' => $server_address, 'reply-to' => $notify_address, diff --git a/core/modules/user/src/Tests/UserBlocksTest.php b/core/modules/user/tests/src/Functional/UserBlocksTest.php similarity index 97% rename from core/modules/user/src/Tests/UserBlocksTest.php rename to core/modules/user/tests/src/Functional/UserBlocksTest.php index 0a4c619da6..d2cee296c2 100644 --- a/core/modules/user/src/Tests/UserBlocksTest.php +++ b/core/modules/user/tests/src/Functional/UserBlocksTest.php @@ -1,16 +1,16 @@ adminUser = $this->drupalCreateUser(['administer blocks']); $this->drupalLogin($this->adminUser); $this->drupalPlaceBlock('user_login_block'); - $this->drupalLogout($this->adminUser); + $this->drupalLogout(); } /** @@ -69,7 +69,7 @@ public function testUserLoginBlock() { // Log in using the block. $edit = []; $edit['name'] = $user->getUsername(); - $edit['pass'] = $user->pass_raw; + $edit['pass'] = $user->passRaw; $this->drupalPostForm('admin/people/permissions', $edit, t('Log in')); $this->assertNoText(t('User login'), 'Logged in.'); diff --git a/core/modules/user/src/Tests/UserCreateTest.php b/core/modules/user/tests/src/Functional/UserCreateTest.php similarity index 97% rename from core/modules/user/src/Tests/UserCreateTest.php rename to core/modules/user/tests/src/Functional/UserCreateTest.php index 7b534435a0..62f6f0dcee 100644 --- a/core/modules/user/src/Tests/UserCreateTest.php +++ b/core/modules/user/tests/src/Functional/UserCreateTest.php @@ -1,9 +1,9 @@ drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Email')])); - $edit['current_pass'] = $user1->pass_raw; + $edit['current_pass'] = $user1->passRaw; $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); $this->assertRaw(t("The changes have been saved.")); @@ -63,7 +63,7 @@ public function testUserEdit() { $this->assertRaw(t("Your current password is missing or incorrect; it's required to change the %name.", ['%name' => t('Password')])); // Try again with the current password. - $edit['current_pass'] = $user1->pass_raw; + $edit['current_pass'] = $user1->passRaw; $this->drupalPostForm("user/" . $user1->id() . "/edit", $edit, t('Save')); $this->assertRaw(t("The changes have been saved.")); @@ -72,7 +72,7 @@ public function testUserEdit() { // Make sure the user can log in with their new password. $this->drupalLogout(); - $user1->pass_raw = $new_pass; + $user1->passRaw = $new_pass; $this->drupalLogin($user1); $this->drupalLogout(); diff --git a/core/modules/user/src/Tests/UserLanguageCreationTest.php b/core/modules/user/tests/src/Functional/UserLanguageCreationTest.php similarity index 93% rename from core/modules/user/src/Tests/UserLanguageCreationTest.php rename to core/modules/user/tests/src/Functional/UserLanguageCreationTest.php index 0dd29079ae..997232d9d2 100644 --- a/core/modules/user/src/Tests/UserLanguageCreationTest.php +++ b/core/modules/user/tests/src/Functional/UserLanguageCreationTest.php @@ -1,9 +1,9 @@ assertOptionSelected("edit-preferred-langcode", $langcode, 'Language selector is accessible and correct language is selected.'); // Set pass_raw so we can log in the new user. - $user->pass_raw = $this->randomMachineName(10); + $user->passRaw = $this->randomMachineName(10); $edit = [ - 'pass[pass1]' => $user->pass_raw, - 'pass[pass2]' => $user->pass_raw, + 'pass[pass1]' => $user->passRaw, + 'pass[pass2]' => $user->passRaw, ]; $this->drupalPostForm($user_edit, $edit, t('Save')); diff --git a/core/modules/user/src/Tests/UserLoginTest.php b/core/modules/user/tests/src/Functional/UserLoginTest.php similarity index 93% rename from core/modules/user/src/Tests/UserLoginTest.php rename to core/modules/user/tests/src/Functional/UserLoginTest.php index d92c1c7ae6..3021bc8fbd 100644 --- a/core/modules/user/src/Tests/UserLoginTest.php +++ b/core/modules/user/tests/src/Functional/UserLoginTest.php @@ -1,8 +1,8 @@ drupalCreateUser([]); $this->drupalGet('user/login', ['query' => ['destination' => 'foo']]); - $edit = ['name' => $user->getUserName(), 'pass' => $user->pass_raw]; + $edit = ['name' => $user->getUserName(), 'pass' => $user->passRaw]; $this->drupalPostForm(NULL, $edit, t('Log in')); $this->assertUrl('foo', [], 'Redirected to the correct URL'); } @@ -40,7 +40,7 @@ public function testGlobalLoginFloodControl() { $user1 = $this->drupalCreateUser([]); $incorrect_user1 = clone $user1; - $incorrect_user1->pass_raw .= 'incorrect'; + $incorrect_user1->passRaw .= 'incorrect'; // Try 2 failed logins. for ($i = 0; $i < 2; $i++) { @@ -77,7 +77,7 @@ public function testPerUserLoginFloodControl() { $user1 = $this->drupalCreateUser([]); $incorrect_user1 = clone $user1; - $incorrect_user1->pass_raw .= 'incorrect'; + $incorrect_user1->passRaw .= 'incorrect'; $user2 = $this->drupalCreateUser([]); @@ -117,7 +117,7 @@ public function testPasswordRehashOnLogin() { // Create a new user and authenticate. $account = $this->drupalCreateUser([]); - $password = $account->pass_raw; + $password = $account->passRaw; $this->drupalLogin($account); $this->drupalLogout(); // Load the stored user. The password hash should reflect $default_count_log2. @@ -132,7 +132,7 @@ public function testPasswordRehashOnLogin() { \Drupal::service('module_installer')->install(['user_custom_phpass_params_test']); $this->resetAll(); - $account->pass_raw = $password; + $account->passRaw = $password; $this->drupalLogin($account); // Load the stored user, which should have a different password hash now. $user_storage->resetCache([$account->id()]); @@ -145,7 +145,7 @@ public function testPasswordRehashOnLogin() { * Make an unsuccessful login attempt. * * @param \Drupal\user\Entity\User $account - * A user object with name and pass_raw attributes for the login attempt. + * A user object with name and passRaw attributes for the login attempt. * @param mixed $flood_trigger * (optional) Whether or not to expect that the flood control mechanism * will be triggered. Defaults to NULL. @@ -157,7 +157,7 @@ public function testPasswordRehashOnLogin() { public function assertFailedLogin($account, $flood_trigger = NULL) { $edit = [ 'name' => $account->getUsername(), - 'pass' => $account->pass_raw, + 'pass' => $account->passRaw, ]; $this->drupalPostForm('user/login', $edit, t('Log in')); $this->assertNoFieldByXPath("//input[@name='pass' and @value!='']", NULL, 'Password value attribute is blank.'); diff --git a/core/modules/user/src/Tests/UserPasswordResetTest.php b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php similarity index 99% rename from core/modules/user/src/Tests/UserPasswordResetTest.php rename to core/modules/user/tests/src/Functional/UserPasswordResetTest.php index 528d38bc96..409e418214 100644 --- a/core/modules/user/src/Tests/UserPasswordResetTest.php +++ b/core/modules/user/tests/src/Functional/UserPasswordResetTest.php @@ -1,6 +1,6 @@ drupalGet('admin/people/permissions'); $tabs = $this->xpath('//ul[@class=:classes and //a[contains(., :text)]]', [ ':classes' => 'tabs primary', - ':text' => t('Roles'), + ':text' => 'Roles', ]); $this->assertEqual(count($tabs), 1, 'Found roles tab'); diff --git a/core/modules/user/src/Tests/UserTimeZoneTest.php b/core/modules/user/tests/src/Functional/UserTimeZoneTest.php similarity index 96% rename from core/modules/user/src/Tests/UserTimeZoneTest.php rename to core/modules/user/tests/src/Functional/UserTimeZoneTest.php index 396add4c05..ccf43253de 100644 --- a/core/modules/user/src/Tests/UserTimeZoneTest.php +++ b/core/modules/user/tests/src/Functional/UserTimeZoneTest.php @@ -1,16 +1,16 @@ drupalPlaceBlock('system_breadcrumb_block'); $this->enableViewsTestModule(); diff --git a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php b/core/modules/user/tests/src/Functional/Views/ArgumentDefaultTest.php similarity index 94% rename from core/modules/user/src/Tests/Views/ArgumentDefaultTest.php rename to core/modules/user/tests/src/Functional/Views/ArgumentDefaultTest.php index 7db32373a8..e14948ba26 100644 --- a/core/modules/user/src/Tests/Views/ArgumentDefaultTest.php +++ b/core/modules/user/tests/src/Functional/Views/ArgumentDefaultTest.php @@ -1,6 +1,6 @@ account = $this->drupalCreateUser(); } diff --git a/core/modules/user/src/Tests/Views/BulkFormAccessTest.php b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php similarity index 99% rename from core/modules/user/src/Tests/Views/BulkFormAccessTest.php rename to core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php index 2b36240442..f76b7880b2 100644 --- a/core/modules/user/src/Tests/Views/BulkFormAccessTest.php +++ b/core/modules/user/tests/src/Functional/Views/BulkFormAccessTest.php @@ -1,6 +1,6 @@ enableViewsTestModule(); diff --git a/core/modules/user/src/Tests/Views/HandlerArgumentUserUidTest.php b/core/modules/user/tests/src/Functional/Views/HandlerArgumentUserUidTest.php similarity index 97% rename from core/modules/user/src/Tests/Views/HandlerArgumentUserUidTest.php rename to core/modules/user/tests/src/Functional/Views/HandlerArgumentUserUidTest.php index 73ee53fabb..628150b889 100644 --- a/core/modules/user/src/Tests/Views/HandlerArgumentUserUidTest.php +++ b/core/modules/user/tests/src/Functional/Views/HandlerArgumentUserUidTest.php @@ -1,6 +1,6 @@ 'uid', ]; - protected function setUp() { - parent::setUp(); + protected function setUp($import_test_views = TRUE) { + parent::setUp($import_test_views); ViewTestData::createTestViews(get_class($this), ['user_test_views']); diff --git a/core/modules/user/src/Tests/Views/RelationshipRepresentativeNodeTest.php b/core/modules/user/tests/src/Functional/Views/RelationshipRepresentativeNodeTest.php similarity index 94% rename from core/modules/user/src/Tests/Views/RelationshipRepresentativeNodeTest.php rename to core/modules/user/tests/src/Functional/Views/RelationshipRepresentativeNodeTest.php index 14f44123e3..6af661e665 100644 --- a/core/modules/user/src/Tests/Views/RelationshipRepresentativeNodeTest.php +++ b/core/modules/user/tests/src/Functional/Views/RelationshipRepresentativeNodeTest.php @@ -1,6 +1,6 @@