class StageBaseTest
Same name in this branch
- 11.x core/modules/package_manager/tests/src/Unit/StageBaseTest.php \Drupal\Tests\package_manager\Unit\StageBaseTest
@coversDefaultClass \Drupal\package_manager\StageBase @group package_manager @group #slow @internal
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
- class \Drupal\Tests\package_manager\Kernel\StageBaseTest extends \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase uses \Drupal\Core\StringTranslation\StringTranslationTrait
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase extends \Drupal\KernelTests\KernelTestBase uses \Drupal\Tests\package_manager\Traits\AssertPreconditionsTrait, \Drupal\Tests\package_manager\Traits\ComposerStagerTestTrait, \Drupal\Tests\package_manager\Traits\FixtureManipulatorTrait, \Drupal\Tests\package_manager\Traits\FixtureUtilityTrait, \Drupal\package_manager\StatusCheckTrait, \Drupal\Tests\package_manager\Traits\ValidationTestTrait
Expanded class hierarchy of StageBaseTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ StageBaseTest.php, line 32
Namespace
Drupal\Tests\package_manager\KernelView source
class StageBaseTest extends PackageManagerKernelTestBase {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'package_manager_test_validation',
];
/**
* {@inheritdoc}
*/
public function register(ContainerBuilder $container) : void {
parent::register($container);
// Since this test adds arbitrary event listeners that aren't services, we
// need to ensure they will persist even if the container is rebuilt when
// staged changes are applied.
$container->getDefinition('event_dispatcher')
->addTag('persist');
}
/**
* @covers ::getMetadata
* @covers ::setMetadata
*/
public function testMetadata() : void {
$stage = $this->createStage();
$stage->create();
$this->assertNull($stage->getMetadata('new_key'));
$stage->setMetadata('new_key', 'value');
$this->assertSame('value', $stage->getMetadata('new_key'));
$stage->destroy();
// Ensure that metadata associated with the previous stage was deleted.
$stage = $this->createStage();
$stage->create();
$this->assertNull($stage->getMetadata('new_key'));
$stage->destroy();
// Ensure metadata cannot be accessed or set unless the stage has been
// claimed.
$stage = $this->createStage();
try {
$stage->getMetadata('new_key');
$this->fail('Expected an ownership exception, but none was thrown.');
} catch (\LogicException $e) {
$this->assertSame('Stage must be claimed before performing any operations on it.', $e->getMessage());
}
try {
$stage->setMetadata('new_key', 'value');
$this->fail('Expected an ownership exception, but none was thrown.');
} catch (\LogicException $e) {
$this->assertSame('Stage must be claimed before performing any operations on it.', $e->getMessage());
}
}
/**
* @covers ::getStageDirectory
*/
public function testGetStageDirectory() : void {
// In this test, we're working with paths that (probably) don't exist in
// the file system at all, so we don't want to validate that the file system
// is writable when creating stages.
$validator = $this->container
->get(WritableFileSystemValidator::class);
$this->container
->get('event_dispatcher')
->removeSubscriber($validator);
/** @var \Drupal\package_manager_bypass\MockPathLocator $path_locator */
$path_locator = $this->container
->get(PathLocator::class);
$stage = $this->createStage();
$id = $stage->create();
$stage_dir = $stage->getStageDirectory();
$this->assertStringStartsWith($path_locator->getStagingRoot() . '/', $stage_dir);
$this->assertStringEndsWith("/{$id}", $stage_dir);
// If the stage root directory is changed, the existing stage shouldn't be
// affected...
$active_dir = $path_locator->getProjectRoot();
$new_staging_root = $this->testProjectRoot . DIRECTORY_SEPARATOR . 'junk';
if (!is_dir($new_staging_root)) {
mkdir($new_staging_root);
}
$path_locator->setPaths($active_dir, "{$active_dir}/vendor", '', $new_staging_root);
$this->assertSame($stage_dir, $stage->getStageDirectory());
$stage->destroy();
// ...but a new stage should be.
$stage = $this->createStage();
$another_id = $stage->create();
$this->assertNotSame($id, $another_id);
$stage_dir = $stage->getStageDirectory();
$this->assertStringStartsWith(realpath($new_staging_root), $stage_dir);
$this->assertStringEndsWith("/{$another_id}", $stage_dir);
}
/**
* @covers ::getStageDirectory
*/
public function testUncreatedGetStageDirectory() : void {
$this->expectException(\LogicException::class);
$this->expectExceptionMessage('Drupal\\package_manager\\StageBase::getStageDirectory() cannot be called because the stage has not been created or claimed.');
$this->createStage()
->getStageDirectory();
}
/**
* Tests that Composer Stager is invoked with a long timeout.
*/
public function testTimeouts() : void {
$stage = $this->createStage();
$stage->create(420);
$stage->require([
'ext-json:*',
]);
$stage->apply();
$timeouts = [
// The beginner was given an explicit timeout.
BeginnerInterface::class => 420,
// The stager should be called with a timeout of 300 seconds, which is
// longer than Composer Stager's default timeout of 120 seconds.
StagerInterface::class => 300,
// The committer should have been called with an even longer timeout,
// since it's the most failure-sensitive operation.
CommitterInterface::class => 600,
];
foreach ($timeouts as $service_id => $expected_timeout) {
$invocations = $this->container
->get($service_id)
->getInvocationArguments();
// The services should have been called with the expected timeouts.
$expected_count = 1;
if ($service_id === StagerInterface::class) {
// Stage::require() calls Stager::stage() twice, once to change the
// version constraints in composer.json, and again to actually update
// the installed dependencies.
$expected_count = 2;
}
$this->assertCount($expected_count, $invocations);
$this->assertSame($expected_timeout, end($invocations[0]));
}
}
/**
* Tests that if a stage fails to apply, another stage cannot be created.
*/
public function testFailureMarkerPreventsCreate() : void {
$stage = $this->createStage();
$stage->create();
$stage->require([
'ext-json:*',
]);
// Make the committer throw an exception, which should cause the failure
// marker to be present.
$thrown_message = 'Thrown by the committer.';
LoggingCommitter::setException(\Exception::class, $thrown_message);
try {
$stage->apply();
$this->fail('Expected an exception.');
} catch (ApplyFailedException $e) {
$this->assertStringContainsString($thrown_message, $e->getMessage());
$this->assertFalse($stage->isApplying());
}
$stage->destroy();
// Even through the previous stage was destroyed, we cannot create a new one
// because the failure marker is still there.
$stage = $this->createStage();
try {
$stage->create();
$this->fail('Expected an exception.');
} catch (StageFailureMarkerException $e) {
$this->assertMatchesRegularExpression('/^Staged changes failed to apply, and the site is in an indeterminate state. It is strongly recommended to restore the code and database from a backup. Caused by Exception, with this message: ' . $thrown_message . "\nBacktrace:\n#0 .*/", $e->getMessage());
$this->assertFalse($stage->isApplying());
}
// If the failure marker is cleared, we should be able to create the stage
// without issue.
$this->container
->get(FailureMarker::class)
->clear();
$stage->create();
}
/**
* Tests that the failure marker file doesn't exist if apply succeeds.
*
* @see ::testCommitException
*/
public function testNoFailureFileOnSuccess() : void {
$stage = $this->createStage();
$stage->create();
$stage->require([
'ext-json:*',
]);
$stage->apply();
$this->container
->get(FailureMarker::class)
->assertNotExists();
}
/**
* Data provider for testStoreDestroyInfo().
*
* @return \string[][]
* The test cases.
*/
public static function providerStoreDestroyInfo() : array {
return [
'Changes applied' => [
FALSE,
TRUE,
NULL,
'This operation has already been applied.',
],
'Changes not applied and forced' => [
TRUE,
FALSE,
NULL,
'This operation was canceled by another user.',
],
'Changes not applied and not forced' => [
FALSE,
FALSE,
NULL,
'This operation was already canceled.',
],
'Changes applied, with a custom exception message.' => [
FALSE,
TRUE,
t('Stage destroyed with a custom message.'),
'Stage destroyed with a custom message.',
],
'Changes not applied and forced, with a custom exception message.' => [
TRUE,
FALSE,
t('Stage destroyed with a custom message.'),
'Stage destroyed with a custom message.',
],
'Changes not applied and not forced, with a custom exception message.' => [
FALSE,
FALSE,
t('Stage destroyed with a custom message.'),
'Stage destroyed with a custom message.',
],
];
}
/**
* Tests exceptions thrown because of previously destroyed stage.
*
* @param bool $force
* Whether the stage was forcefully destroyed.
* @param bool $changes_applied
* Whether the changes are applied.
* @param \Drupal\Core\StringTranslation\TranslatableMarkup|null $message
* A message about why the stage was destroyed or null.
* @param string $expected_exception_message
* The expected exception message string.
*
* @dataProvider providerStoreDestroyInfo
*/
public function testStoreDestroyInfo(bool $force, bool $changes_applied, ?TranslatableMarkup $message, string $expected_exception_message) : void {
$stage = $this->createStage();
$stage_id = $stage->create();
$stage->require([
'drupal/core:9.8.1',
]);
$tempstore = $this->container
->get('tempstore.shared');
// Simulate whether ::apply() has run or not.
// @see \Drupal\package_manager\Stage::TEMPSTORE_CHANGES_APPLIED
$tempstore->get('package_manager_stage')
->set('changes_applied', $changes_applied);
$stage->destroy($force, $message);
// Prove the first stage was destroyed: a second stage can be created
// without an exception being thrown.
$stage2 = $this->createStage();
$stage2->create();
// Claiming the first stage always fails in this test because it was
// destroyed, but the exception message depends on why it was destroyed.
$this->expectException(StageException::class);
$this->expectExceptionMessage($expected_exception_message);
$stage->claim($stage_id);
}
/**
* Tests exception message once temp store message has expired.
*/
public function testTempStoreMessageExpired() : void {
$stage = $this->createStage();
$stage_id = $stage->create();
$stage->require([
'drupal/core:9.8.1',
]);
$stage->destroy(TRUE, $this->t('Force destroy stage.'));
// Delete the tempstore message stored for the previously destroyed stage.
$tempstore = $this->container
->get('tempstore.shared');
// @see \Drupal\package_manager\Stage::TEMPSTORE_DESTROYED_STAGES_INFO_PREFIX
$tempstore->get('package_manager_stage')
->delete('TEMPSTORE_DESTROYED_STAGES_INFO' . $stage_id);
// Claiming the stage will fail, but we won't get the message we set in
// \Drupal\package_manager\Stage::storeDestroyInfo() as we are deleting it
// above.
$this->expectException(StageException::class);
$this->expectExceptionMessage('Cannot claim the stage because no stage has been created.');
$stage->claim($stage_id);
}
/**
* Data provider for ::testFailureDuringComposerStagerOperations().
*
* @return array[]
* The test cases.
*/
public static function providerFailureDuringComposerStagerOperations() : array {
return [
[
LoggingBeginner::class,
],
[
NoOpStager::class,
],
[
LoggingCommitter::class,
],
];
}
/**
* Tests when Composer Stager throws an exception during an operation.
*
* @param class-string $throwing_class
* The fully qualified name of the Composer Stager class that should throw
* an exception. It is expected to have a static ::setException() method,
* provided by \Drupal\package_manager_bypass\ComposerStagerExceptionTrait.
*
* @dataProvider providerFailureDuringComposerStagerOperations
*/
public function testFailureDuringComposerStagerOperations(string $throwing_class) : void {
$exception_message = "{$throwing_class} is angry!";
$throwing_class::setException(\Exception::class, $exception_message, 1024);
$expected_message = preg_quote($exception_message);
if ($throwing_class === LoggingCommitter::class) {
$expected_message = "/^Staged changes failed to apply, and the site is in an indeterminate state. It is strongly recommended to restore the code and database from a backup. Caused by Exception, with this message: {$expected_message}\nBacktrace:\n#0 .*/";
}
else {
$expected_message = "/^{$expected_message}\$/";
}
$stage = $this->createStage();
try {
$stage->create();
$stage->require([
'ext-json:*',
]);
$stage->apply();
$this->fail('Expected an exception to be thrown, but it was not.');
} catch (StageException $e) {
$this->assertMatchesRegularExpression($expected_message, $e->getMessage());
$this->assertSame(1024, $e->getCode());
$this->assertInstanceOf(\Exception::class, $e->getPrevious());
}
}
/**
* Tests that paths to exclude are collected before create and apply.
*/
public function testCollectPathsToExclude() : void {
$this->addEventTestListener(function (CollectPathsToExcludeEvent $event) : void {
$event->add('exclude/me');
}, CollectPathsToExcludeEvent::class);
// On pre-create and pre-apply, ensure that the excluded path is known to
// the event.
$asserted = FALSE;
$assert_excluded = function (object $event) use (&$asserted) : void {
$this->assertContains('exclude/me', $event->excludedPaths
->getAll());
// Use this to confirm that this listener was actually called.
$asserted = TRUE;
};
$this->addEventTestListener($assert_excluded, PreCreateEvent::class);
$this->addEventTestListener($assert_excluded);
$stage = $this->createStage();
$stage->create();
$this->assertTrue($asserted);
$asserted = FALSE;
$stage->require([
'ext-json:*',
]);
$stage->apply();
$this->assertTrue($asserted);
}
/**
* Tests that the failure marker file is excluded using a relative path.
*/
public function testFailureMarkerFileExcluded() : void {
$this->assertResults([]);
/** @var \Drupal\package_manager_bypass\LoggingCommitter $committer */
$committer = $this->container
->get(CommitterInterface::class);
$committer_args = $committer->getInvocationArguments();
$this->assertCount(1, $committer_args);
$this->assertContains('PACKAGE_MANAGER_FAILURE.yml', $committer_args[0][2]);
}
/**
* Tests that if a stage fails to get paths to exclude, throws a stage exception.
*/
public function testFailureCollectPathsToExclude() : void {
$project_root = $this->container
->get(PathLocator::class)
->getProjectRoot();
unlink($project_root . '/composer.json');
$this->expectException(StageException::class);
$this->expectExceptionMessage("composer.json not found.");
$this->createStage()
->create();
}
/**
* Tests that if apply fails to get paths to exclude, throws a stage exception.
*/
public function testFailureCollectPathsToExcludeOnApply() : void {
$stage = $this->createStage();
$stage->create();
$stage->require([
'drupal/random',
]);
$this->expectException(StageException::class);
$this->expectExceptionMessage("composer.json not found.");
unlink($stage->getStageDirectory() . '/composer.json');
$stage->apply();
}
/**
* @covers ::stageDirectoryExists
*/
public function testStageDirectoryExists() : void {
// Ensure that stageDirectoryExists() returns an accurate result during
// pre-create.
$listener = function (StageEvent $event) : void {
$stage = $event->stage;
// The directory should not exist yet, because we are still in pre-create.
$this->assertDirectoryDoesNotExist($stage->getStageDirectory());
$this->assertFalse($stage->stageDirectoryExists());
};
$this->addEventTestListener($listener, PreCreateEvent::class);
$stage = $this->createStage();
$this->assertFalse($stage->stageDirectoryExists());
$stage->create();
$this->assertTrue($stage->stageDirectoryExists());
}
/**
* Tests that destroyed stage directories are actually deleted during cron.
*
* @covers ::destroy
* @covers \Drupal\package_manager\Plugin\QueueWorker\Cleaner
*/
public function testStageDirectoryDeletedDuringCron() : void {
$stage = $this->createStage();
$stage->create();
$dir = $stage->getStageDirectory();
$this->assertDirectoryExists($dir);
$stage->destroy();
// The stage directory should still exist, but the stage should be
// available.
$this->assertTrue($stage->isAvailable());
$this->assertDirectoryExists($dir);
$this->container
->get('cron')
->run();
$this->assertDirectoryDoesNotExist($dir);
}
}
Members
Title Sort descending | Deprecated | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|---|
AssertContentTrait::$content | protected | property | The current raw content. | |||
AssertContentTrait::$drupalSettings | protected | property | The drupalSettings value from the current raw $content. | |||
AssertContentTrait::$elements | protected | property | The XML structure parsed from the current raw $content. | 1 | ||
AssertContentTrait::$plainTextContent | protected | property | The plain-text content of raw $content (text nodes). | |||
AssertContentTrait::assertEscaped | protected | function | Passes if the raw text IS found escaped on the loaded page, fail otherwise. | |||
AssertContentTrait::assertField | protected | function | Asserts that a field exists with the given name or ID. | |||
AssertContentTrait::assertFieldById | Deprecated | protected | function | Asserts that a field exists with the given ID and value. | ||
AssertContentTrait::assertFieldByName | protected | function | Asserts that a field exists with the given name and value. | |||
AssertContentTrait::assertFieldByXPath | protected | function | Asserts that a field exists in the current page by the given XPath. | |||
AssertContentTrait::assertFieldChecked | Deprecated | protected | function | Asserts that a checkbox field in the current page is checked. | ||
AssertContentTrait::assertFieldsByValue | protected | function | Asserts that a field exists in the current page with a given Xpath result. | |||
AssertContentTrait::assertLink | protected | function | Passes if a link with the specified label is found. | |||
AssertContentTrait::assertLinkByHref | protected | function | Passes if a link containing a given href (part) is found. | |||
AssertContentTrait::assertNoDuplicateIds | Deprecated | protected | function | Asserts that each HTML ID is used for just a single element. | ||
AssertContentTrait::assertNoEscaped | protected | function | Passes if raw text IS NOT found escaped on loaded page, fail otherwise. | |||
AssertContentTrait::assertNoField | Deprecated | protected | function | Asserts that a field does not exist with the given name or ID. | ||
AssertContentTrait::assertNoFieldById | Deprecated | protected | function | Asserts that a field does not exist with the given ID and value. | ||
AssertContentTrait::assertNoFieldByName | Deprecated | protected | function | Asserts that a field does not exist with the given name and value. | ||
AssertContentTrait::assertNoFieldByXPath | Deprecated | protected | function | Asserts that a field does not exist or its value does not match, by XPath. | ||
AssertContentTrait::assertNoFieldChecked | Deprecated | protected | function | Asserts that a checkbox field in the current page is not checked. | ||
AssertContentTrait::assertNoLink | protected | function | Passes if a link with the specified label is not found. | |||
AssertContentTrait::assertNoLinkByHref | Deprecated | protected | function | Passes if a link containing a given href (part) is not found. | ||
AssertContentTrait::assertNoLinkByHrefInMainRegion | Deprecated | protected | function | Passes if a link containing a given href is not found in the main region. | ||
AssertContentTrait::assertNoOption | Deprecated | protected | function | Asserts that a select option in the current page does not exist. | ||
AssertContentTrait::assertNoOptionSelected | Deprecated | protected | function | Asserts that a select option in the current page is not checked. | ||
AssertContentTrait::assertNoPattern | protected | function | Triggers a pass if the perl regex pattern is not found in raw content. | |||
AssertContentTrait::assertNoRaw | protected | function | Passes if the raw text is NOT found on the loaded page, fail otherwise. | |||
AssertContentTrait::assertNoText | protected | function | Passes if the page (with HTML stripped) does not contains the text. | |||
AssertContentTrait::assertNoTitle | protected | function | Pass if the page title is not the given string. | |||
AssertContentTrait::assertNoUniqueText | Deprecated | protected | function | Passes if the text is found MORE THAN ONCE on the text version of the page. | ||
AssertContentTrait::assertOption | protected | function | Asserts that a select option in the current page exists. | |||
AssertContentTrait::assertOptionByText | Deprecated | protected | function | Asserts that a select option with the visible text exists. | ||
AssertContentTrait::assertOptionSelected | Deprecated | protected | function | Asserts that a select option in the current page is checked. | ||
AssertContentTrait::assertOptionSelectedWithDrupalSelector | Deprecated | protected | function | Asserts that a select option in the current page is checked. | ||
AssertContentTrait::assertOptionWithDrupalSelector | protected | function | Asserts that a select option in the current page exists. | |||
AssertContentTrait::assertPattern | protected | function | Triggers a pass if the Perl regex pattern is found in the raw content. | |||
AssertContentTrait::assertRaw | protected | function | Passes if the raw text IS found on the loaded page, fail otherwise. | |||
AssertContentTrait::assertText | protected | function | Passes if the page (with HTML stripped) contains the text. | |||
AssertContentTrait::assertTextHelper | protected | function | Helper for assertText and assertNoText. | |||
AssertContentTrait::assertTextPattern | Deprecated | protected | function | Asserts that a Perl regex pattern is found in the plain-text content. | ||
AssertContentTrait::assertThemeOutput | protected | function | Asserts themed output. | |||
AssertContentTrait::assertTitle | protected | function | Pass if the page title is the given string. | |||
AssertContentTrait::assertUniqueText | Deprecated | protected | function | Passes if the text is found ONLY ONCE on the text version of the page. | ||
AssertContentTrait::assertUniqueTextHelper | Deprecated | protected | function | Helper for assertUniqueText and assertNoUniqueText. | ||
AssertContentTrait::buildXPathQuery | protected | function | Builds an XPath query. | |||
AssertContentTrait::constructFieldXpath | protected | function | Helper: Constructs an XPath for the given set of attributes and value. | |||
AssertContentTrait::cssSelect | protected | function | Searches elements using a CSS selector in the raw content. | |||
AssertContentTrait::getAllOptions | protected | function | Get all option elements, including nested options, in a select. | |||
AssertContentTrait::getDrupalSettings | protected | function | Gets the value of drupalSettings for the currently-loaded page. | |||
AssertContentTrait::getRawContent | protected | function | Gets the current raw content. | |||
AssertContentTrait::getSelectedItem | protected | function | Get the selected value from a select field. | |||
AssertContentTrait::getTextContent | protected | function | Retrieves the plain-text content from the current raw content. | |||
AssertContentTrait::parse | protected | function | Parse content returned from curlExec using DOM and SimpleXML. | |||
AssertContentTrait::removeWhiteSpace | protected | function | Removes all white-space between HTML tags from the raw content. | |||
AssertContentTrait::setDrupalSettings | protected | function | Sets the value of drupalSettings for the currently-loaded page. | |||
AssertContentTrait::setRawContent | protected | function | Sets the raw content (e.g. HTML). | |||
AssertContentTrait::xpath | protected | function | Performs an xpath search on the contents of the internal browser. | |||
AssertPreconditionsTrait::assertNoFailureMarker | private static | function | Asserts that there is no failure marker present. | |||
AssertPreconditionsTrait::failIfUnmetPreConditions | protected static | function | Asserts universal test preconditions before any setup is done. | |||
AssertPreconditionsTrait::getProjectRoot | private static | function | Returns the absolute path of the project root. | |||
AssertPreconditionsTrait::setUpBeforeClass | public static | function | Invokes the test preconditions assertion before the first test is run. | |||
ComposerStagerTestTrait::createComposeStagerMessage | protected | function | Creates a Composer Stager translatable message. | |||
ConfigTestTrait::configImporter | protected | function | Returns a ConfigImporter object to import test configuration. | |||
ConfigTestTrait::copyConfig | protected | function | Copies configuration objects from source storage to target storage. | |||
ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. | |||
ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. | |||
ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. | |||
ExtensionListTestTrait::getModulePath | protected | function | Gets the path for the specified module. | |||
ExtensionListTestTrait::getThemePath | protected | function | Gets the path for the specified theme. | |||
FixtureManipulatorTrait::getStageFixtureManipulator | protected | function | Gets the stage fixture manipulator service. | |||
FixtureUtilityTrait::copyFixtureFilesTo | protected static | function | Mirrors a fixture directory to the given path. | |||
FixtureUtilityTrait::renameGitDirectories | private static | function | Renames _git directories to .git. | |||
FixtureUtilityTrait::renameInfoYmlFiles | protected static | function | Renames all files that end with .info.yml.hide. | |||
KernelTestBase::$classLoader | protected | property | ||||
KernelTestBase::$configImporter | protected | property | @todo Move into Config test base class. | 6 | ||
KernelTestBase::$configSchemaCheckerExclusions | protected static | property | An array of config object names that are excluded from schema checking. | 4 | ||
KernelTestBase::$container | protected | property | ||||
KernelTestBase::$databasePrefix | protected | property | ||||
KernelTestBase::$keyValue | protected | property | The key_value service that must persist between container rebuilds. | |||
KernelTestBase::$root | protected | property | The app root. | |||
KernelTestBase::$siteDirectory | protected | property | ||||
KernelTestBase::$strictConfigSchema | protected | property | Set to TRUE to strict check all configuration saved. | 10 | ||
KernelTestBase::$usesSuperUserAccessPolicy | protected | property | Set to TRUE to make user 1 a super user. | 2 | ||
KernelTestBase::$vfsRoot | protected | property | The virtual filesystem root directory. | |||
KernelTestBase::assertPostConditions | protected | function | 1 | |||
KernelTestBase::bootEnvironment | protected | function | Bootstraps a basic test environment. | |||
KernelTestBase::bootKernel | protected | function | Bootstraps a kernel for a test. | 1 | ||
KernelTestBase::config | protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |||
KernelTestBase::disableModules | protected | function | Disables modules for this test. | |||
KernelTestBase::getConfigSchemaExclusions | protected | function | Gets the config schema exclusions for this test. | |||
KernelTestBase::getDatabaseConnectionInfo | protected | function | Returns the Database connection info to be used for this test. | 2 | ||
KernelTestBase::getDatabasePrefix | public | function | ||||
KernelTestBase::getExtensionsForModules | private | function | Returns Extension objects for $modules to install. | |||
KernelTestBase::getModulesToEnable | private static | function | Returns the modules to install for this test. | |||
KernelTestBase::initFileCache | protected | function | Initializes the FileCache component. | |||
KernelTestBase::installConfig | protected | function | Installs default configuration for a given list of modules. | |||
KernelTestBase::installEntitySchema | protected | function | Installs the storage schema for a specific entity type. | |||
KernelTestBase::installSchema | protected | function | Installs database tables from a module schema definition. | |||
KernelTestBase::render | protected | function | Renders a render array. | 1 | ||
KernelTestBase::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | |||
KernelTestBase::setInstallProfile | protected | function | Sets the install profile and rebuilds the container to update it. | |||
KernelTestBase::setSetting | protected | function | Sets an in-memory Settings variable. | |||
KernelTestBase::setUpFilesystem | protected | function | Sets up the filesystem, so things like the file directory. | 3 | ||
KernelTestBase::tearDownCloseDatabaseConnection | public | function | Additional tear down method to close the connection at the end. | |||
KernelTestBase::vfsDump | protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |||
KernelTestBase::__construct | public | function | ||||
KernelTestBase::__sleep | public | function | Prevents serializing any properties. | |||
PackageManagerKernelTestBase::$client | private | property | The mocked HTTP client that returns metadata about available updates. | |||
PackageManagerKernelTestBase::$disableValidators | protected | property | The service IDs of any validators to disable. | |||
PackageManagerKernelTestBase::$failureLogger | protected | property | A logger that will fail the test if Package Manager logs any errors. | |||
PackageManagerKernelTestBase::$fileSystem | private | property | The Symfony filesystem class. | |||
PackageManagerKernelTestBase::$testProjectRoot | protected | property | The test root directory, if any, created by ::createTestProject(). | |||
PackageManagerKernelTestBase::addEventTestListener | protected | function | Adds an event listener on an event for testing purposes. | |||
PackageManagerKernelTestBase::assertEventPropagationStopped | protected | function | Asserts event propagation is stopped by a certain event subscriber. | |||
PackageManagerKernelTestBase::assertExpectedResultsFromException | protected | function | Asserts that a StageEventException has a particular set of results. | |||
PackageManagerKernelTestBase::assertResults | protected | function | Asserts validation results are returned from a stage life cycle event. | |||
PackageManagerKernelTestBase::assertStatusCheckResults | protected | function | Asserts validation results are returned from the status check event. | |||
PackageManagerKernelTestBase::createStage | protected | function | Creates a stage object for testing purposes. | |||
PackageManagerKernelTestBase::createTestProject | protected | function | Creates a test project. | 1 | ||
PackageManagerKernelTestBase::enableModules | protected | function | Enables modules for this test. | Overrides KernelTestBase::enableModules | ||
PackageManagerKernelTestBase::registerPostUpdateFunctions | protected | function | Marks all pending post-update functions as completed. | |||
PackageManagerKernelTestBase::setCoreVersion | protected | function | Sets the current (running) version of core, as known to the Update module. | |||
PackageManagerKernelTestBase::setReleaseMetadata | protected | function | Sets the release metadata file to use when fetching available updates. | |||
PackageManagerKernelTestBase::setUp | protected | function | Overrides KernelTestBase::setUp | 12 | ||
PackageManagerKernelTestBase::tearDown | protected | function | Invokes the test preconditions assertion after each test run. | Overrides AssertPreconditionsTrait::tearDown | 2 | |
RandomGeneratorTrait::getRandomGenerator | protected | function | Gets the random generator for the utility methods. | |||
RandomGeneratorTrait::randomMachineName | protected | function | Generates a unique random string containing letters and numbers. | |||
RandomGeneratorTrait::randomObject | public | function | Generates a random PHP object. | |||
RandomGeneratorTrait::randomString | public | function | Generates a pseudo-random string of ASCII characters of codes 32 to 126. | |||
StageBaseTest::$modules | protected static | property | Modules to install. | Overrides PackageManagerKernelTestBase::$modules | ||
StageBaseTest::providerFailureDuringComposerStagerOperations | public static | function | Data provider for ::testFailureDuringComposerStagerOperations(). | |||
StageBaseTest::providerStoreDestroyInfo | public static | function | Data provider for testStoreDestroyInfo(). | |||
StageBaseTest::register | public | function | Registers test-specific services. | Overrides PackageManagerKernelTestBase::register | ||
StageBaseTest::testCollectPathsToExclude | public | function | Tests that paths to exclude are collected before create and apply. | |||
StageBaseTest::testFailureCollectPathsToExclude | public | function | Tests that if a stage fails to get paths to exclude, throws a stage exception. | |||
StageBaseTest::testFailureCollectPathsToExcludeOnApply | public | function | Tests that if apply fails to get paths to exclude, throws a stage exception. | |||
StageBaseTest::testFailureDuringComposerStagerOperations | public | function | Tests when Composer Stager throws an exception during an operation. | |||
StageBaseTest::testFailureMarkerFileExcluded | public | function | Tests that the failure marker file is excluded using a relative path. | |||
StageBaseTest::testFailureMarkerPreventsCreate | public | function | Tests that if a stage fails to apply, another stage cannot be created. | |||
StageBaseTest::testGetStageDirectory | public | function | @covers ::getStageDirectory | |||
StageBaseTest::testMetadata | public | function | @covers ::getMetadata @covers ::setMetadata |
|||
StageBaseTest::testNoFailureFileOnSuccess | public | function | Tests that the failure marker file doesn't exist if apply succeeds. | |||
StageBaseTest::testStageDirectoryDeletedDuringCron | public | function | Tests that destroyed stage directories are actually deleted during cron. | |||
StageBaseTest::testStageDirectoryExists | public | function | @covers ::stageDirectoryExists | |||
StageBaseTest::testStoreDestroyInfo | public | function | Tests exceptions thrown because of previously destroyed stage. | |||
StageBaseTest::testTempStoreMessageExpired | public | function | Tests exception message once temp store message has expired. | |||
StageBaseTest::testTimeouts | public | function | Tests that Composer Stager is invoked with a long timeout. | |||
StageBaseTest::testUncreatedGetStageDirectory | public | function | @covers ::getStageDirectory | |||
StatusCheckTrait::runStatusCheck | protected | function | Runs a status check for a stage and returns the results, if any. | |||
StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. | |||
StringTranslationTrait::$stringTranslation | protected | property | The string translation service. | 3 | ||
StringTranslationTrait::formatPlural | protected | function | Formats a string containing a count of items. | |||
StringTranslationTrait::getNumberOfPlurals | protected | function | Returns the number of plurals supported by a given language. | |||
StringTranslationTrait::getStringTranslation | protected | function | Gets the string translation service. | |||
StringTranslationTrait::setStringTranslation | public | function | Sets the string translation service to use. | 2 | ||
StringTranslationTrait::t | protected | function | Translates a string to the current language or to a given language. | 1 | ||
TestRequirementsTrait::getDrupalRoot | protected static | function | Returns the Drupal root directory. | |||
ValidationTestTrait::assertValidationResultsEqual | protected | function | Asserts two validation result sets are equal. | |||
ValidationTestTrait::getValidationResultsAsArray | protected | function | Gets an array representation of validation results for easy comparison. | |||
ValidationTestTrait::resolvePlaceholdersInArrayValuesWithRealPaths | protected | function | Resolves <PROJECT_ROOT>, <VENDOR_DIR>, <STAGE_ROOT>, <STAGE_ROOT_PARENT>. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.