You are here

public function ScheduledTransitionModalFormTest::testRevisionLogHtml in Scheduled Transitions 8

Same name and namespace in other branches
  1. 2.x tests/src/Functional/ScheduledTransitionModalFormTest.php \Drupal\Tests\scheduled_transitions\Functional\ScheduledTransitionModalFormTest::testRevisionLogHtml()

Tests revision logs.

File

tests/src/Functional/ScheduledTransitionModalFormTest.php, line 43

Class

ScheduledTransitionModalFormTest
Tests the route to add a new transition to an entity (modal form).

Namespace

Drupal\Tests\scheduled_transitions\Functional

Code

public function testRevisionLogHtml() {
  $this
    ->enabledBundles([
    [
      'st_entity_test',
      'st_entity_test',
    ],
  ]);
  $workflow = $this
    ->createEditorialWorkflow();
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('st_entity_test', 'st_entity_test');
  $workflow
    ->save();
  $currentUser = $this
    ->drupalCreateUser([
    'administer st_entity_test entities',
    'use editorial transition create_new_draft',
    'use editorial transition publish',
    'use editorial transition archive',
    Permissions::addScheduledTransitionsPermission('st_entity_test', 'st_entity_test'),
  ]);
  $this
    ->drupalLogin($currentUser);
  $entity = ScheduledTransitionsTestEntity::create([
    'type' => 'st_entity_test',
  ]);
  $logMessage = '<strong>Hello world</strong>';
  $entity
    ->setRevisionLogMessage($logMessage);
  $entity
    ->save();
  $this
    ->drupalGet($entity
    ->toUrl());

  // Access the modal directly.
  $this
    ->drupalGet($entity
    ->toUrl(ScheduledTransitionsRouteProvider::LINK_TEMPLATE_ADD));

  // Check if the log message exists in HTML verbatim, the HTML tags should
  // not be entity encoded.
  $this
    ->assertSession()
    ->responseContains($logMessage);
}