Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3425304
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Issue forks
drupal-3425304
Commits
35adb459
Verified
Commit
35adb459
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()
(cherry picked from commit
82ba8f54
)
parent
a55f5739
No related branches found
Branches containing commit
No related tags found
Tags containing commit
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 @
35adb459
<?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.
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