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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
drupal
Commits
a85b1ec7
Commit
a85b1ec7
authored
Jul 24, 2018
by
catch
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2987084
by amateescu: Convert EntityReferenceSelectionAccessTest to a kernel test
parent
e8c9956d
No related branches found
No related tags found
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
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
+44
-17
44 additions, 17 deletions
...ReferenceSelection/EntityReferenceSelectionAccessTest.php
with
44 additions
and
17 deletions
core/modules/system/tests/src/Functional/Entity/EntityReferenceSelection/EntityReferenceSelectionAccessTest.php
+
44
−
17
View file @
a85b1ec7
...
@@ -6,9 +6,11 @@
...
@@ -6,9 +6,11 @@
use
Drupal\Component\Utility\Html
;
use
Drupal\Component\Utility\Html
;
use
Drupal\Core\Language\LanguageInterface
;
use
Drupal\Core\Language\LanguageInterface
;
use
Drupal\comment\CommentInterface
;
use
Drupal\comment\CommentInterface
;
use
Drupal\KernelTests\KernelTestBase
;
use
Drupal\node\Entity\Node
;
use
Drupal\node\Entity\Node
;
use
Drupal\Tests\BrowserTestBase
;
use
Drupal\node\NodeInterface
;
use
Drupal\node\NodeInterface
;
use
Drupal\Tests\node\Traits\ContentTypeCreationTrait
;
use
Drupal\Tests\user\Traits\UserCreationTrait
;
use
Drupal\user\Entity\User
;
use
Drupal\user\Entity\User
;
use
Drupal\comment\Entity\Comment
;
use
Drupal\comment\Entity\Comment
;
...
@@ -17,22 +19,46 @@
...
@@ -17,22 +19,46 @@
*
*
* @group entity_reference
* @group entity_reference
*/
*/
class
EntityReferenceSelectionAccessTest
extends
Browser
TestBase
{
class
EntityReferenceSelectionAccessTest
extends
Kernel
TestBase
{
use
CommentTestTrait
;
use
CommentTestTrait
;
use
ContentTypeCreationTrait
;
use
UserCreationTrait
;
/**
/**
* Modules to enable.
* Modules to enable.
*
*
* @var array
* @var array
*/
*/
public
static
$modules
=
[
'
node'
,
'comment
'
];
public
static
$modules
=
[
'
comment'
,
'field'
,
'node'
,
'system'
,
'text'
,
'user
'
];
/**
* {@inheritdoc}
*/
protected
function
setUp
()
{
protected
function
setUp
()
{
parent
::
setUp
();
parent
::
setUp
();
// Create an Article node type.
$this
->
installSchema
(
'system'
,
'sequences'
);
$this
->
drupalCreateContentType
([
'type'
=>
'article'
,
'name'
=>
'Article'
]);
$this
->
installSchema
(
'comment'
,
[
'comment_entity_statistics'
]);
$this
->
installEntitySchema
(
'comment'
);
$this
->
installEntitySchema
(
'node'
);
$this
->
installEntitySchema
(
'user'
);
$this
->
installConfig
([
'comment'
,
'field'
,
'node'
,
'user'
]);
// Create the anonymous and the admin users.
$anonymous_user
=
User
::
create
([
'uid'
=>
0
,
'name'
=>
''
,
]);
$anonymous_user
->
save
();
$admin_user
=
User
::
create
([
'uid'
=>
1
,
'name'
=>
'admin'
,
'status'
=>
1
,
]);
$admin_user
->
save
();
}
}
/**
/**
...
@@ -110,8 +136,8 @@ public function testNodeHandler() {
...
@@ -110,8 +136,8 @@ public function testNodeHandler() {
}
}
// Test as a non-admin.
// Test as a non-admin.
$normal_user
=
$this
->
drupalC
reateUser
([
'access content'
]);
$normal_user
=
$this
->
c
reateUser
([
'access content'
]);
\Drupal
::
currentUser
()
->
setAccount
(
$normal_user
);
$this
->
setCurrentUser
(
$normal_user
);
$referenceable_tests
=
[
$referenceable_tests
=
[
[
[
'arguments'
=>
[
'arguments'
=>
[
...
@@ -162,8 +188,8 @@ public function testNodeHandler() {
...
@@ -162,8 +188,8 @@ public function testNodeHandler() {
$this
->
assertReferenceable
(
$selection_options
,
$referenceable_tests
,
'Node handler'
);
$this
->
assertReferenceable
(
$selection_options
,
$referenceable_tests
,
'Node handler'
);
// Test as an admin.
// Test as an admin.
$admin
_user
=
$this
->
drupalC
reateUser
([
'access content'
,
'bypass node access'
]);
$
content_
admin
=
$this
->
c
reateUser
([
'access content'
,
'bypass node access'
]);
\Drupal
::
currentUser
()
->
setAccount
(
$admin_user
);
$this
->
setCurrentUser
(
$content_admin
);
$referenceable_tests
=
[
$referenceable_tests
=
[
[
[
'arguments'
=>
[
'arguments'
=>
[
...
@@ -239,7 +265,7 @@ public function testUserHandler() {
...
@@ -239,7 +265,7 @@ public function testUserHandler() {
}
}
// Test as a non-admin.
// Test as a non-admin.
\Drupal
::
currentUser
()
->
setAccount
(
$users
[
'non_admin'
]);
$this
->
setCurrentUser
(
$users
[
'non_admin'
]);
$referenceable_tests
=
[
$referenceable_tests
=
[
[
[
'arguments'
=>
[
'arguments'
=>
[
...
@@ -278,7 +304,7 @@ public function testUserHandler() {
...
@@ -278,7 +304,7 @@ public function testUserHandler() {
];
];
$this
->
assertReferenceable
(
$selection_options
,
$referenceable_tests
,
'User handler'
);
$this
->
assertReferenceable
(
$selection_options
,
$referenceable_tests
,
'User handler'
);
\Drupal
::
currentUser
()
->
setAccount
(
$users
[
'admin'
]);
$this
->
setCurrentUser
(
$users
[
'admin'
]);
$referenceable_tests
=
[
$referenceable_tests
=
[
[
[
'arguments'
=>
[
'arguments'
=>
[
...
@@ -361,6 +387,7 @@ public function testCommentHandler() {
...
@@ -361,6 +387,7 @@ public function testCommentHandler() {
];
];
// Build a set of test data.
// Build a set of test data.
$this
->
createContentType
([
'type'
=>
'article'
,
'name'
=>
'Article'
]);
$node_values
=
[
$node_values
=
[
'published'
=>
[
'published'
=>
[
'type'
=>
'article'
,
'type'
=>
'article'
,
...
@@ -431,8 +458,8 @@ public function testCommentHandler() {
...
@@ -431,8 +458,8 @@ public function testCommentHandler() {
}
}
// Test as a non-admin.
// Test as a non-admin.
$normal_user
=
$this
->
drupalC
reateUser
([
'access content'
,
'access comments'
]);
$normal_user
=
$this
->
c
reateUser
([
'access content'
,
'access comments'
]);
\Drupal
::
currentUser
()
->
setAccount
(
$normal_user
);
$this
->
setCurrentUser
(
$normal_user
);
$referenceable_tests
=
[
$referenceable_tests
=
[
[
[
'arguments'
=>
[
'arguments'
=>
[
...
@@ -470,8 +497,8 @@ public function testCommentHandler() {
...
@@ -470,8 +497,8 @@ public function testCommentHandler() {
$this
->
assertReferenceable
(
$selection_options
,
$referenceable_tests
,
'Comment handler'
);
$this
->
assertReferenceable
(
$selection_options
,
$referenceable_tests
,
'Comment handler'
);
// Test as a comment admin.
// Test as a comment admin.
$admin_user
=
$this
->
drupalC
reateUser
([
'access content'
,
'access comments'
,
'administer comments'
]);
$admin_user
=
$this
->
c
reateUser
([
'access content'
,
'access comments'
,
'administer comments'
]);
\Drupal
::
currentUser
()
->
setAccount
(
$admin_user
);
$this
->
setCurrentUser
(
$admin_user
);
$referenceable_tests
=
[
$referenceable_tests
=
[
[
[
'arguments'
=>
[
'arguments'
=>
[
...
@@ -488,8 +515,8 @@ public function testCommentHandler() {
...
@@ -488,8 +515,8 @@ public function testCommentHandler() {
$this
->
assertReferenceable
(
$selection_options
,
$referenceable_tests
,
'Comment handler (comment admin)'
);
$this
->
assertReferenceable
(
$selection_options
,
$referenceable_tests
,
'Comment handler (comment admin)'
);
// Test as a node and comment admin.
// Test as a node and comment admin.
$admin_user
=
$this
->
drupalC
reateUser
([
'access content'
,
'access comments'
,
'administer comments'
,
'bypass node access'
]);
$admin_user
=
$this
->
c
reateUser
([
'access content'
,
'access comments'
,
'administer comments'
,
'bypass node access'
]);
\Drupal
::
currentUser
()
->
setAccount
(
$admin_user
);
$this
->
setCurrentUser
(
$admin_user
);
$referenceable_tests
=
[
$referenceable_tests
=
[
[
[
'arguments'
=>
[
'arguments'
=>
[
...
...
This diff is collapsed.
Click to expand it.
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