class SandboxManagerBaseTest
Same name in this branch
- main core/modules/package_manager/tests/src/Unit/SandboxManagerBaseTest.php \Drupal\Tests\package_manager\Unit\SandboxManagerBaseTest
Same name and namespace in other branches
- 11.x core/modules/package_manager/tests/src/Unit/SandboxManagerBaseTest.php \Drupal\Tests\package_manager\Unit\SandboxManagerBaseTest
- 11.x core/modules/package_manager/tests/src/Kernel/SandboxManagerBaseTest.php \Drupal\Tests\package_manager\Kernel\SandboxManagerBaseTest
Tests Drupal\package_manager\SandboxManagerBase.
@internal
Attributes
#[CoversClass(SandboxManagerBase::class)]
#[Group('package_manager')]
#[Group('#slow')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\Tests\DrupalTestCase uses \Drupal\Tests\DrupalTestCaseTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \Drupal\Tests\DrupalTestCase
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase 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 extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\package_manager\Kernel\SandboxManagerBaseTest uses \Drupal\Core\StringTranslation\StringTranslationTrait extends \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase
- class \Drupal\Tests\package_manager\Kernel\PackageManagerKernelTestBase 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 extends \Drupal\KernelTests\KernelTestBase
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \Drupal\Tests\DrupalTestCase
Expanded class hierarchy of SandboxManagerBaseTest
File
-
core/
modules/ package_manager/ tests/ src/ Kernel/ SandboxManagerBaseTest.php, line 31
Namespace
Drupal\Tests\package_manager\KernelView source
class SandboxManagerBaseTest extends PackageManagerKernelTestBase {
use StringTranslationTrait;
/**
* {@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');
}
/**
* Tests metadata.
*
* @legacy-covers ::getMetadata
* @legacy-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());
}
}
/**
* Tests get sandbox directory.
*/
public function testGetSandboxDirectory() : 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->getSandboxDirectory();
$this->assertStringStartsWith($path_locator->getStagingRoot() . '/', $stage_dir);
$this->assertStringEndsWith("/sandbox_directory", $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->getSandboxDirectory());
$stage->destroy();
// ...but a new stage should be.
$stage = $this->createStage();
$another_id = $stage->create();
$this->assertNotSame($id, $another_id);
$stage_dir = $stage->getSandboxDirectory();
$this->assertStringStartsWith(realpath($new_staging_root), $stage_dir);
$this->assertStringEndsWith("/sandbox_directory", $stage_dir);
}
/**
* 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]));
}
}
/**
* 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.
*/
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(SandboxException::class);
$this->expectExceptionMessageIs($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(SandboxException::class);
$this->expectExceptionMessageIs('Cannot claim the stage because no stage has been created.');
$stage->claim($stage_id);
}
/**
* 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 stage directory exists.
*
* @legacy-covers ::sandboxDirectoryExists
*/
public function testStageDirectoryExists() : void {
// Ensure that sandboxDirectoryExists() returns an accurate result during
// pre-create.
$listener = function (SandboxEvent $event) : void {
$stage = $event->sandboxManager;
// The directory should not exist yet, because we are still in pre-create.
$this->assertDirectoryDoesNotExist($stage->getSandboxDirectory());
$this->assertFalse($stage->sandboxDirectoryExists());
};
$this->addEventTestListener($listener, PreCreateEvent::class);
$stage = $this->createStage();
$this->assertFalse($stage->sandboxDirectoryExists());
$stage->create();
$this->assertTrue($stage->sandboxDirectoryExists());
// After destroy(), the directory still physically exists on disk (long-lived
// sandbox), but sandboxDirectoryExists() should return FALSE because there
// is no active lock.
$dir = $stage->getSandboxDirectory();
$stage->destroy();
$this->assertDirectoryExists($dir);
$this->assertTrue($stage->isAvailable());
$this->assertFalse($stage->sandboxDirectoryExists());
}
/**
* Tests that destroyed stage directories are actually deleted during cron.
*
* @legacy-covers ::destroy
* @legacy-covers \Drupal\package_manager\Hook\CronHook
*/
public function testStageDirectoryDeletedDuringCron() : void {
$stage = $this->createStage();
$stage->create();
$dir = $stage->getSandboxDirectory();
$this->assertDirectoryExists($dir);
$stage->destroy();
// The stage directory should still exist, but the stage should be
// available.
$this->assertTrue($stage->isAvailable());
$this->assertDirectoryExists($dir);
// The stage directory should still exist (by default) up to 14 days since
// the last $stage->create() was run.
$fresh_directory_age = time() - 13 * 24 * 60 * 60;
$this->container
->get('state')
->set(LongLivedSandboxSubscriber::STATE_KEY, $fresh_directory_age);
$this->container
->get('cron')
->run();
$this->assertDirectoryExists($dir);
$stale_directory_age = time() - 15 * 24 * 60 * 60;
$this->container
->get('state')
->set(LongLivedSandboxSubscriber::STATE_KEY, $stale_directory_age);
$this->container
->get('cron')
->run();
$this->assertDirectoryDoesNotExist($dir);
}
/**
* Tests that the sandbox directory persists after destroy and is reused.
*
* The long-lived sandbox directory should survive destroy() and be reused
* across create/destroy cycles.
*
* @legacy-covers ::getSandboxDirectory
* @legacy-covers ::destroy
* @legacy-covers ::create
*/
public function testSandboxDirectoryPersistsAndIsReused() : void {
$stage = $this->createStage();
$stage->create();
$first_dir = $stage->getSandboxDirectory();
$this->assertDirectoryExists($first_dir);
// Place a marker file in the sandbox directory.
file_put_contents($first_dir . '/marker.txt', 'test');
$stage->destroy();
// Directory and its contents should persist after destroy.
$this->assertDirectoryExists($first_dir);
$this->assertFileExists($first_dir . '/marker.txt');
// A second create should succeed with the existing directory and use the
// exact same path.
$stage = $this->createStage();
$stage->create();
$this->assertSame($first_dir, $stage->getSandboxDirectory());
$this->assertDirectoryExists($first_dir);
$stage->destroy();
}
/**
* Tests that getSandboxDirectory() works without a lock.
*
* The sandbox directory path should be deterministic and accessible without
* creating or claiming the stage, since other components (CronHook,
* LongLivedSandboxSubscriber) need to check the path for cleanup decisions.
*
* @legacy-covers ::getSandboxDirectory
*/
public function testGetSandboxDirectoryWithoutLock() : void {
$stage = $this->createStage();
// getSandboxDirectory() should work without creating/claiming the stage.
$dir = $stage->getSandboxDirectory();
$this->assertStringEndsWith('/sandbox_directory', $dir);
// The returned path should be consistent.
$this->assertSame($dir, $stage->getSandboxDirectory());
}
/**
* Tests that getStagingRoot() does not pollute tempstore without a lock.
*
* When getSandboxDirectory() is called without a lock (e.g. from CronHook),
* it should NOT cache the staging root in the shared tempstore, since that
* would pollute state visible to other stage operations.
*
* @legacy-covers ::getSandboxDirectory
*/
public function testGetStagingRootDoesNotPolluteTempstore() : void {
$stage = $this->createStage();
$tempstore = $this->container
->get('tempstore.shared')
->get('package_manager_stage');
// Before any create, call getSandboxDirectory() which internally calls
// getStagingRoot(). This should NOT write to tempstore.
$stage->getSandboxDirectory();
$this->assertNull($tempstore->get('staging_root'));
// After creating the stage (which acquires a lock), the staging root
// should be cached in tempstore.
$stage->create();
$this->assertNotNull($tempstore->get('staging_root'));
$stage->destroy();
}
/**
* Tests that LongLivedSandboxSubscriber tracks the create event time.
*
* @legacy-covers \Drupal\package_manager\EventSubscriber\LongLivedSandboxSubscriber
*/
public function testLongLivedSandboxSubscriberTracksTime() : void {
$state = $this->container
->get('state');
// No timestamp should exist before any stage is created.
$this->assertNull($state->get(LongLivedSandboxSubscriber::STATE_KEY));
$stage = $this->createStage();
$stage->create();
// After creating a stage, the timestamp should be set.
/** @var int $timestamp */
$timestamp = $state->get(LongLivedSandboxSubscriber::STATE_KEY);
$this->assertNotNull($timestamp);
$this->assertIsInt($timestamp);
$this->assertGreaterThan(0, $timestamp);
$stage->destroy();
// The timestamp should persist after destroy, since it tracks the age
// of the long-lived sandbox directory.
$this->assertSame($timestamp, $state->get(LongLivedSandboxSubscriber::STATE_KEY));
}
/**
* Tests that cron does not delete the sandbox when no create event occurred.
*
* If there's no recorded create event in state (e.g. state was cleared),
* cron should not attempt to delete the sandbox directory even if it exists.
*
* @legacy-covers \Drupal\package_manager\Hook\CronHook
*/
public function testCronDoesNotDeleteWithoutCreateEvent() : void {
$stage = $this->createStage();
$stage->create();
$dir = $stage->getSandboxDirectory();
$this->assertDirectoryExists($dir);
$stage->destroy();
// Clear the create event timestamp from state.
$this->container
->get('state')
->delete(LongLivedSandboxSubscriber::STATE_KEY);
// Cron should not delete the sandbox directory without a create event.
$this->container
->get('cron')
->run();
$this->assertDirectoryExists($dir);
}
/**
* Tests that the sandbox directory is deleted on config change.
*
* When 'include_unknown_files_in_project_root' is changed to FALSE, the
* sandbox directory should be deleted directly to ensure unknown files
* from a previous sync are not retained.
*
* @legacy-covers \Drupal\package_manager\EventSubscriber\LongLivedSandboxSubscriber
*/
public function testConfigChangeDeletesSandbox() : void {
$stage = $this->createStage();
$stage->create();
$dir = $stage->getSandboxDirectory();
$this->assertDirectoryExists($dir);
$stage->destroy();
$this->assertDirectoryExists($dir);
// First enable the setting, then disable it to trigger the subscriber.
$config = $this->config('package_manager.settings');
$config->set('include_unknown_files_in_project_root', TRUE)
->save();
// Directory should still exist after enabling.
$this->assertDirectoryExists($dir);
// Disabling should delete the sandbox directory immediately.
$config->set('include_unknown_files_in_project_root', FALSE)
->save();
$this->assertDirectoryDoesNotExist($dir);
// The create event timestamp should also be cleared.
$this->assertNull($this->container
->get('state')
->get(LongLivedSandboxSubscriber::STATE_KEY));
}
/**
* Tests that config change does not trigger deletion while stage is active.
*
* If a stage is in use (locked), the sandbox should not be deleted even if
* the config setting changes.
*
* @legacy-covers \Drupal\package_manager\EventSubscriber\LongLivedSandboxSubscriber
*/
public function testConfigChangeDoesNotDeleteWhileStageIsActive() : void {
$stage = $this->createStage();
$stage->create();
$dir = $stage->getSandboxDirectory();
// Set up a listener that changes the config setting during pre-apply,
// while the stage is active. This verifies the LongLivedSandboxSubscriber
// respects the isAvailable check.
$config = $this->config('package_manager.settings');
$config->set('include_unknown_files_in_project_root', TRUE)
->save();
$this->addEventTestListener(function () use ($config) : void {
$config->set('include_unknown_files_in_project_root', FALSE)
->save();
});
$stage->require([
'ext-json:*',
]);
$stage->apply();
// The sandbox directory should still exist because the stage was active.
$this->assertDirectoryExists($dir);
}
/**
* Tests that cron does not delete the sandbox while the stage is active.
*
* If the stage is locked (not available), cron should not delete the sandbox
* directory even if it is older than the configured maximum age.
*
* @legacy-covers \Drupal\package_manager\Hook\CronHook
*/
public function testCronDoesNotDeleteWhileStageIsActive() : void {
$stage = $this->createStage();
$stage->create();
$dir = $stage->getSandboxDirectory();
$this->assertDirectoryExists($dir);
// Set the create event timestamp to well beyond the max age.
$stale_directory_age = time() - 30 * 24 * 60 * 60;
$this->container
->get('state')
->set(LongLivedSandboxSubscriber::STATE_KEY, $stale_directory_age);
// Run cron while the stage is still active (not destroyed).
$this->assertFalse($stage->isAvailable());
$this->container
->get('cron')
->run();
// The sandbox directory should still exist because the stage is locked.
$this->assertDirectoryExists($dir);
$stage->destroy();
}
/**
* Tests that config change is a no-op when no sandbox directory exists.
*
* When 'include_unknown_files_in_project_root' is changed to FALSE but no
* sandbox directory exists on disk, the subscriber should do nothing.
*
* @legacy-covers \Drupal\package_manager\EventSubscriber\LongLivedSandboxSubscriber
*/
public function testConfigChangeNoOpWithoutSandboxDirectory() : void {
$stage = $this->createStage();
$dir = $stage->getSandboxDirectory();
// Verify no sandbox directory exists on disk.
$this->assertDirectoryDoesNotExist($dir);
// Changing the config setting should not cause any errors.
$config = $this->config('package_manager.settings');
$config->set('include_unknown_files_in_project_root', TRUE)
->save();
$config->set('include_unknown_files_in_project_root', FALSE)
->save();
// Still no directory and no errors.
$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. | |||
| 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::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::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::assertNoLink | protected | function | Passes if a link with the specified label is not found. | |||
| 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::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::assertThemeOutput | protected | function | Asserts themed output. | |||
| AssertContentTrait::assertTitle | protected | function | Pass if the page title is the given string. | |||
| 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::getSimpleXmlElementsByXpath | protected | function | Performs an xpath search on the contents of the internal browser. | |||
| 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 | Deprecated | 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. | |||
| BrowserHtmlDebugTrait::$htmlOutputBaseUrl | protected | property | The Base URI to use for links to the output files. | |||
| BrowserHtmlDebugTrait::$htmlOutputClassName | protected | property | Class name for HTML output logging. | |||
| BrowserHtmlDebugTrait::$htmlOutputCounter | protected | property | Counter for HTML output logging. | |||
| BrowserHtmlDebugTrait::$htmlOutputCounterStorage | protected | property | Counter storage for HTML output logging. | |||
| BrowserHtmlDebugTrait::$htmlOutputDirectory | protected | property | Directory name for HTML output logging. | |||
| BrowserHtmlDebugTrait::$htmlOutputEnabled | protected | property | HTML output enabled. | |||
| BrowserHtmlDebugTrait::$htmlOutputTestId | protected | property | HTML output test ID. | |||
| BrowserHtmlDebugTrait::formatHtmlOutputHeaders | protected | function | Formats HTTP headers as string for HTML output logging. | |||
| BrowserHtmlDebugTrait::getHtmlOutputHeaders | protected | function | Returns headers in HTML output format. | 1 | ||
| BrowserHtmlDebugTrait::getResponseLogHandler | protected | function | Provides a Guzzle middleware handler to log every response received. | |||
| BrowserHtmlDebugTrait::getTestMethodCaller | protected | function | Retrieves the current calling line in the class under test. | 1 | ||
| BrowserHtmlDebugTrait::htmlOutput | protected | function | Logs a HTML output message in a text file. | |||
| BrowserHtmlDebugTrait::initBrowserOutputFile | protected | function | Creates the directory to store browser output. | |||
| 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. | |||
| DrupalTestCase::$root | protected | property | The Drupal root directory. | |||
| DrupalTestCase::getDrupalRoot | Deprecated | protected | function | Returns the Drupal root directory. | 1 | |
| DrupalTestCase::setUpRoot | final protected | function | Ensure that the $root property is set initially. | |||
| DrupalTestCase::skipTestWithAttribute | final protected | function | Supports skipping tests with the Skip attribute. | |||
| DrupalTestCaseTrait::checkErrorHandlerOnTearDown | public | function | Checks the test error handler after test execution. | 1 | ||
| DrupalTestCaseTrait::setDebugDumpHandler | public static | function | Registers the dumper CLI handler when the DebugDump extension is enabled. | |||
| 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. | |||
| ForwardCompatibilityTrait::expectExceptionMessageIs | protected | function | Expects an exactly matching exception message. | |||
| ForwardCompatibilityTrait::expectExceptionMessageIsOrContains | protected | function | Expects an exception message containing a specified string. | |||
| HttpKernelUiHelperTrait::$mink | protected | property | Mink session manager. | |||
| HttpKernelUiHelperTrait::assertSession | public | function | Returns WebAssert object. | |||
| HttpKernelUiHelperTrait::buildUrl | protected | function | Builds a URL from a system path or a URL object. | |||
| HttpKernelUiHelperTrait::clickLink | protected | function | Follows a link by complete name. | |||
| HttpKernelUiHelperTrait::drupalGet | protected | function | Retrieves a Drupal path. | |||
| HttpKernelUiHelperTrait::getDefaultDriverInstance | protected | function | Gets an instance of the default Mink driver. | |||
| HttpKernelUiHelperTrait::getNodeElementsByXpath | protected | function | Performs an xpath search on the contents of the internal browser. | |||
| HttpKernelUiHelperTrait::getSession | public | function | Returns Mink session. | |||
| HttpKernelUiHelperTrait::getUrl | protected | function | Gets the current URL from the browser. | |||
| HttpKernelUiHelperTrait::initMink | protected | function | Initializes Mink sessions. | |||
| HttpKernelUiHelperTrait::rebuildContainer | protected | function | Rebuilds the container. | |||
| KernelTestBase::$classLoader | protected | property | The class loader. | |||
| KernelTestBase::$configImporter | protected | property | The configuration importer. | |||
| KernelTestBase::$configSchemaCheckerExclusions | protected static | property | An array of config object names that are excluded from schema checking. | 4 | ||
| KernelTestBase::$container | protected | property | The test container. | |||
| KernelTestBase::$databasePrefix | protected | property | The test database prefix. | |||
| KernelTestBase::$environmentTables | private | property | The names of the tables that make up the shared environment. | |||
| KernelTestBase::$keyValue | protected | property | The key value factory of the container that booted the test method. | |||
| KernelTestBase::$siteDirectory | protected | property | The relative path to the test site directory. | |||
| KernelTestBase::$strictConfigSchema | protected | property | Set to TRUE to strict check all configuration saved. | 9 | ||
| KernelTestBase::$usesSuperUserAccessPolicy | protected | property | Set to TRUE to make user 1 a super user. | 1 | ||
| KernelTestBase::$vfsRoot | protected | property | The virtual filesystem root directory. | |||
| KernelTestBase::allocateSharedDatabase | public static | function | Allocates one database prefix for the whole test class. | |||
| 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::checkNoSharedTableWasDropped | protected | function | Fails when a test method dropped a table of the shared environment. | |||
| KernelTestBase::checkNoTableWasLeftBehind | protected | function | Fails when a test method left a table behind. | |||
| KernelTestBase::checkSharedDatabaseState | private | function | Checks the shared database state after a test method has run. | |||
| KernelTestBase::config | protected | function | Configuration accessor for tests. Returns non-overridden configuration. | |||
| KernelTestBase::createStateTable | private | function | Creates the table recording the state of the shared database. | |||
| 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. | 3 | ||
| KernelTestBase::getDatabasePrefix | public | function | Gets the database prefix used for test isolation. | |||
| KernelTestBase::getExtensionsForModules | private | function | Returns Extension objects for $modules to install. | |||
| KernelTestBase::getModulesToEnable | protected static | function | Returns the modules to install for this test. | |||
| KernelTestBase::getSharedStateTables | private | function | Returns the tables that make up the shared database state. | |||
| KernelTestBase::getTestDatabase | protected | function | Returns the test database for this test. | |||
| KernelTestBase::INFRASTRUCTURE_TABLES | protected | constant | Tables that Drupal creates on its own, whatever a test method does. | |||
| 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::invalidateDatabaseState | protected | function | Records that the shared database state can no longer be trusted. | |||
| KernelTestBase::loadSharedDatabaseState | private | function | Reads the record describing the shared database state. | |||
| KernelTestBase::releaseSharedDatabase | public static | function | Drops the tables of the test class once all its test methods have run. | |||
| KernelTestBase::render | protected | function | Renders a render array. | 1 | ||
| KernelTestBase::resetEnvironment | protected | function | Resets the environment after a test method has run. | 4 | ||
| 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::setUpEnvironment | protected | function | Sets up the environment shared by every test method in this class. | 3 | ||
| KernelTestBase::setUpFilesystem | protected | function | Sets up the filesystem, so things like the file directory. | 3 | ||
| KernelTestBase::SHARED_DATABASE_PREFIX_ENV | private | constant | Environment variable carrying the shared prefix from parent to children. | |||
| KernelTestBase::sharesEnvironment | protected static | function | Returns whether this test class shares its environment between its methods. | |||
| KernelTestBase::STATE_TABLE | protected | constant | Name of the table recording the state of the shared database. | |||
| KernelTestBase::tearDownCloseDatabaseConnection | public | function | Additional tear down method to close the connection at the end. | |||
| KernelTestBase::tearDownEnvironment | protected | function | Cleans the environment up after a test method and checks the result. | |||
| KernelTestBase::vfsDump | protected | function | Dumps the current state of the virtual filesystem to STDOUT. | |||
| 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::$modules | protected static | property | Modules to install. | Overrides KernelTestBase::$modules | 5 | |
| 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 for the Update Status module. | |||
| PackageManagerKernelTestBase::setReleaseMetadata | protected | function | Sets the release metadata file to use when fetching available updates. | |||
| PackageManagerKernelTestBase::setUp | protected | function | Overrides KernelTestBase::setUp | 16 | ||
| PackageManagerKernelTestBase::tearDown | protected | function | Invokes the test preconditions assertion after each test run. | Overrides AssertPreconditionsTrait::tearDown | 3 | |
| 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. | |||
| SandboxManagerBaseTest::providerStoreDestroyInfo | public static | function | Data provider for testStoreDestroyInfo(). | |||
| SandboxManagerBaseTest::register | public | function | Registers test-specific services. | Overrides PackageManagerKernelTestBase::register | ||
| SandboxManagerBaseTest::testCollectPathsToExclude | public | function | Tests that paths to exclude are collected before create and apply. | |||
| SandboxManagerBaseTest::testConfigChangeDeletesSandbox | public | function | Tests that the sandbox directory is deleted on config change. | |||
| SandboxManagerBaseTest::testConfigChangeDoesNotDeleteWhileStageIsActive | public | function | Tests that config change does not trigger deletion while stage is active. | |||
| SandboxManagerBaseTest::testConfigChangeNoOpWithoutSandboxDirectory | public | function | Tests that config change is a no-op when no sandbox directory exists. | |||
| SandboxManagerBaseTest::testCronDoesNotDeleteWhileStageIsActive | public | function | Tests that cron does not delete the sandbox while the stage is active. | |||
| SandboxManagerBaseTest::testCronDoesNotDeleteWithoutCreateEvent | public | function | Tests that cron does not delete the sandbox when no create event occurred. | |||
| SandboxManagerBaseTest::testGetSandboxDirectory | public | function | Tests get sandbox directory. | |||
| SandboxManagerBaseTest::testGetSandboxDirectoryWithoutLock | public | function | Tests that getSandboxDirectory() works without a lock. | |||
| SandboxManagerBaseTest::testGetStagingRootDoesNotPolluteTempstore | public | function | Tests that getStagingRoot() does not pollute tempstore without a lock. | |||
| SandboxManagerBaseTest::testLongLivedSandboxSubscriberTracksTime | public | function | Tests that LongLivedSandboxSubscriber tracks the create event time. | |||
| SandboxManagerBaseTest::testMetadata | public | function | Tests metadata. | |||
| SandboxManagerBaseTest::testSandboxDirectoryPersistsAndIsReused | public | function | Tests that the sandbox directory persists after destroy and is reused. | |||
| SandboxManagerBaseTest::testStageDirectoryDeletedDuringCron | public | function | Tests that destroyed stage directories are actually deleted during cron. | |||
| SandboxManagerBaseTest::testStageDirectoryExists | public | function | Tests stage directory exists. | |||
| SandboxManagerBaseTest::testStoreDestroyInfo | public | function | Tests exceptions thrown because of previously destroyed stage. | |||
| SandboxManagerBaseTest::testTempStoreMessageExpired | public | function | Tests exception message once temp store message has expired. | |||
| SandboxManagerBaseTest::testTimeouts | public | function | Tests that Composer Stager is invoked with a long timeout. | |||
| 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 | ||
| 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.