You are here

protected function NodeMultipleWidgetTest::setUp in Rate 8

Same name in this branch
  1. 8 tests/src/Functional/NodeMultipleWidgetTest.php \Drupal\Tests\rate\Functional\NodeMultipleWidgetTest::setUp()
  2. 8 tests/src/FunctionalJavascript/NodeMultipleWidgetTest.php \Drupal\Tests\rate\FunctionalJavascript\NodeMultipleWidgetTest::setUp()

Overrides BrowserTestBase::setUp

File

tests/src/FunctionalJavascript/NodeMultipleWidgetTest.php, line 43

Class

NodeMultipleWidgetTest
Tests of multiple widgets for different nodes.

Namespace

Drupal\Tests\rate\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  NodeType::create([
    'type' => 'article',
    'name' => 'Article',
  ])
    ->save();
  NodeType::create([
    'type' => 'page',
    'name' => 'Basic Page',
  ])
    ->save();

  // Enable 'Fivestar' on Article and 'Thumbs Up / Down' on Basic Page.
  $this
    ->config('rate.settings')
    ->set('enabled_types_widgets.node', [
    'article' => [
      'widget_type' => 'fivestar',
    ],
    'page' => [
      'widget_type' => 'thumbs_up_down',
    ],
  ])
    ->set('use_ajax', TRUE)
    ->save();
  $this
    ->drupalCreateNode([
    'type' => 'article',
    'nid' => 1,
  ])
    ->save();
  $this
    ->drupalCreateNode([
    'type' => 'page',
    'nid' => 2,
  ])
    ->save();
  $permissions = [
    'access content',
    'cast rate vote on node of article',
    'cast rate vote on node of page',
  ];
  $this->users[0] = $this
    ->createUser($permissions);
  $this->users[1] = $this
    ->createUser($permissions);
  $this->users[2] = $this
    ->createUser($permissions);
}