function NodeEditFormTest::testNodeMetaInformation
Same name and namespace in other branches
- 9 core/modules/node/tests/src/Functional/NodeEditFormTest.php \Drupal\Tests\node\Functional\NodeEditFormTest::testNodeMetaInformation()
- 8.9.x core/modules/node/tests/src/Functional/NodeEditFormTest.php \Drupal\Tests\node\Functional\NodeEditFormTest::testNodeMetaInformation()
- 10 core/modules/node/tests/src/Functional/NodeEditFormTest.php \Drupal\Tests\node\Functional\NodeEditFormTest::testNodeMetaInformation()
Tests the node meta information.
File
-
core/
modules/ node/ tests/ src/ Functional/ NodeEditFormTest.php, line 226
Class
- NodeEditFormTest
- Create a node and test node edit functionality.
Namespace
Drupal\Tests\node\FunctionalCode
public function testNodeMetaInformation() : void {
// Check that regular users (i.e. without the 'administer nodes' permission)
// can not see the meta information.
$this->drupalLogin($this->webUser);
$this->drupalGet('node/add/page');
$this->assertSession()
->pageTextNotContains('Not saved yet');
// Create node to edit.
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->submitForm($edit, 'Save');
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->drupalGet("node/" . $node->id() . "/edit");
$this->assertSession()
->pageTextNotContains('Published');
$this->assertSession()
->pageTextNotContains($this->container
->get('date.formatter')
->format($node->getChangedTime(), 'short'));
// Check that users with the 'administer nodes' permission can see the meta
// information.
$this->drupalLogin($this->adminUser);
$this->drupalGet('node/add/page');
$this->assertSession()
->pageTextContains('Not saved yet');
// Create node to edit.
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->submitForm($edit, 'Save');
// Enable user_hooks_test to test the users display name is visible on the
// edit form.
\Drupal::service('module_installer')->install([
'user_hooks_test',
]);
\Drupal::keyValue('user_hooks_test')->set('user_format_name_alter', TRUE);
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->drupalGet($node->toUrl('edit-form'));
$this->assertSession()
->pageTextContains('Published');
$this->assertSession()
->pageTextContains($this->container
->get('date.formatter')
->format($node->getChangedTime(), 'short'));
$this->assertSession()
->responseContains('<em>' . $this->adminUser
->id() . '</em>');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.