Skip to content
Snippets Groups Projects

Issue #3328234: Improve test DX *and* confidence: assert VFS state

Compare and Show latest version
1 file
+ 10
30
Compare changes
  • Side-by-side
  • Inline
@@ -55,13 +55,6 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase {
*/
private $client;
/**
* Whether to use VFS.
*
* @var bool
*/
protected $useVfs = FALSE;
/**
* {@inheritdoc}
*/
@@ -239,38 +232,22 @@ abstract class PackageManagerKernelTestBase extends KernelTestBase {
*/
protected function createVirtualProject(?string $source_dir = NULL): void {
$source_dir = $source_dir ?? __DIR__ . '/../../fixtures/fake_site';
if ($this->useVfs) {
$root = $this->vfsRoot->url();
}
else {
$root = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'package_manager_testing_root' . $this->databasePrefix;
$root = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'package_manager_testing_root' . $this->databasePrefix;
$fs = new Filesystem();
if (is_dir($root)) {
$fs = new Filesystem();
if (is_dir($root)) {
$fs = new Filesystem();
$fs->remove($root);
}
$fs->mkdir($root);
$fs->remove($root);
}
$fs->mkdir($root);
// Create the active directory and copy its contents from a fixture.
$active_dir = $root . DIRECTORY_SEPARATOR . 'active';
$this->assertTrue(mkdir($active_dir));
if ($this->useVfs) {
// Move vfs://root/sites to vfs://root/active/sites.
$sites_in_vfs = vfsStream::url('root/sites');
rename($sites_in_vfs, $sites_in_vfs . '/active');
}
static::copyFixtureFilesTo($source_dir, $active_dir);
// Override siteDirectory to point to root/active/... instead of root/... .
if ($this->useVfs) {
$test_site_path = str_replace('vfs://root/', '', $this->siteDirectory);
$this->siteDirectory = vfsStream::url('root/active/' . $test_site_path);
}
else {
$test_site_path = str_replace('vfs://root/', '', $this->siteDirectory);
$this->siteDirectory = $active_dir . $test_site_path;
}
$test_site_path = str_replace('vfs://root/', '', $this->siteDirectory);
$this->siteDirectory = $active_dir . $test_site_path;
// Override KernelTestBase::setUpFilesystem's Settings object.
$settings = Settings::getInstance() ? Settings::getAll() : [];
$settings['file_public_path'] = $this->siteDirectory . '/files';
@@ -426,6 +403,9 @@ final class TestStageValidationException extends StageValidationException {
*/
private $originalException;
/**
*
*/
public function __construct(StageValidationException $original_exception, StageEvent $event) {
parent::__construct($original_exception->getResults(), $original_exception->getMessage(), $original_exception->getCode(), $original_exception);
$this->originalException = $original_exception;
Loading