Skip to content
Snippets Groups Projects
Commit 1eef08b4 authored by catch's avatar catch
Browse files

Issue #3445847 by mstrelan: PHPUnit 10 behaves differently when invoked outside web root

parent 8f25e5c2
No related branches found
No related tags found
No related merge requests found
......@@ -33,9 +33,8 @@ class FileSaveUploadTest extends KernelTestBase {
* {@inheritdoc}
*/
protected function setUp(): void {
\file_put_contents('test.bbb', 'test');
parent::setUp();
\file_put_contents('test.bbb', 'test');
$request = new Request();
$request->files->set('files', [
'file' => new UploadedFile(
......@@ -53,6 +52,14 @@ protected function setUp(): void {
$this->container->set('request_stack', $requestStack);
}
/**
* {@inheritdoc}
*/
protected function tearDown(): void {
\unlink('test.bbb');
parent::tearDown();
}
/**
* Tests file_save_upload() with empty extensions.
*/
......
......@@ -31,6 +31,7 @@ protected function setUp(): void {
// is not the one the test requires, skip before test database
// initialization so to save cycles.
$this->root = static::getDrupalRoot();
chdir($this->root);
$connectionInfo = $this->getDatabaseConnectionInfo();
$test_class_parts = explode('\\', get_class($this));
$expected_provider = $test_class_parts[2] ?? '';
......
......@@ -242,6 +242,7 @@ protected function setUp(): void {
$this->registerComparator(new MarkupInterfaceComparator());
$this->root = static::getDrupalRoot();
chdir($this->root);
$this->initFileCache();
$this->bootEnvironment();
$this->bootKernel();
......
......@@ -352,6 +352,7 @@ protected function setUp(): void {
parent::setUp();
$this->setUpAppRoot();
chdir($this->root);
// Allow tests to compare MarkupInterface objects via assertEquals().
$this->registerComparator(new MarkupInterfaceComparator());
......
......@@ -56,6 +56,7 @@ protected function setUp(): void {
$php_executable_finder = new PhpExecutableFinder();
$this->php = $php_executable_finder->find();
$this->root = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
chdir($this->root);
if (!is_writable("{$this->root}/sites/simpletest")) {
$this->markTestSkipped('This test requires a writable sites/simpletest directory');
}
......
......@@ -62,6 +62,7 @@ protected function setUp(): void {
FileCacheFactory::setPrefix('prefix');
$this->root = dirname(substr(__DIR__, 0, -strlen(__NAMESPACE__)), 2);
chdir($this->root);
}
/**
......
......@@ -183,7 +183,3 @@ class_alias('\Drupal\Tests\DocumentElement', '\Behat\Mink\Element\DocumentElemen
if ($browserTestOutputDirectory !== FALSE) {
HtmlOutputLogger::init($browserTestOutputDirectory, (bool) getenv('BROWSERTEST_OUTPUT_VERBOSE') ?? FALSE);
}
// Drupal expects to be run from its root directory. This ensures all test types
// are consistent.
chdir(dirname(__DIR__, 2));
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment