Commit 66f5091a authored by alexpott's avatar alexpott

Issue #2887869 by navneet0693, ApacheEx, Lendude, Dinesh18, dawehner,...

Issue #2887869 by navneet0693, ApacheEx, Lendude, Dinesh18, dawehner, naveenvalecha, borisson_: Convert web tests to browser tests for user module part-2
parent 4cafe992
......@@ -2,10 +2,17 @@
namespace Drupal\user\Tests;
@trigger_error(__NAMESPACE__ . '\UserResetEmailTestTrait is deprecated and scheduled for removal before Drupal 9.0.0. Add the method to the test class instead, see https://www.drupal.org/node/2999766', E_USER_DEPRECATED);
use Drupal\Core\Test\AssertMailTrait;
/**
* Helper function for logging in from reset password email.
*
* @deprecated Scheduled for removal before Drupal 9.0.0.
* Add the method to the test class instead.
*
* @see https://www.drupal.org/node/2999766
*/
trait UserResetEmailTestTrait {
......
<?php
namespace Drupal\user\Tests;
namespace Drupal\Tests\user\Functional;
use Drupal\Core\Language\LanguageInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests users' ability to change their own administration language.
*
* @group user
*/
class UserAdminLanguageTest extends WebTestBase {
class UserAdminLanguageTest extends BrowserTestBase {
/**
* A user with permission to access admin pages and administer languages.
......
<?php
namespace Drupal\user\Tests;
namespace Drupal\Tests\user\Functional;
use Drupal\Core\Database\Database;
use Drupal\dynamic_page_cache\EventSubscriber\DynamicPageCacheSubscriber;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests user blocks.
*
* @group user
*/
class UserBlocksTest extends WebTestBase {
class UserBlocksTest extends BrowserTestBase {
/**
* Modules to enable.
......@@ -70,7 +70,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.');
......
<?php
namespace Drupal\user\Tests;
namespace Drupal\Tests\user\Functional;
use Drupal\Core\Test\AssertMailTrait;
use Drupal\field\Entity\FieldConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the create user administration page.
*
* @group user
*/
class UserCreateTest extends WebTestBase {
class UserCreateTest extends BrowserTestBase {
use AssertMailTrait {
getMails as drupalGetMails;
}
/**
* Modules to enable.
......@@ -109,7 +114,7 @@ public function testUserAdd() {
$this->drupalGet('admin/people');
$this->assertText($edit['name'], 'User found in list of users');
$user = user_load_by_name($name);
$this->assertEqual($user->isActive(), 'User is not blocked');
$this->assertTrue($user->isActive(), 'User is not blocked');
}
// Test that the password '0' is considered a password.
......
......@@ -3,10 +3,10 @@
namespace Drupal\Tests\user\Functional;
use Drupal\Core\Flood\DatabaseBackend;
use Drupal\Core\Test\AssertMailTrait;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
use Drupal\user\Controller\UserAuthenticationController;
use Drupal\user\Tests\UserResetEmailTestTrait;
use GuzzleHttp\Cookie\CookieJar;
use Psr\Http\Message\ResponseInterface;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
......@@ -21,7 +21,9 @@
*/
class UserLoginHttpTest extends BrowserTestBase {
use UserResetEmailTestTrait;
use AssertMailTrait {
getMails as drupalGetMails;
}
/**
* Modules to install.
......@@ -526,4 +528,17 @@ protected function doTestPasswordReset($format, $account) {
$this->drupalLogout();
}
/**
* Login from reset password email.
*/
protected function loginFromResetEmail() {
$_emails = $this->drupalGetMails();
$email = end($_emails);
$urls = [];
preg_match('#.+user/reset/.+#', $email['body'], $urls);
$resetURL = $urls[0];
$this->drupalGet($resetURL);
$this->drupalPostForm(NULL, NULL, 'Log in');
}
}
<?php
namespace Drupal\user\Tests;
namespace Drupal\Tests\user\Functional;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests registration of user under different configurations.
*
* @group user
*/
class UserRegistrationTest extends WebTestBase {
class UserRegistrationTest extends BrowserTestBase {
/**
* Modules to enable.
......
<?php
namespace Drupal\user\Tests;
namespace Drupal\Tests\user\Kernel;
use Drupal\KernelTests\ConfigFormTestBase;
use Drupal\user\AccountSettingsForm;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment