You are here

protected function ContextualLinksTest::setUp in Drupal 8

Same name in this branch
  1. 8 core/modules/node/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\node\FunctionalJavascript\ContextualLinksTest::setUp()
  2. 8 core/modules/layout_builder/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\layout_builder\FunctionalJavascript\ContextualLinksTest::setUp()
  3. 8 core/modules/contextual/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\contextual\FunctionalJavascript\ContextualLinksTest::setUp()
Same name and namespace in other branches
  1. 9 core/modules/node/tests/src/FunctionalJavascript/ContextualLinksTest.php \Drupal\Tests\node\FunctionalJavascript\ContextualLinksTest::setUp()

Overrides BrowserTestBase::setUp

File

core/modules/node/tests/src/FunctionalJavascript/ContextualLinksTest.php, line 39

Class

ContextualLinksTest
Create a node with revisions and test contextual links.

Namespace

Drupal\Tests\node\FunctionalJavascript

Code

protected function setUp() {
  parent::setUp();
  $this
    ->drupalCreateContentType([
    'type' => 'page',
    'name' => 'Basic page',
    'display_submitted' => FALSE,
  ]);

  // Create initial node.
  $node = $this
    ->drupalCreateNode();
  $nodes = [];

  // Get original node.
  $nodes[] = clone $node;

  // Create two revisions.
  $revision_count = 2;
  for ($i = 0; $i < $revision_count; $i++) {

    // Create revision with a random title and body and update variables.
    $node->title = $this
      ->randomMachineName();
    $node->body = [
      'value' => $this
        ->randomMachineName(32),
      'format' => filter_default_format(),
    ];
    $node
      ->setNewRevision();
    $node
      ->save();

    // Make sure we get revision information.
    $node = Node::load($node
      ->id());
    $nodes[] = clone $node;
  }
  $this->nodes = $nodes;
  $this
    ->drupalLogin($this
    ->createUser([
    'view page revisions',
    'revert page revisions',
    'delete page revisions',
    'edit any page content',
    'delete any page content',
    'access contextual links',
    'administer content types',
  ]));
}