public function NodePostSettingsTest::testPagePostInfo in Drupal 8
Same name and namespace in other branches
- 9 core/modules/node/tests/src/Functional/NodePostSettingsTest.php \Drupal\Tests\node\Functional\NodePostSettingsTest::testPagePostInfo()
Confirms "Basic page" content type and post information is on a new node.
File
- core/
modules/ node/ tests/ src/ Functional/ NodePostSettingsTest.php, line 32
Class
- NodePostSettingsTest
- Tests that the post information (submitted by Username on date) text displays appropriately.
Namespace
Drupal\Tests\node\FunctionalCode
public function testPagePostInfo() {
// Set "Basic page" content type to display post information.
$edit = [];
$edit['display_submitted'] = TRUE;
$this
->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
// Create a node.
$edit = [];
$edit['title[0][value]'] = $this
->randomMachineName(8);
$edit['body[0][value]'] = $this
->randomMachineName(16);
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
$node = $this
->drupalGetNodeByTitle($edit['title[0][value]']);
$elements = $this
->xpath('//div[contains(@class, :class)]', [
':class' => 'node__submitted',
]);
$this
->assertCount(1, $elements, 'Post information is displayed.');
$node
->delete();
// Set "Basic page" content type to display post information.
$edit = [];
$edit['display_submitted'] = FALSE;
$this
->drupalPostForm('admin/structure/types/manage/page', $edit, t('Save content type'));
// Create a node.
$edit = [];
$edit['title[0][value]'] = $this
->randomMachineName(8);
$edit['body[0][value]'] = $this
->randomMachineName(16);
$this
->drupalPostForm('node/add/page', $edit, t('Save'));
// Check that the post information is displayed.
$elements = $this
->xpath('//div[contains(@class, :class)]', [
':class' => 'node__submitted',
]);
$this
->assertCount(0, $elements, 'Post information is not displayed.');
}