function ModerationStateNodeTest::testNodeLatestVersionContent

Tests content on the latest version tab for nodes.

File

core/modules/content_moderation/tests/src/Functional/ModerationStateNodeTest.php, line 187

Class

ModerationStateNodeTest
Tests general content moderation workflow for nodes.

Namespace

Drupal\Tests\content_moderation\Functional

Code

public function testNodeLatestVersionContent() : void {
  $node = $this->drupalCreateNode([
    'type' => 'moderated_content',
    'title' => 'Test moderated node content',
    'status' => 1,
    'moderation_state' => 'published',
  ]);
  $node->setNewRevision(TRUE);
  $node->set('moderation_state', 'draft')
    ->setTitle('Test moderated node content - draft')
    ->save();
  $this->drupalLogin($this->adminUser);
  $this->drupalGet($node->toUrl('latest-version'));
  $this->assertSession()
    ->statusCodeEquals(200);
  // The node title should only appear twice - once in the title tag, and once
  // in the h1 tag.
  $this->assertSession()
    ->pageTextMatchesCount(2, '/Test moderated node content - draft/ui');
  $this->assertSession()
    ->elementNotExists('css', 'article h2');
}

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