diff --git a/core/modules/user/src/Tests/UserSubAdminTest.php b/core/modules/user/tests/src/Functional/UserSubAdminTest.php similarity index 53% rename from core/modules/user/src/Tests/UserSubAdminTest.php rename to core/modules/user/tests/src/Functional/UserSubAdminTest.php index 1102a32524f7eaa2491a0e48f395a5febed46d21..9b8e6daa134463cfdf5c546d4f08a853c4745a06 100644 --- a/core/modules/user/src/Tests/UserSubAdminTest.php +++ b/core/modules/user/tests/src/Functional/UserSubAdminTest.php @@ -1,20 +1,18 @@ drupalGet('admin/people/create'); - $this->assertField("edit-name", "Name field exists."); - $this->assertField("edit-notify", "Notify field exists."); + $this->assertSession()->fieldExists("edit-name"); + $this->assertSession()->fieldExists("edit-notify"); // Not 'status' or 'roles' as they require extra permission. - $this->assertNoField("edit-status-0", "Status field missing."); - $this->assertNoField("edit-role", "Role field missing."); + $this->assertSession()->fieldNotExists("edit-status-0"); + $this->assertSession()->fieldNotExists("edit-role"); // Test that create user gives an admin style message. $edit = [ @@ -42,25 +40,25 @@ public function testSubAdmin() { 'pass[pass2]' => $pass, 'notify' => FALSE, ]; - $this->drupalPostForm('admin/people/create', $edit, t('Create new account')); - $this->assertText(t('Created a new user account for @name. No email has been sent.', ['@name' => $edit['name']]), 'User created'); + $this->drupalPostForm('admin/people/create', $edit, 'Create new account'); + $this->assertSession()->pageTextContains('Created a new user account for ' . $edit['name'] . '. No email has been sent.'); // Test that the cancel user page has admin fields. $cancel_user = $this->createUser(); $this->drupalGet('user/' . $cancel_user->id() . '/cancel'); - $this->assertRaw(t('Are you sure you want to cancel the account %name?', ['%name' => $cancel_user->getUsername()]), 'Confirmation form to cancel account displayed.'); - $this->assertRaw(t('Disable the account and keep its content.') . ' ' . t('This action cannot be undone.'), 'Cannot select account cancellation method.'); + $this->assertSession()->responseContains('Are you sure you want to cancel the account ' . $cancel_user->getUsername() . '?'); + $this->assertSession()->responseContains('Disable the account and keep its content. This action cannot be undone.'); // Test that cancel confirmation gives an admin style message. $this->drupalPostForm(NULL, NULL, t('Cancel account')); - $this->assertRaw(t('%name has been disabled.', ['%name' => $cancel_user->getUsername()]), "Confirmation message displayed to user."); + $this->assertSession()->pageTextContains($cancel_user->getUsername() . ' has been disabled.'); // Repeat with permission to select account cancellation method. $user->addRole($this->drupalCreateRole(['select account cancellation method'])); $user->save(); $cancel_user = $this->createUser(); $this->drupalGet('user/' . $cancel_user->id() . '/cancel'); - $this->assertText(t('Select the method to cancel the account above.'), 'Allows to select account cancellation method.'); + $this->assertSession()->pageTextContains('Select the method to cancel the account above.'); } }