FixtureContext.php in Lightning Core 8.3
File
tests/src/FixtureContext.php
View source
<?php
namespace Drupal\Tests\lightning_core;
use Drupal\block\Entity\Block;
use Drupal\node\Entity\NodeType;
use Drupal\search_api\Entity\Index;
use Drupal\user\Entity\Role;
final class FixtureContext extends FixtureBase {
public function setUp() {
if (!Role::load('administrator')) {
$role = Role::create([
'id' => 'administrator',
'label' => 'Administrator',
])
->setIsAdmin(TRUE);
$this
->save($role);
}
$this
->installTheme('seven');
$this
->config('system.theme')
->set('admin', 'seven')
->set('default', 'seven')
->save();
if (!Block::load('seven_content')) {
$block = Block::create([
'id' => 'seven_content',
'theme' => 'seven',
'region' => 'content',
'plugin' => 'system_main_block',
'settings' => [
'label_display' => '0',
],
]);
$this
->save($block);
}
$node_type = NodeType::create([
'type' => 'test',
'name' => 'Test',
]);
$this
->save($node_type);
$this
->installModule('views');
if ($this
->installModule('lightning_search')) {
$index = Index::load('content');
$dependencies = $index
->getDependencies();
$dependencies['enforced']['module'][] = 'lightning_search';
$index
->set('dependencies', $dependencies)
->save();
}
if (!Block::load('seven_search')) {
$block = Block::create([
'id' => 'seven_search',
'theme' => 'seven',
'region' => 'content',
'plugin' => 'views_exposed_filter_block:search-page',
])
->setVisibilityConfig('request_path', [
'pages' => '/search',
]);
$this
->save($block);
}
$this
->config('views.view.search')
->set('display.default.display_options.cache', [
'type' => 'none',
'options' => [],
])
->save();
}
public function tearDown() {
parent::tearDown();
}
}
Classes
Name |
Description |
FixtureContext |
Performs set-up and tear-down tasks before and after test scenarios. |