You are here

public function AggregatorTestBase::createSampleNodes in Drupal 8

Same name in this branch
  1. 8 core/modules/aggregator/src/Tests/AggregatorTestBase.php \Drupal\aggregator\Tests\AggregatorTestBase::createSampleNodes()
  2. 8 core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php \Drupal\Tests\aggregator\Functional\AggregatorTestBase::createSampleNodes()

Creates sample article nodes.

Parameters

int $count: (optional) The number of nodes to generate. Defaults to five.

File

core/modules/aggregator/src/Tests/AggregatorTestBase.php, line 379

Class

AggregatorTestBase
Defines a base class for testing the Aggregator module.

Namespace

Drupal\aggregator\Tests

Code

public function createSampleNodes($count = 5) {

  // Post $count article nodes.
  for ($i = 0; $i < $count; $i++) {
    $edit = [];
    $edit['title[0][value]'] = $this
      ->randomMachineName();
    $edit['body[0][value]'] = $this
      ->randomMachineName();
    $this
      ->drupalPostForm('node/add/article', $edit, t('Save'));
  }
}