protected function EvaTestBase::makeNodes in EVA: Entity Views Attachment 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/EvaTestBase.php \Drupal\Tests\eva\Functional\EvaTestBase::makeNodes()
Create some example nodes.
1 call to EvaTestBase::makeNodes()
- EvaTestBase::setUp in tests/
src/ Functional/ EvaTestBase.php
File
- tests/
src/ Functional/ EvaTestBase.php, line 64
Class
- EvaTestBase
- Browser testing for Eva.
Namespace
Drupal\Tests\eva\FunctionalCode
protected function makeNodes() {
// Single page for simple Eva test.
$node = $this
->createNode([
'title' => 'Test Eva',
'type' => 'just_eva',
]);
$this->nids['just_eva'] = $node
->id();
// Pages for lists-in-lists.
$this->nids['pages'] = [];
for ($i = 0; $i < $this->pageCount; $i++) {
$node = $this
->createNode([
'title' => sprintf('Page %d', $i + 1),
'type' => 'page_with_related_articles',
]);
$this->nids['pages'][] = $node
->id();
}
// Articles.
for ($i = 0; $i < $this->articleCount; $i++) {
$node = $this
->createNode([
'title' => sprintf('Article %d', $i + 1),
'type' => 'mini',
]);
// Associate articles with assorted pages.
$k = array_rand($this->nids['pages'], 1);
$node->field_page[] = $this->nids['pages'][$k];
$node
->save();
}
}