You are here

protected function ViewsFilterTest::setUp in Rate 8

Overrides ViewTestBase::setUp

File

tests/src/Functional/ViewsFilterTest.php, line 51

Class

ViewsFilterTest
Tests Views Fivestar Widget.

Namespace

Drupal\Tests\rate\Functional

Code

protected function setUp($import_test_views = TRUE) {
  parent::setUp($import_test_views);
  ViewTestData::createTestViews(get_class($this), [
    'rate_views_test',
  ]);
  NodeType::create([
    'type' => 'article',
    'name' => 'Article',
  ])
    ->save();

  // Enable 'Fivestar' on Article.
  $this
    ->config('rate.settings')
    ->set('enabled_types_widgets.node', [
    'article' => [
      'widget_type' => 'fivestar',
    ],
  ])
    ->set('use_ajax', FALSE)
    ->save();
  foreach (range(1, 6) as $id) {
    $this
      ->drupalCreateNode([
      'type' => 'article',
      'title' => 'Article ' . $id,
      'nid' => $id,
    ])
      ->save();
  }
  $user = $this
    ->createUser([
    'access content',
    'cast rate vote on node of article',
  ]);
  $this
    ->drupalLogin($user);
}