You are here

public function DemoUmamiProfileTest::testEditNodesByAdmin in Drupal 8

Same name and namespace in other branches
  1. 9 core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php \Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testEditNodesByAdmin()
  2. 10 core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php \Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testEditNodesByAdmin()

Tests the successful editing of nodes by admin.

File

core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php, line 112

Class

DemoUmamiProfileTest
Tests demo_umami profile.

Namespace

Drupal\Tests\demo_umami\Functional

Code

public function testEditNodesByAdmin() {
  $permissions = [
    'administer nodes',
    'edit any recipe content',
    'use editorial transition create_new_draft',
  ];
  $account = $this
    ->drupalCreateUser($permissions);
  $this
    ->drupalLogin($account);
  $webassert = $this
    ->assertSession();

  // Check that admin is able to edit the node.
  $nodes = $this->container
    ->get('entity_type.manager')
    ->getStorage('node')
    ->loadByProperties([
    'title' => 'Deep mediterranean quiche',
  ]);
  $node = reset($nodes);
  $this
    ->drupalGet($node
    ->toUrl('edit-form'));
  $webassert
    ->statusCodeEquals('200');
  $this
    ->submitForm([], "Save");
  $webassert
    ->pageTextContains('Recipe Deep mediterranean quiche has been updated.');
}