Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scheduler
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
scheduler
Commits
6ba02f7e
Commit
6ba02f7e
authored
3 years ago
by
Jonathan Smith
Committed by
Jonathan Smith
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3224263
by jonathan1055: Simplify FieldsDisplayTest
parent
2bb5e797
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Functional/SchedulerFieldsDisplayTest.php
+11
-37
11 additions, 37 deletions
tests/src/Functional/SchedulerFieldsDisplayTest.php
with
11 additions
and
37 deletions
tests/src/Functional/SchedulerFieldsDisplayTest.php
+
11
−
37
View file @
6ba02f7e
...
...
@@ -12,28 +12,12 @@ use Drupal\Core\Url;
class
SchedulerFieldsDisplayTest
extends
SchedulerBrowserTestBase
{
/**
* Additional module field_ui is required for t
he 'm
anage
f
orm
d
isplay
' test
.
* Additional
core
module field_ui is required for t
estM
anage
F
orm
D
isplay.
*
* @var array
*/
protected
static
$modules
=
[
'field_ui'
];
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
// Give adminUser the permissions to use the field_ui 'manage form display'
// tab for each entity type being tested.
$this
->
addPermissionsToUser
(
$this
->
adminUser
,
[
'administer node form display'
,
'administer media form display'
,
'administer commerce_product form display'
,
'administer taxonomy_term form display'
,
]);
}
/**
* Tests date input is displayed as vertical tab or an expandable fieldset.
*
...
...
@@ -155,6 +139,9 @@ class SchedulerFieldsDisplayTest extends SchedulerBrowserTestBase {
* @dataProvider dataStandardEntityTypes()
*/
public
function
testManageFormDisplay
(
$entityTypeId
,
$bundle
)
{
// Give adminUser the permissions to use the field_ui 'manage form display'
// tab for the entity type being tested.
$this
->
addPermissionsToUser
(
$this
->
adminUser
,
[
"administer
{
$entityTypeId
}
form display"
]);
$this
->
drupalLogin
(
$this
->
adminUser
);
$entityType
=
$this
->
entityTypeObject
(
$entityTypeId
,
$bundle
);
...
...
@@ -182,19 +169,15 @@ class SchedulerFieldsDisplayTest extends SchedulerBrowserTestBase {
* @dataProvider dataStandardEntityTypes()
*/
public
function
testDisabledFields
(
$entityTypeId
,
$bundle
)
{
$this
->
drupalLogin
(
$this
->
adminUser
);
$entityType
=
$this
->
entityTypeObject
(
$entityTypeId
,
$bundle
);
$this
->
drupalLogin
(
$this
->
schedulerUser
);
/** @var \Drupal\Tests\WebAssert $assert */
$assert
=
$this
->
assertSession
();
// 1. Set the publish_on field to 'hidden' in the entity edit form.
$edit
=
[
'fields[publish_on][region]'
=>
'hidden'
,
];
$form_display_url
=
Url
::
fromRoute
(
"entity.entity_form_display.
{
$entityTypeId
}
.default"
,
[
$entityType
->
getEntityTypeId
()
=>
$bundle
]);
$this
->
drupalGet
(
$form_display_url
);
$this
->
submitForm
(
$edit
,
'Save'
);
$formDisplay
=
$this
->
container
->
get
(
'entity_display.repository'
)
->
getFormDisplay
(
$entityTypeId
,
$bundle
);
$publish_on_component
=
$formDisplay
->
getComponent
(
'publish_on'
);
$formDisplay
->
removeComponent
(
'publish_on'
)
->
save
();
// Check that the scheduler details element is shown and that the
// unpublish_on field is shown, but the publish_on field is not shown.
...
...
@@ -205,12 +188,8 @@ class SchedulerFieldsDisplayTest extends SchedulerBrowserTestBase {
$this
->
assertSession
()
->
FieldExists
(
'unpublish_on[0][value][date]'
);
// 2. Set publish_on to be displayed but hide the unpublish_on field.
$edit
=
[
'fields[publish_on][region]'
=>
'content'
,
'fields[unpublish_on][region]'
=>
'hidden'
,
];
$this
->
drupalGet
(
$form_display_url
);
$this
->
submitForm
(
$edit
,
'Save'
);
$formDisplay
->
setComponent
(
'publish_on'
,
$publish_on_component
)
->
removeComponent
(
'unpublish_on'
)
->
save
();
// Check that the scheduler details element is shown and that the
// publish_on field is shown, but the unpublish_on field is not shown.
...
...
@@ -220,12 +199,7 @@ class SchedulerFieldsDisplayTest extends SchedulerBrowserTestBase {
$this
->
assertSession
()
->
FieldNotExists
(
'unpublish_on[0][value][date]'
);
// 3. Set both fields to be hidden.
$edit
=
[
'fields[publish_on][region]'
=>
'hidden'
,
'fields[unpublish_on][region]'
=>
'hidden'
,
];
$this
->
drupalGet
(
$form_display_url
);
$this
->
submitForm
(
$edit
,
'Save'
);
$formDisplay
->
removeComponent
(
'publish_on'
)
->
save
();
// Check that the scheduler details element is not shown when both of the
// date fields are set to be hidden.
...
...
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