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
!7058
Draft: [Test only] Validation failing for required untranslatable field
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Draft: [Test only] Validation failing for required untranslatable field
issue/drupal-3223670:3223670-setting-an-untranslatable-test-only
into
11.x
Overview
0
Commits
2
Pipelines
2
Changes
1
Open
Mohit Aghera
requested to merge
issue/drupal-3223670:3223670-setting-an-untranslatable-test-only
into
11.x
1 year ago
Overview
0
Commits
2
Pipelines
2
Changes
1
Expand
Add test cases.
Closes
#3223670
0
0
Merge request reports
Compare
11.x
version 1
91c0f81f
1 year ago
11.x (HEAD)
and
latest version
latest version
c862820f
2 commits,
1 year ago
version 1
91c0f81f
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/content_moderation/tests/src/Functional/ModerationFormTest.php
+
64
−
0
Options
@@ -6,6 +6,8 @@
use
Drupal\Core\Entity\Entity\EntityFormDisplay
;
use
Drupal\Core\Url
;
use
Drupal\field\Entity\FieldConfig
;
use
Drupal\field\Entity\FieldStorageConfig
;
use
Drupal\Tests\content_translation
\Traits\ContentTranslationTestTrait
;
/**
@@ -493,6 +495,68 @@ public function testContentTranslationNodeForm(): void {
],
'Save (this translation)'
);
}
/**
* Tests translated and moderated nodes.
*/
public
function
testContentTranslationNodeFormWithNonRequiredField
():
void
{
$this
->
drupalLogin
(
$this
->
rootUser
);
$fieldName
=
$this
->
randomMachineName
();
FieldStorageConfig
::
create
([
'field_name'
=>
$fieldName
,
'type'
=>
'text'
,
'entity_type'
=>
'node'
,
'cardinality'
=>
1
,
])
->
save
();
FieldConfig
::
create
([
'entity_type'
=>
'node'
,
'field_name'
=>
$fieldName
,
'bundle'
=>
'moderated_content'
,
'label'
=>
'Test field'
,
])
->
setRequired
(
FALSE
)
->
setTranslatable
(
FALSE
)
->
save
();
// Add French language.
static
::
createLanguageFromLangcode
(
'fr'
);
// Enable content translation on moderated_content.
$this
->
enableContentTranslation
(
'node'
,
'moderated_content'
);
// Adding languages requires a container rebuild in the test running
// environment so that multilingual services are used.
$this
->
rebuildContainer
();
// Create new moderated content in draft (revision 1).
$this
->
drupalGet
(
'node/add/moderated_content'
);
$this
->
submitForm
([
'title[0][value]'
=>
'Some moderated content'
,
'body[0][value]'
=>
'First version of the content.'
,
'moderation_state[0][state]'
=>
'published'
,
],
'Save'
);
$node
=
$this
->
drupalGetNodeByTitle
(
'Some moderated content'
);
$translate_path
=
sprintf
(
'node/%d/translations/add/en/fr'
,
$node
->
id
());
// Add French translation.
$this
->
drupalGet
(
$translate_path
);
$this
->
submitForm
([
'body[0][value]'
=>
'Second version of the content FR.'
,
'moderation_state[0][state]'
=>
'published'
,
],
'Save (this translation)'
);
$this
->
drupalGet
(
"/fr/node/
{
$node
->
id
()
}
/edit"
);
$this
->
submitForm
([],
'Save'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
$field
=
FieldConfig
::
load
(
"node.moderated_content.
{
$fieldName
}
"
);
$field
->
setRequired
(
TRUE
);
$field
->
save
();
$this
->
drupalGet
(
"/fr/node/
{
$node
->
id
()
}
/edit"
);
$this
->
submitForm
([],
'Save'
);
$this
->
assertSession
()
->
statusCodeEquals
(
200
);
}
/**
* Tests the moderation_state field when an alternative widget is set.
*/
Loading