protected function WebTestBase::drupalCreateNode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/simpletest/src/WebTestBase.php \Drupal\simpletest\WebTestBase::drupalCreateNode()
Creates a node based on default settings.
Parameters
array $settings: (optional) An associative array of settings for the node, as used in entity_create(). Override the defaults by specifying the key and value in the array, for example:
$this
->drupalCreateNode(array(
'title' => t('Hello, world!'),
'type' => 'article',
));
The following defaults are provided:
- body: Random string using the default filter format:
$settings['body'][0] = array(
'value' => $this
->randomMachineName(32),
'format' => filter_default_format(),
);
- title: Random string.
- type: 'page'.
- uid: The currently logged in user, or anonymous.
Return value
\Drupal\node\NodeInterface The created node entity.
235 calls to WebTestBase::drupalCreateNode()
- ArgumentDateTimeTest::setUp in core/
modules/ datetime/ src/ Tests/ Views/ ArgumentDateTimeTest.php - Sets up a Drupal site for running functional and integration tests.
- ArgumentStringTest::testGlossary in core/
modules/ views/ src/ Tests/ Handler/ ArgumentStringTest.php - Tests the glossary feature.
- BasicTest::testViewsWizardAndListing in core/
modules/ views/ src/ Tests/ Wizard/ BasicTest.php - BookTest::testBookNavigationCacheContext in core/
modules/ book/ src/ Tests/ BookTest.php - Tests the book navigation cache context.
- BookTest::testBookOutline in core/
modules/ book/ src/ Tests/ BookTest.php - Tests outline of a book.
File
- core/
modules/ simpletest/ src/ WebTestBase.php, line 284 - Contains \Drupal\simpletest\WebTestBase.
Class
- WebTestBase
- Test case for typical Drupal tests.
Namespace
Drupal\simpletestCode
protected function drupalCreateNode(array $settings = array()) {
// Populate defaults array.
$settings += array(
'body' => array(
array(
'value' => $this
->randomMachineName(32),
'format' => filter_default_format(),
),
),
'title' => $this
->randomMachineName(8),
'type' => 'page',
'uid' => \Drupal::currentUser()
->id(),
);
$node = entity_create('node', $settings);
$node
->save();
return $node;
}