8000 Fix test with open_basedir · symfony/symfony@08ebeab · GitHub
[go: up one dir, main page]

Skip to content

Commit 08ebeab

Browse files
committed
Fix test with open_basedir
1 parent 15be6a9 commit 08ebeab

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,9 @@ public function testIgnoreVCSIgnoredUpToFirstGitRepositoryRoot()
460460
]), $finder->in(self::toAbsolute('gitignore/git_root/search_root'))->getIterator());
461461
}
462462

463+
/**
464+
* @runInSeparateProcess
465+
*/
463466
public function testIgnoreVCSIgnoredWithOpenBasedir()
464467
{
465468
if (ini_get('open_basedir')) {
@@ -1503,4 +1506,13 @@ protected function buildFinder()
15031506
{
15041507
return Finder::create()->exclude('gitignore');
15051508
}
1509+
1510+
protected function iniSet(string $varName, string $newValue): void
1511+
{
1512+
if ('open_basedir' === $varName && $deprecationsFile = getenv('SYMFONY_DEPRECATIONS_SERIALIZE')) {
1513+
$newValue .= \PATH_SEPARATOR.$deprecationsFile;
1514+
}
1515+
1516+
parent::iniSet('open_basedir', $newValue);
1517+
}
15061518
}
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,15 @@ public static function setUpBeforeClass(): void
9090

9191
public static function tearDownAfterClass(): void
9292
{
93-
$paths = new \RecursiveIteratorIterator(
94-
new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS),
95-
\RecursiveIteratorIterator::CHILD_FIRST
96-
);
93+
try {
94+
$paths = new \RecursiveIteratorIterator(
95+
new \RecursiveDirectoryIterator(self::$tmpDir, \RecursiveDirectoryIterator::SKIP_DOTS),
96+
\RecursiveIteratorIterator::CHILD_FIRST
97+
);
98+
} catch (\UnexpectedValueException $exception) {
99+
// open_basedir restriction in effect
100+
return;
101+
}
97102

98103
foreach ($paths as $path) {
99104
if ($path->isDir()) {