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
48522ffe
Unverified
Commit
48522ffe
authored
5 years ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3041036
by claudiu.cristea: Convert UserDeleteTest to kernel test (or get rid of it?)
parent
d8a7ce2f
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/UserDeleteTest.php
+28
-13
28 additions, 13 deletions
core/modules/user/tests/src/Kernel/UserDeleteTest.php
with
28 additions
and
13 deletions
core/modules/user/tests/src/
Functiona
l/UserDeleteTest.php
→
core/modules/user/tests/src/
Kerne
l/UserDeleteTest.php
+
28
−
13
View file @
48522ffe
<?php
namespace
Drupal\Tests\user\
Functiona
l
;
namespace
Drupal\Tests\user\
Kerne
l
;
use
Drupal\Core\Database\Database
;
use
Drupal\Tests\BrowserTestBase
;
use
Drupal\KernelTests\KernelTestBase
;
use
Drupal\Tests\user\Traits\UserCreationTrait
;
use
Drupal\user\Entity\User
;
/**
* Tests
account
deleting of users.
* Tests deleting of user
account
s.
*
* @group user
*/
class
UserDeleteTest
extends
BrowserTestBase
{
class
UserDeleteTest
extends
KernelTestBase
{
use
UserCreationTrait
;
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'system'
,
'user'
,
];
/**
* Test deleting multiple users.
*/
public
function
testUserDeleteMultiple
()
{
$this
->
installSchema
(
'system'
,
[
'sequences'
]);
$this
->
installSchema
(
'user'
,
[
'users_data'
]);
$this
->
installEntitySchema
(
'user'
);
// Create a few users with permissions, so roles will be created.
$user_a
=
$this
->
drupalC
reateUser
([
'access user profiles'
]);
$user_b
=
$this
->
drupalC
reateUser
([
'access user profiles'
]);
$user_c
=
$this
->
drupalC
reateUser
([
'access user profiles'
]);
$user_a
=
$this
->
c
reateUser
([
'access user profiles'
]);
$user_b
=
$this
->
c
reateUser
([
'access user profiles'
]);
$user_c
=
$this
->
c
reateUser
([
'access user profiles'
]);
$uids
=
[
$user_a
->
id
(),
$user_b
->
id
(),
$user_c
->
id
()];
...
...
@@ -34,9 +49,9 @@ public function testUserDeleteMultiple() {
->
execute
()
->
fetchField
();
$this
->
assert
True
(
$roles_created
>
0
,
'R
ole
assignments created for new users and deletion of role assignments can be tested'
);
$this
->
assert
GreaterThan
(
0
,
$r
ole
s_created
);
// We should be able to load one of the users.
$this
->
assert
True
(
User
::
load
(
$user_a
->
id
())
,
'User is created and deletion of user can be tested'
);
$this
->
assert
NotNull
(
User
::
load
(
$user_a
->
id
()));
// Delete the users.
user_delete_multiple
(
$uids
);
// Test if the roles assignments are deleted.
...
...
@@ -47,11 +62,11 @@ public function testUserDeleteMultiple() {
->
countQuery
()
->
execute
()
->
fetchField
();
$this
->
assert
True
(
$roles_after_deletion
==
0
,
'Role assignments deleted along with users'
);
$this
->
assert
Equals
(
0
,
$roles_after_deletion
);
// Test if the users are deleted, User::load() will return NULL.
$this
->
assertNull
(
User
::
load
(
$user_a
->
id
())
,
format_string
(
'User with id @uid deleted.'
,
[
'@uid'
=>
$user_a
->
id
()])
);
$this
->
assertNull
(
User
::
load
(
$user_b
->
id
())
,
format_string
(
'User with id @uid deleted.'
,
[
'@uid'
=>
$user_b
->
id
()])
);
$this
->
assertNull
(
User
::
load
(
$user_c
->
id
())
,
format_string
(
'User with id @uid deleted.'
,
[
'@uid'
=>
$user_c
->
id
()])
);
$this
->
assertNull
(
User
::
load
(
$user_a
->
id
()));
$this
->
assertNull
(
User
::
load
(
$user_b
->
id
()));
$this
->
assertNull
(
User
::
load
(
$user_c
->
id
()));
}
}
This diff is collapsed.
Click to expand it.
Alex Pott
@alexpott
mentioned in commit
1a6a8cf1
·
5 years ago
mentioned in commit
1a6a8cf1
mentioned in commit 1a6a8cf1e0dc9bd9673cbe7ad69145786e92f432
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