You are here

public function ScheduledTransitionModalFormTest::testNoRevisionLinkTemplate 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::testNoRevisionLinkTemplate()

Test using an entity without a revision link template.

File

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

Class

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

Namespace

Drupal\Tests\scheduled_transitions\Functional

Code

public function testNoRevisionLinkTemplate() {
  $this
    ->enabledBundles([
    [
      'st_entity_test_norevtemplate',
      'st_entity_test_norevtemplate',
    ],
  ]);
  $workflow = $this
    ->createEditorialWorkflow();
  $workflow
    ->getTypePlugin()
    ->addEntityTypeAndBundle('st_entity_test_norevtemplate', 'st_entity_test_norevtemplate');
  $workflow
    ->save();
  $currentUser = $this
    ->drupalCreateUser([
    'administer st_entity_test_norevtemplate entities',
    'use editorial transition create_new_draft',
    'use editorial transition publish',
    'use editorial transition archive',
    'add scheduled transitions st_entity_test_norevtemplate st_entity_test_norevtemplate',
  ]);
  $this
    ->drupalLogin($currentUser);
  $entity = ScheduledTransitionsTestNoRevisionTemplateEntity::create([
    'type' => 'st_entity_test_norevtemplate',
  ]);
  $entity
    ->save();

  // Need to create an extra revision, because out of the box a freshly
  // created entity will have only one entity, and the toUrl method will
  // shortcut out, changing rel to 'canonical'.
  $entity
    ->setNewRevision(TRUE);
  $entity
    ->setRevisionLogMessage('test rev log msg');
  $entity
    ->save();

  // Ensure the entity wasn't updated with a 'revision' link template.
  $this
    ->assertFalse($entity
    ->getEntityType()
    ->hasLinkTemplate('revision'));

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