Skip to content
Snippets Groups Projects
Unverified Commit f2aeaaa1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2079647 by claudiu.cristea: Convert UserSaveTest to a kernel test. Remove useless test

parent 9a4a499f
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
<?php
namespace Drupal\Tests\user\Functional;
namespace Drupal\Tests\user\Kernel;
use Drupal\Tests\BrowserTestBase;
use Drupal\KernelTests\KernelTestBase;
use Drupal\user\Entity\User;
/**
......@@ -10,45 +10,23 @@
*
* @group user
*/
class UserSaveTest extends BrowserTestBase {
class UserSaveTest extends KernelTestBase {
/**
* Test creating a user with arbitrary uid.
* {@inheritdoc}
*/
public function testUserImport() {
// User ID must be a number that is not in the database.
$uids = \Drupal::entityManager()->getStorage('user')->getQuery()
->sort('uid', 'DESC')
->range(0, 1)
->execute();
$max_uid = reset($uids);
$test_uid = $max_uid + mt_rand(1000, 1000000);
$test_name = $this->randomMachineName();
// Create the base user, based on drupalCreateUser().
$user = User::create([
'name' => $test_name,
'uid' => $test_uid,
'mail' => $test_name . '@example.com',
'pass' => user_password(),
'status' => 1,
]);
$user->enforceIsNew();
$user->save();
// Test if created user exists.
$user_by_uid = User::load($test_uid);
$this->assertTrue($user_by_uid, 'Loading user by uid.');
$user_by_name = user_load_by_name($test_name);
$this->assertTrue($user_by_name, 'Loading user by name.');
}
protected static $modules = [
'system',
'user',
];
/**
* Ensures that an existing password is unset after the user was saved.
*/
public function testExistingPasswordRemoval() {
$this->installSchema('system', ['sequences']);
$this->installEntitySchema('user');
/** @var \Drupal\user\Entity\User $user */
$user = User::create(['name' => $this->randomMachineName()]);
$user->save();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment