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
Merge requests
!6685
[
#3341438
] - Add additional test coverage for layout_builder_entity_view_alter
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
[
#3341438
] - Add additional test coverage for layout_builder_entity_view_alter
issue/drupal-3341438:3341438-add-test-coverage
into
11.x
Overview
0
Commits
2
Pipelines
2
Changes
1
Closed
danielveza
requested to merge
issue/drupal-3341438:3341438-add-test-coverage
into
11.x
1 year ago
Overview
0
Commits
2
Pipelines
2
Changes
1
Expand
Closes
#3341438
0
0
Merge request reports
Compare
11.x
version 1
c67ed204
1 year ago
11.x (base)
and
latest version
latest version
7d9cd356
2 commits,
1 year ago
version 1
c67ed204
1 commit,
1 year ago
1 file
+
64
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
core/modules/layout_builder/tests/src/Kernel/EntityViewAlterTest.php
0 → 100644
+
64
−
0
Options
<?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
);
}
}
Loading