final class FixtureContext in Lightning Core 8.5
Same name and namespace in other branches
- 8.3 tests/src/FixtureContext.php \Drupal\Tests\lightning_core\FixtureContext
- 8.4 tests/src/FixtureContext.php \Drupal\Tests\lightning_core\FixtureContext
Performs set-up and tear-down tasks before and after test scenarios.
Hierarchy
- class \Drupal\Tests\lightning_core\FixtureBase implements \Behat\Behat\Context\Context, \Symfony\Component\DependencyInjection\ContainerAwareInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait
- class \Drupal\Tests\lightning_core\FixtureContext
Expanded class hierarchy of FixtureContext
File
- tests/
src/ FixtureContext.php, line 12
Namespace
Drupal\Tests\lightning_coreView source
final class FixtureContext extends FixtureBase {
/**
* Performs set-up tasks before a test scenario.
*
* @BeforeScenario
*/
public function setUp() {
// Create the administrator role if it does not already exist.
if (!Role::load('administrator')) {
$role = Role::create([
'id' => 'administrator',
'label' => 'Administrator',
])
->setIsAdmin(TRUE);
$this
->save($role);
}
// Install the Seven theme if not already installed.
$this
->installTheme('seven');
// Use Seven as both the default and administrative theme.
$this
->config('system.theme')
->set('admin', 'seven')
->set('default', 'seven')
->save();
// Place the main content block if it's not already there.
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);
}
// Create a test content type to be automatically cleaned up at the end of
// the scenario.
$node_type = NodeType::create([
'type' => 'test',
'name' => 'Test',
]);
$this
->save($node_type);
}
/**
* Performs tear-down tasks after a test scenario.
*
* @AfterScenario
*/
public function tearDown() {
// This pointless if statement is here to evade a too-strict coding
// standards rule.
if (TRUE) {
parent::tearDown();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FixtureBase:: |
private | property | Raw configuration data to be restored after the scenario, keyed by ID. | |
FixtureBase:: |
private | property | Entities to be automatically deleted after the scenario. | |
FixtureBase:: |
private | property | Modules installed during the scenario. | |
FixtureBase:: |
private | property | Themes installed during the scenario. | |
FixtureBase:: |
private | property | Entity types for which to delete all content created by the current users. | |
FixtureBase:: |
private | property | The Drupal Extension's user manager. | |
FixtureBase:: |
private | property | The Drupal user IDs that were logged in during the scenario. | |
FixtureBase:: |
private | function | Deletes all content created by the current users. | |
FixtureBase:: |
protected | function | Returns a config object and caches its data for automatic restoration. | |
FixtureBase:: |
protected | function | Installs a module if not already present. | |
FixtureBase:: |
protected | function | Installs a theme if not already present. | |
FixtureBase:: |
protected | function | Updates the container. | |
FixtureBase:: |
protected | function | Saves an entity and marks it for automatic deletion. | |
FixtureBase:: |
public | function | Records the current Drupal user ID if possible. | |
FixtureBase:: |
public | function | Marks content by the current user to be deleted after the scenario. | |
FixtureBase:: |
public | function | FixtureBase constructor. | |
FixtureContext:: |
public | function | Performs set-up tasks before a test scenario. | |
FixtureContext:: |
public | function |
Performs tear-down tasks after a test scenario. Overrides FixtureBase:: |