Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
layout_builder_styles
Manage
Activity
Members
Labels
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
drupal.org
layout_builder_styles
Commits
954ce9b8
Commit
954ce9b8
authored
2 years ago
by
mark_fullmer
Browse files
Options
Downloads
Patches
Plain Diff
Add test coverage for required group
parent
1544bb11
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
tests/src/Functional/LayoutBuilderStyleGroupTest.php
+36
-1
36 additions, 1 deletion
tests/src/Functional/LayoutBuilderStyleGroupTest.php
with
36 additions
and
1 deletion
tests/src/Functional/LayoutBuilderStyleGroupTest.php
+
36
−
1
View file @
954ce9b8
...
...
@@ -83,6 +83,14 @@ class LayoutBuilderStyleGroupTest extends BrowserTestBase {
'required'
=>
false
,
])
->
save
();
LayoutBuilderStyleGroup
::
create
([
'label'
=>
'Test Required'
,
'id'
=>
'testrequired'
,
'multiselect'
=>
LayoutBuilderStyleGroupInterface
::
TYPE_MULTIPLE
,
'form_type'
=>
LayoutBuilderStyleGroupInterface
::
TYPE_MULTIPLE_SELECT
,
'required'
=>
TRUE
,
])
->
save
();
LayoutBuilderStyleGroup
::
create
([
'label'
=>
'Test Single'
,
'id'
=>
'testsingle'
,
...
...
@@ -124,6 +132,33 @@ class LayoutBuilderStyleGroupTest extends BrowserTestBase {
'group'
=>
'testsingle'
,
])
->
save
();
LayoutBuilderStyle
::
create
([
'id'
=>
'foobar5'
,
'label'
=>
'Foobar5'
,
'classes'
=>
'foo5-style-class'
,
'type'
=>
'section'
,
'group'
=>
'testrequired'
,
])
->
save
();
LayoutBuilderStyle
::
create
([
'id'
=>
'foobar6'
,
'label'
=>
'Foobar6'
,
'classes'
=>
'foo6-style-class'
,
'type'
=>
'section'
,
'group'
=>
'testrequired'
,
])
->
save
();
// Confirm form validation catches if required group is not selected.
$this
->
drupalGet
(
'node/'
.
$section_node
->
id
());
$page
->
clickLink
(
'Layout'
);
$page
->
clickLink
(
'Add section'
);
$page
->
clickLink
(
'Two column'
);
// Verify 'Required' group exists.
$assert_session
->
elementExists
(
'css'
,
'select#edit-layout-builder-style-testrequired option'
);
// Do not make a selection.
$page
->
pressButton
(
'Add section'
);
$assert_session
->
responseContains
(
'Test Required field is required.'
);
// Add section to node with new styles.
$this
->
drupalGet
(
'node/'
.
$section_node
->
id
());
$assert_session
->
responseNotContains
(
'foo-style-class bar-style-class'
);
...
...
@@ -137,6 +172,7 @@ class LayoutBuilderStyleGroupTest extends BrowserTestBase {
$assert_session
->
elementExists
(
'css'
,
'select#edit-layout-builder-style-testmulti option'
);
$page
->
selectFieldOption
(
'edit-layout-builder-style-testmulti'
,
'foobar'
,
TRUE
);
$page
->
selectFieldOption
(
'edit-layout-builder-style-testmulti'
,
'foobar2'
,
TRUE
);
$page
->
selectFieldOption
(
'edit-layout-builder-style-testrequired'
,
'foobar5'
,
TRUE
);
$page
->
pressButton
(
'Add section'
);
// Confirm section element contains the proper classes.
...
...
@@ -156,6 +192,5 @@ class LayoutBuilderStyleGroupTest extends BrowserTestBase {
$assert_session
->
responseContains
(
'foo3-style-class bar3-style-class'
);
$assert_session
->
responseNotContains
(
'foo4-style-class bar4-style-class'
);
// Confirm query fails if required Group is not selected.
}
}
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