NodePostSettingsTest.php in Drupal 10
File
core/modules/node/tests/src/Functional/NodePostSettingsTest.php
View source
<?php
namespace Drupal\Tests\node\Functional;
class NodePostSettingsTest extends NodeTestBase {
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$web_user = $this
->drupalCreateUser([
'create page content',
'administer content types',
'access user profiles',
]);
$this
->drupalLogin($web_user);
}
public function testPagePostInfo() {
$edit = [];
$edit['display_submitted'] = TRUE;
$this
->drupalGet('admin/structure/types/manage/page');
$this
->submitForm($edit, 'Save content type');
$edit = [];
$edit['title[0][value]'] = $this
->randomMachineName(8);
$edit['body[0][value]'] = $this
->randomMachineName(16);
$this
->drupalGet('node/add/page');
$this
->submitForm($edit, 'Save');
$node = $this
->drupalGetNodeByTitle($edit['title[0][value]']);
$this
->assertSession()
->pageTextContainsOnce('Submitted by');
$node
->delete();
$edit = [];
$edit['display_submitted'] = FALSE;
$this
->drupalGet('admin/structure/types/manage/page');
$this
->submitForm($edit, 'Save content type');
$edit = [];
$edit['title[0][value]'] = $this
->randomMachineName(8);
$edit['body[0][value]'] = $this
->randomMachineName(16);
$this
->drupalGet('node/add/page');
$this
->submitForm($edit, 'Save');
$this
->assertSession()
->pageTextNotContains('Submitted by');
}
}
Classes
Name |
Description |
NodePostSettingsTest |
Tests that the post information (submitted by Username on date) text displays
appropriately. |