function DemoUmamiProfileTest::testEditNodesByAdmin

Same name in other branches
  1. 9 core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php \Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testEditNodesByAdmin()
  2. 8.9.x core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php \Drupal\Tests\demo_umami\Functional\DemoUmamiProfileTest::testEditNodesByAdmin()
  3. 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.

1 call to DemoUmamiProfileTest::testEditNodesByAdmin()
DemoUmamiProfileTest::testDemoFeatures in core/profiles/demo_umami/tests/src/Functional/DemoUmamiProfileTest.php
Tests various capabilities of the demo profile.

File

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

Class

DemoUmamiProfileTest
Tests demo_umami profile.

Namespace

Drupal\Tests\demo_umami\Functional

Code

protected function testEditNodesByAdmin() : void {
    $permissions = [
        'administer nodes',
        'edit any recipe content',
        'use editorial transition create_new_draft',
    ];
    $account = $this->drupalCreateUser($permissions);
    $this->drupalLogin($account);
    $assert_session = $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'));
    $assert_session->statusCodeEquals(200);
    $this->submitForm([], 'Preview');
    $assert_session->statusCodeEquals(200);
    $this->assertSession()
        ->elementsCount('css', 'h1', 1);
    $this->clickLink('Back to content editing');
    $this->submitForm([], "Save");
    $assert_session->pageTextContains('Recipe Deep mediterranean quiche has been updated.');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.