You are here

public function EntityRevisionConverterTest::testConvertWithRevisionableEntityType in Workbench Moderation 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/EntityRevisionConverterTest.php \Drupal\Tests\workbench_moderation\Kernel\EntityRevisionConverterTest::testConvertWithRevisionableEntityType()

Test converting revisionable entity type.

File

tests/src/Kernel/EntityRevisionConverterTest.php, line 65

Class

EntityRevisionConverterTest
@coversDefaultClass \Drupal\workbench_moderation\ParamConverter\EntityRevisionConverter @group workbench_moderation

Namespace

Drupal\Tests\workbench_moderation\Kernel

Code

public function testConvertWithRevisionableEntityType() {
  $node_type = NodeType::create([
    'type' => 'article',
  ]);
  $node_type
    ->setThirdPartySetting('workbench_moderation', 'enabled', TRUE);
  $node_type
    ->save();
  $revision_ids = [];
  $node = Node::create([
    'title' => 'test',
    'type' => 'article',
  ]);
  $node
    ->save();
  $revision_ids[] = $node
    ->getRevisionId();
  $node
    ->setNewRevision(TRUE);
  $node
    ->save();
  $revision_ids[] = $node
    ->getRevisionId();
  $node
    ->setNewRevision(TRUE);
  $node
    ->isDefaultRevision(FALSE);
  $node
    ->save();
  $revision_ids[] = $node
    ->getRevisionId();

  /** @var \Symfony\Component\Routing\RouterInterface $router */
  $router = \Drupal::service('router.no_access_checks');
  $result = $router
    ->match('/node/' . $node
    ->id() . '/edit');
  $this
    ->assertInstanceOf(Node::class, $result['node']);
  $this
    ->assertEquals($revision_ids[2], $result['node']
    ->getRevisionId());
  $this
    ->assertFalse($result['node']
    ->isDefaultRevision());
}