function AdminNodeTest::testPublishedCheckboxOnTreedForm
Same name and namespace in other branches
- 11.x core/themes/default_admin/tests/src/Functional/AdminNodeTest.php \Drupal\Tests\default_admin\Functional\AdminNodeTest::testPublishedCheckboxOnTreedForm()
Tests the published checkbox on an entity form that sets #tree.
The theme copies the footer into its sidebar, and a group is identified by its #parents, so without pinning them the copy registers under a different name on a treed form. The checkbox would then render nowhere while still being processed on submit, which unpublishes the entity on save.
File
-
core/
themes/ default_admin/ tests/ src/ Functional/ AdminNodeTest.php, line 60
Class
- AdminNodeTest
- Tests Default Admin theme for nodes.
Namespace
Drupal\Tests\default_admin\FunctionalCode
public function testPublishedCheckboxOnTreedForm() : void {
$node = $this->drupalCreateNode([
'type' => 'page',
'status' => TRUE,
]);
$this->drupalGet($node->toUrl('edit-form'));
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->fieldExists('status[value]');
$this->assertSession()
->checkboxChecked('status[value]');
$this->submitForm([], 'Save');
$node = $this->container
->get('entity_type.manager')
->getStorage('node')
->loadUnchanged($node->id());
$this->assertTrue($node->isPublished());
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.