Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
f2aeaaa1
Unverified
Commit
f2aeaaa1
authored
5 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2079647
by claudiu.cristea: Convert UserSaveTest to a kernel test. Remove useless test
parent
9a4a499f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/user/tests/src/Kernel/UserSaveTest.php
+39
-0
39 additions, 0 deletions
core/modules/user/tests/src/Kernel/UserSaveTest.php
with
39 additions
and
0 deletions
core/modules/user/tests/src/
Functiona
l/UserSaveTest.php
→
core/modules/user/tests/src/
Kerne
l/UserSaveTest.php
+
39
−
0
View file @
f2aeaaa1
<?php
namespace
Drupal\Tests\user\
Functiona
l
;
namespace
Drupal\Tests\user\
Kerne
l
;
use
Drupal\
Tests\Browser
TestBase
;
use
Drupal\
KernelTests\Kernel
TestBase
;
use
Drupal\user\Entity\User
;
/**
...
...
@@ -10,45 +10,23 @@
*
* @group user
*/
class
UserSaveTest
extends
Browser
TestBase
{
class
UserSaveTest
extends
Kernel
TestBase
{
/**
*
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
();
...
...
This diff is collapsed.
Click to expand it.
Alex Pott
@alexpott
mentioned in commit
8f85b859
·
5 years ago
mentioned in commit
8f85b859
mentioned in commit 8f85b859dc97de8eba00fe8e0dab1ea580024379
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment