You are here

protected function ViewsOutputTest::setUp in Workbench Access 8

Overrides BrowserTestBase::setUp

File

tests/src/Functional/ViewsOutputTest.php, line 81

Class

ViewsOutputTest
Defines a class for testing workbench access views.

Namespace

Drupal\Tests\workbench_access\Functional

Code

protected function setUp() {
  parent::setUp();

  // Create some sections and some nodes in them.
  $sections = [
    'Some section',
    'Another section',
    'More sections',
  ];
  foreach ($sections as $section) {
    $this->terms[$section] = Term::create([
      'vid' => 'editorial_section',
      'name' => $section . ' term',
    ]);
    $this->terms[$section]
      ->save();
    $this->links[$section] = MenuLinkContent::create([
      'title' => $section,
      'link' => [
        [
          'uri' => 'route:<front>',
        ],
      ],
      'menu_name' => 'main',
    ]);
    foreach ([
      ' node 1',
      ' node 2',
    ] as $stub) {
      $title = $section . $stub;
      $this->nodes[$title] = Node::create([
        'type' => 'article',
        'title' => $title,
        'status' => 1,
        'field_workbench_access' => $this->terms[$section],
      ]);
      $this->nodes[$title]
        ->save();
      _menu_ui_node_save($this->nodes[$title], [
        'title' => $title . '-menu',
        'menu_name' => 'main',
        'description' => 'view bar',
        'parent' => $this->links[$section]
          ->getPluginId(),
      ]);
    }
  }

  // Create a user who can access content etc.
  $permissions = [
    'create article content',
    'edit any article content',
    'access content',
    'delete any article content',
    'administer nodes',
    'access user profiles',
    'use workbench access',
  ];
  $this->user = $this
    ->createUser($permissions);
  $this->user
    ->save();
}