Skip to content

Commit 934d11b

Browse files
committed
run tests with PHPUnit 12.1 on PHP >= 8.3
1 parent 7b2d29f commit 934d11b

File tree

3 files changed

+29
-11
lines changed

3 files changed

+29
-11
lines changed

phpunit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) {
77
}
88
if (!getenv('SYMFONY_PHPUNIT_VERSION')) {
99
if (\PHP_VERSION_ID >= 80300) {
10-
putenv('SYMFONY_PHPUNIT_VERSION=12.0');
10+
putenv('SYMFONY_PHPUNIT_VERSION=12.1');
1111
} else {
1212
putenv('SYMFONY_PHPUNIT_VERSION=11.5');
1313
}

src/Symfony/Component/Process/Tests/ExecutableFinderTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
1515
use PHPUnit\Framework\TestCase;
1616
use Symfony\Component\Process\ExecutableFinder;
17+
use Symfony\Component\Process\Process;
1718

1819
/**
1920
* @author Chris Smith <chris@cs278.org>
@@ -122,17 +123,11 @@ public function testFindWithOpenBaseDir()
122123
$this->markTestSkipped('Cannot test when open_basedir is set');
123124
}
124125

125-
putenv('PATH='.\dirname(\PHP_BINARY));
126-
$initialOpenBaseDir = ini_set('open_basedir', \dirname(\PHP_BINARY).\PATH_SEPARATOR.'/');
127-
128-
try {
129-
$finder = new ExecutableFinder();
130-
$result = $finder->find($this->getPhpBinaryName());
126+
$process = new Process([\PHP_BINARY, '-d', 'open_basedir='.\dirname(\PHP_BINARY).\PATH_SEPARATOR.'/', __DIR__.'/Fixtures/open_basedir.php']);
127+
$process->run();
128+
$result = $process->getOutput();
131129

132-
$this->assertSamePath(\PHP_BINARY, $result);
133-
} finally {
134-
ini_set('open_basedir', $initialOpenBaseDir);
135-
}
130+
$this->assertSamePath(\PHP_BINARY, $result);
136131
}
137132

138133
#[RunInSeparateProcess]
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
require_once __DIR__.'/../../ExecutableFinder.php';
13+
14+
use Symfony\Component\Process\ExecutableFinder;
15+
16+
putenv('PATH='.dirname(PHP_BINARY));
17+
18+
function getPhpBinaryName(): string
19+
{
20+
return basename(PHP_BINARY, '\\' === DIRECTORY_SEPARATOR ? '.exe' : '');
21+
}
22+
23+
echo (new ExecutableFinder())->find(getPhpBinaryName());

0 commit comments

Comments
 (0)