class NodePostSettingsTest
Same name and namespace in other branches
- 11.x core/modules/node/tests/src/Functional/NodePostSettingsTest.php \Drupal\Tests\node\Functional\NodePostSettingsTest
Tests the node setting for displaying author and date information.
@group node
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\Tests\node\Functional\NodeTestBase implements \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\node\Functional\NodePostSettingsTest implements \Drupal\Tests\node\Functional\NodeTestBase
- class \Drupal\Tests\node\Functional\NodeTestBase implements \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of NodePostSettingsTest
File
-
core/
modules/ node/ tests/ src/ Functional/ NodePostSettingsTest.php, line 10
Namespace
Drupal\Tests\node\FunctionalView source
class NodePostSettingsTest extends NodeTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$web_user = $this->drupalCreateUser([
'create page content',
'administer content types',
'access user profiles',
]);
$this->drupalLogin($web_user);
}
/**
* Confirms "Basic page" content type and post information is on a new node.
*/
public function testPagePostInfo() {
// Set "Basic page" content type to display post information.
$edit = [];
$edit['display_submitted'] = TRUE;
$this->drupalGet('admin/structure/types/manage/page');
$this->submitForm($edit, 'Save content type');
// Create a node.
$edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalGet('node/add/page');
$this->submitForm($edit, 'Save');
// Check that the post information is displayed.
$node = $this->drupalGetNodeByTitle($edit['title[0][value]']);
$this->assertSession()
->pageTextContainsOnce('Submitted by');
$node->delete();
// Set "Basic page" content type to display post information.
$edit = [];
$edit['display_submitted'] = FALSE;
$this->drupalGet('admin/structure/types/manage/page');
$this->submitForm($edit, 'Save content type');
// Create a node.
$edit = [];
$edit['title[0][value]'] = $this->randomMachineName(8);
$edit['body[0][value]'] = $this->randomMachineName(16);
$this->drupalGet('node/add/page');
$this->submitForm($edit, 'Save');
// Check that the post information is not displayed.
$this->assertSession()
->pageTextNotContains('Submitted by');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.