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
!4324
Issue
#3368656
: Add 'Layout' Operation Link to entities
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Issue
#3368656
: Add 'Layout' Operation Link to entities
issue/drupal-3368656:3368656-add-layout-operation
into
11.x
Overview
11
Commits
5
Pipelines
0
Changes
4
6 unresolved threads
Hide all comments
Open
Chris Burge
requested to merge
issue/drupal-3368656:3368656-add-layout-operation
into
11.x
1 year ago
Overview
11
Commits
5
Pipelines
0
Changes
4
6 unresolved threads
Hide all comments
Expand
0
0
Merge request reports
Compare
11.x
version 1
a9ca1c8a
1 year ago
11.x (base)
and
latest version
latest version
e4b24703
5 commits,
1 year ago
version 1
a9ca1c8a
1 commit,
1 year ago
4 files
+
295
−
9
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
4
Search (e.g. *.vue) (Ctrl+P)
core/modules/layout_builder/tests/src/Functional/OperationLinkTest.php
0 → 100644
+
221
−
0
Options
<?php
namespace
Drupal\Tests\layout_builder\Functional
;
use
Drupal\Core\Entity\Entity\EntityViewDisplay
;
use
Drupal\language\Entity\ConfigurableLanguage
;
use
Drupal\layout_builder
\Entity\LayoutBuilderEntityViewDisplay
;
use
Drupal\layout_builder
\Plugin\SectionStorage\OverridesSectionStorage
;
use
Drupal\Tests\BrowserTestBase
;
use
Drupal\Tests\taxonomy\Traits\TaxonomyTestTrait
;
use
Drupal\user\Entity\Role
;
/**
* Tests Layout Builder Operation Link.
*
* @group layout_builder
*/
class
OperationLinkTest
extends
BrowserTestBase
{
use
TaxonomyTestTrait
;
/**
* {@inheritdoc}
*/
protected
$defaultTheme
=
'stark'
;
/**
* {@inheritdoc}
*/
protected
static
$modules
=
[
'field_ui'
,
'layout_builder'
,
'node'
,
'taxonomy'
,
'views'
,
];
/**
* A non-Layout Builder enabled node.
*
* @var \Drupal\node\NodeInterface
*/
protected
$pageNode
;
/**
* A Layout Builder enabled node.
*
* @var \Drupal\node\NodeInterface
*/
protected
$layoutBuilderNode
;
/**
* A user with Layout Builder permissions.
*
* @var \Drupal\user\UserInterface
*/
protected
$layoutUser
;
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
// Create user with Layout Builder permissions.
$this
->
layoutUser
=
$this
->
drupalCreateUser
([
'access administration pages'
,
'access content overview'
,
'access taxonomy overview'
,
'administer node display'
,
'administer node fields'
,
'administer taxonomy'
,
'administer taxonomy_term display'
,
'administer taxonomy_term fields'
,
'bypass node access'
,
'configure any layout'
,
]);
$this
->
drupalLogin
(
$this
->
layoutUser
);
// Create content types.
$this
->
createContentType
([
'type'
=>
'page'
]);
$this
->
createContentType
([
'type'
=>
'bundle_with_section_field'
]);
// Enable Layout Builder w/ overrides for bundle_with_section_field bundle.
LayoutBuilderEntityViewDisplay
::
load
(
'node.bundle_with_section_field.default'
)
->
enableLayoutBuilder
()
->
setOverridable
()
->
save
();
// Create nodes.
$this
->
pageNode
=
$this
->
createNode
([
'type'
=>
'page'
,
]);
$this
->
layoutBuilderNode
=
$this
->
createNode
([
'type'
=>
'bundle_with_section_field'
,
]);
}
/**
* Tests Layout Builder Operation Link.
*/
public
function
testOperationLink
()
{
$assert_session
=
$this
->
assertSession
();
// Check for Layout operation link with user with Layout Builder
// permissions.
$this
->
drupalGet
(
'/admin/content'
);
$assert_session
->
elementNotExists
(
'xpath'
,
'//table//ul[contains(@class, "dropbutton")]//a[contains(@href, "node/'
.
$this
->
pageNode
->
id
()
.
'/layout")]'
);
$assert_session
->
elementExists
(
'xpath'
,
'//table//ul[contains(@class, "dropbutton")]//a[contains(@href, "node/'
.
$this
->
layoutBuilderNode
->
id
()
.
'/layout")]'
);
// Create taxonomy vocabularies.
$vocabulary
=
$this
->
createVocabulary
();
$vocabulary_with_section_field
=
$this
->
createVocabulary
();
// Create terms.
$termNoLayoutBuilder
=
$this
->
createTerm
(
$vocabulary
);
$termWithLayoutBuilder
=
$this
->
createTerm
(
$vocabulary_with_section_field
);
$vocabulary_id
=
$vocabulary
->
id
();
$vocabulary_with_section_field_id
=
$vocabulary_with_section_field
->
id
();
// Enable Layout Builder w/ overrides for vocabulary_with_section_field_id
// bundle.
EntityViewDisplay
::
create
([
'targetEntityType'
=>
'taxonomy_term'
,
'bundle'
=>
$vocabulary_with_section_field_id
,
'mode'
=>
'default'
,
'status'
=>
TRUE
,
])
->
save
();
LayoutBuilderEntityViewDisplay
::
load
(
"taxonomy_term.
$vocabulary_with_section_field_id
.default"
)
->
enableLayoutBuilder
()
->
setOverridable
()
->
save
();
$this
->
drupalGet
(
"admin/structure/taxonomy/manage/
$vocabulary_id
/overview/"
);
$assert_session
->
elementNotExists
(
'xpath'
,
'//table//ul[contains(@class, "dropbutton")]//a[contains(@href, "term/'
.
$termNoLayoutBuilder
->
id
()
.
'/layout")]'
);
$this
->
drupalGet
(
"admin/structure/taxonomy/manage/
$vocabulary_with_section_field_id
/overview/"
);
$assert_session
->
elementExists
(
'xpath'
,
'//table//ul[contains(@class, "dropbutton")]//a[contains(@href, "term/'
.
$termWithLayoutBuilder
->
id
()
.
'/layout")]'
);
// Check for Layout operation link with user without Layout Builder
// permissions.
// Create user without Layout Builder permissions.
$auth_user
=
$this
->
drupalCreateUser
([
'access administration pages'
,
'access content overview'
,
'access taxonomy overview'
,
'administer taxonomy'
,
'bypass node access'
,
]);
$this
->
drupalLogin
(
$auth_user
);
$this
->
drupalGet
(
'/admin/content'
);
$assert_session
->
elementNotExists
(
'xpath'
,
'//table//ul[contains(@class, "dropbutton")]//a[contains(@href, "node/'
.
$this
->
layoutBuilderNode
->
id
()
.
'/layout")]'
);
$this
->
drupalGet
(
"admin/structure/taxonomy/manage/
$vocabulary_id
/overview/"
);
$assert_session
->
elementNotExists
(
'xpath'
,
'//table//ul[contains(@class, "dropbutton")]//a[contains(@href, "term/'
.
$termNoLayoutBuilder
->
id
()
.
'/layout")]'
);
$this
->
drupalGet
(
"admin/structure/taxonomy/manage/
$vocabulary_with_section_field_id
/overview/"
);
$assert_session
->
elementNotExists
(
'xpath'
,
'//table//ul[contains(@class, "dropbutton")]//a[contains(@href, "term/'
.
$termWithLayoutBuilder
->
id
()
.
'/layout")]'
);
}
/**
* Tests language support.
*/
public
function
testLanguage
()
{
// Rewrite test without dependency on contrib module.
// Skip the test in the meantime (without failing PHPCS).
if
(
TRUE
)
{
return
;
}
$assert_session
=
$this
->
assertSession
();
\Drupal
::
service
(
'module_installer'
)
->
install
([
'content_translation'
,
'language'
,
'layout_builder_at'
,
]);
Role
::
Load
(
$this
->
layoutUser
->
getRoles
(
TRUE
)[
0
])
->
grantPermission
(
'administer content translation'
)
->
grantPermission
(
'administer languages'
)
->
grantPermission
(
'translate any entity'
)
->
save
();
$additional_langcode
=
'es'
;
// Enable additional language.
ConfigurableLanguage
::
createFromLangcode
(
$additional_langcode
)
->
save
();
// Enable translation for bundle_with_section_field bundle and ensure the
// change is picked up.
\Drupal
::
service
(
'content_translation.manager'
)
->
setEnabled
(
'node'
,
'bundle_with_section_field'
,
TRUE
);
// Create a translation through the UI.
$url_options
=
[
'language'
=>
\Drupal
::
languageManager
()
->
getLanguage
(
$additional_langcode
)];
$this
->
drupalGet
(
'node/'
.
$this
->
layoutBuilderNode
->
id
()
.
'/translations/add/en/'
.
$additional_langcode
,
$url_options
);
$this
->
getSession
()
->
getPage
()
->
pressButton
(
'Save (this translation)'
);
// Make layout builder field translatable.
$this
->
drupalGet
(
'admin/config/regional/content-language'
);
$edit
=
[
'entity_types[node]'
=>
TRUE
,
'settings[node][bundle_with_section_field][fields]['
.
OverridesSectionStorage
::
FIELD_NAME
.
']'
=>
TRUE
,
];
$this
->
submitForm
(
$edit
,
'Save configuration'
);
$this
->
drupalGet
(
'/admin/content'
);
$assert_session
->
elementExists
(
'xpath'
,
'//table//ul[contains(@class, "dropbutton")]//a[contains(@href, "'
.
$additional_langcode
.
'/node/2/layout")]'
);
}
}
Loading