InstallTest.php in Lightning Layout 8
File
modules/lightning_landing_page/tests/src/Kernel/InstallTest.php
View source
<?php
namespace Drupal\Tests\lightning_landing_page\Kernel;
use Drupal\Core\Cache\NullBackend;
use Drupal\Core\Extension\ModuleHandler;
use Drupal\KernelTests\KernelTestBase;
use Drupal\workflows\Entity\Workflow;
class InstallTest extends KernelTestBase {
protected static $modules = [
'content_moderation',
'lightning_landing_page',
'node',
'workflows',
];
public function testInstallWorkflow($should_apply = TRUE) {
lightning_landing_page_modules_installed([
'lightning_workflow',
]);
$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();
$type_plugin = Workflow::load('editorial')
->getTypePlugin();
$this
->assertSame($should_apply, $type_plugin
->appliesToEntityTypeAndBundle('node', 'landing_page'));
}
public function testInstallWorkflowDuringSync() {
$this->container
->get('config.installer')
->setSyncing(TRUE);
$this
->testInstallWorkflow(FALSE);
}
}
class TestModuleHandler extends ModuleHandler {
public function moduleExists($module) {
return $module === 'lightning_workflow' ? TRUE : parent::moduleExists($module);
}
}
Classes
Name |
Description |
InstallTest |
Tests installation of Lightning Landing Page. |
TestModuleHandler |
Fake module handler that always reports lightning_workflow is installed. |