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
82ba8f54
Verified
Commit
82ba8f54
authored
1 year ago
by
Alex Pott
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3341438
by DanielVeza, andypost: Add test coverage for layout_builder_entity_view_alter()
parent
589b8fe8
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/layout_builder/tests/src/Kernel/EntityViewAlterTest.php
+64
-0
64 additions, 0 deletions
...s/layout_builder/tests/src/Kernel/EntityViewAlterTest.php
with
64 additions
and
0 deletions
core/modules/layout_builder/tests/src/Kernel/EntityViewAlterTest.php
0 → 100644
+
64
−
0
View file @
82ba8f54
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\Tests\layout_builder\Kernel
;
use
Drupal\Core\Routing\RouteObjectInterface
;
use
Drupal\entity_test
\Entity\EntityTest
;
use
Drupal\KernelTests\KernelTestBase
;
use
Drupal\layout_builder
\Entity\LayoutBuilderEntityViewDisplay
;
use
Symfony\Component\HttpFoundation\Request
;
use
Symfony\Component\HttpFoundation\Session\Session
;
use
Symfony\Component\HttpFoundation\Session\Storage\MockArraySessionStorage
;
use
Symfony\Component\Routing\Route
;
/**
* @covers layout_builder_entity_view_alter
*
* @group layout_builder
*/
class
EntityViewAlterTest
extends
KernelTestBase
{
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'layout_discovery'
,
'layout_builder'
,
'layout_builder_defaults_test'
,
'entity_test'
,
'user'
,
];
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
entity_test_create_bundle
(
'bundle_with_extra_fields'
);
$this
->
installEntitySchema
(
'entity_test'
);
$this
->
installConfig
([
'layout_builder_defaults_test'
]);
}
/**
* Tests that contextual links are removed when rendering Layout Builder.
*/
public
function
testContextualLinksRemoved
():
void
{
$display
=
LayoutBuilderEntityViewDisplay
::
load
(
'entity_test.bundle_with_extra_fields.default'
);
$entity
=
EntityTest
::
create
();
$build
=
[
'#contextual_links'
=>
[
'entity.node.canonical'
],
];
// Create a fake request that starts with layout_builder.
$request
=
Request
::
create
(
'<front>'
);
$request
->
attributes
->
set
(
RouteObjectInterface
::
ROUTE_NAME
,
'layout_builder.test'
);
$request
->
attributes
->
set
(
RouteObjectInterface
::
ROUTE_OBJECT
,
new
Route
(
'/'
));
$request
->
setSession
(
new
Session
(
new
MockArraySessionStorage
()));
\Drupal
::
requestStack
()
->
push
(
$request
);
// Assert the contextual links are removed.
layout_builder_entity_view_alter
(
$build
,
$entity
,
$display
);
$this
->
assertArrayNotHasKey
(
'#contextual_links'
,
$build
);
}
}
This diff is collapsed.
Click to expand it.
Alex Pott
@alexpott
mentioned in commit
35adb459
·
1 year ago
mentioned in commit
35adb459
mentioned in commit 35adb459bcb0dc2ed915956d53f9459bb8d1b9de
Toggle commit list
Alex Pott
@alexpott
mentioned in commit
893c57fe
·
1 year ago
mentioned in commit
893c57fe
mentioned in commit 893c57fe9af94326f2c574e8fcdf3a280376daa5
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