You are here

protected function EvaTestBase::makeNodes in EVA: Entity Views Attachment 8

Same name and namespace in other branches
  1. 8.2 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 54

Class

EvaTestBase
Browser testing for Eva.

Namespace

Drupal\Tests\eva\Functional

Code

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->page_count; $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->article_count; $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();
  }
}