You are here

public function InstallTest::testInstallWorkflow in Lightning Core 8.4

Same name and namespace in other branches
  1. 8.5 modules/lightning_page/tests/src/Kernel/InstallTest.php \Drupal\Tests\lightning_page\Kernel\InstallTest::testInstallWorkflow()

Tests installing Lightning Workflow.

Parameters

bool $should_apply: (optional) Whether or not the workflow will be applied to the page content type. Defaults to TRUE.

1 call to InstallTest::testInstallWorkflow()
InstallTest::testInstallWorkflowDuringSync in modules/lightning_page/tests/src/Kernel/InstallTest.php
Tests installing Lightning Workflow during config sync.

File

modules/lightning_page/tests/src/Kernel/InstallTest.php, line 34

Class

InstallTest
Tests installation of Lightning Page.

Namespace

Drupal\Tests\lightning_page\Kernel

Code

public function testInstallWorkflow($should_apply = TRUE) {

  // Ensure the module does not react directly to the installation of
  // lightning_workflow.
  lightning_page_modules_installed([
    'lightning_workflow',
  ]);

  // Create a fake module handler which will report that lightning_workflow
  // is installed. It is too cumbersome to bring it in as a real dev
  // dependency, so this is a decent way to hack it.
  $this->container
    ->set('module_handler', new TestModuleHandler($this->root, $this->container
    ->getParameter('container.modules'), new NullBackend('discovery')));
  Workflow::create([
    'id' => 'editorial',
    'label' => 'Editorial',
    'type' => 'content_moderation',
  ])
    ->save();

  /** @var \Drupal\content_moderation\Plugin\WorkflowType\ContentModerationInterface $type_plugin */
  $type_plugin = Workflow::load('editorial')
    ->getTypePlugin();
  $this
    ->assertSame($should_apply, $type_plugin
    ->appliesToEntityTypeAndBundle('node', 'page'));
}