Problem/Motivation
The test ConfigPageTest::testRequireOnPublishEnable() fails to verify that the require_on_publish setting is saved correctly, due to two related issues:
- The
field_tagsfield is created without specifying a required Vocabulary bundle. This causes a form validation error ("Vocabulary field is required.") that prevents the form from being submitted. - Despite the failed submission, the test attempts to verify the setting using:
$required = $this->getSession()->getPage()->findField('require_on_publish')->getValue(); $this->assertEquals(1, $required);
In Drupal 10, this check still passed—likely because the field value persisted in the form even after the validation error. However, in Drupal 11, this assertion fails. The test environment no longer retains the field value after validation fails, resulting in a null or incorrect value, and causing the assertion to break.
Steps to reproduce
- Run `ConfigPageTest::testRequireOnPublishEnable()` in a Drupal 11 environment.
- Observe test failure with:
WebDriver\Exception\StaleElementReference: stale element reference: element is not attached to the page document - Investigate the form and discover the unconfigured required Vocabulary caused the form to never successfully submit.
- Note that in Drupal 10, the form value was still accessible despite the failed submission; this behavior no longer holds in Drupal 11.
Proposed resolution
- Fix the test setup by creating a Vocabulary and assigning it when adding the
field_tagsfield to thearticlecontent type. This allows the form to submit successfully. - Fix the verification step by reloading the
FieldConfigentity after form submission and asserting the setting directly:
$field_config = FieldConfig::load('node.article.field_tags');
$this->assertTrue($field_config->getThirdPartySetting('require_on_publish', 'require_on_publish', FALSE));
This ensures the test reliably verifies persisted configuration rather than transient UI state.
Issue fork require_on_publish-3538810
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
jcandan commentedComment #4
jcandan commented