You are here

protected function EntityPagerTest::setUp in Entity Pager 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Functional/EntityPagerTest.php \Drupal\Tests\entity_pager\Functional\EntityPagerTest::setUp()

Overrides ViewTestBase::setUp

File

tests/src/Functional/EntityPagerTest.php, line 52

Class

EntityPagerTest
Tests the entity pager view style.

Namespace

Drupal\Tests\entity_pager\Functional

Code

protected function setUp($import_test_views = TRUE) {
  parent::setUp($import_test_views);
  $view = View::load('entity_pager_example');
  $view
    ->setStatus(TRUE)
    ->save();
  $type = mb_strtolower($this
    ->randomMachineName());
  NodeType::create([
    'type' => $type,
  ])
    ->save();
  $test_user = $this
    ->drupalCreateUser();
  $now = $this->container
    ->get('datetime.time')
    ->getRequestTime();
  for ($i = 0; $i < 5; $i++) {
    $node = Node::create([
      'type' => $type,
      'title' => $this
        ->randomMachineName(),
      // Ensure created times are in sequence.
      'created' => $now + $i * 10,
      // Set different author for some nodes for ::testRelationship().
      'uid' => $i < 3 ? $test_user
        ->id() : NULL,
    ]);
    $node
      ->save();
    $this->nodes[] = $node;
  }
}