protected function DecoupledRouterFunctionalTest::createDefaultContent in Decoupled Router 8
Same name and namespace in other branches
- 2.x tests/src/Functional/DecoupledRouterFunctionalTest.php \Drupal\Tests\decoupled_router\Functional\DecoupledRouterFunctionalTest::createDefaultContent()
Creates default content to test the API.
Parameters
int $num_articles: Number of articles to create.
Throws
\Drupal\Core\Entity\EntityStorageException
1 call to DecoupledRouterFunctionalTest::createDefaultContent()
- DecoupledRouterFunctionalTest::setUp in tests/
src/ Functional/ DecoupledRouterFunctionalTest.php
File
- tests/
src/ Functional/ DecoupledRouterFunctionalTest.php, line 102
Class
- DecoupledRouterFunctionalTest
- Test class.
Namespace
Drupal\Tests\decoupled_router\FunctionalCode
protected function createDefaultContent($num_articles) {
$random = $this
->getRandomGenerator();
for ($created_nodes = 0; $created_nodes < $num_articles; $created_nodes++) {
$values = [
'uid' => [
'target_id' => $this->user
->id(),
],
'type' => 'article',
'path' => '/node--' . $created_nodes,
'title' => $random
->name(),
];
$node = $this
->createNode($values);
$values['title'] = $node
->getTitle() . ' (ca)';
$values['field_image']['alt'] = 'alt text (ca)';
$values['path'] = '/node--' . $created_nodes . '--ca';
$node
->addTranslation('ca', $values);
$node
->save();
$this->nodes[] = $node;
}
}