From 934d11ba3eebe1ab4f9a773717f7db14e4c8072e Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 4 Aug 2025 14:35:27 +0200 Subject: [PATCH] run tests with PHPUnit 12.1 on PHP >= 8.3 --- phpunit | 2 +- .../Process/Tests/ExecutableFinderTest.php | 15 ++++-------- .../Process/Tests/Fixtures/open_basedir.php | 23 +++++++++++++++++++ 3 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 src/Symfony/Component/Process/Tests/Fixtures/open_basedir.php diff --git a/phpunit b/phpunit index f606e15485c8c..42b6866d4aa9e 100755 --- a/phpunit +++ b/phpunit @@ -7,7 +7,7 @@ if (!file_exists(__DIR__.'/vendor/symfony/phpunit-bridge/bin/simple-phpunit')) { } if (!getenv('SYMFONY_PHPUNIT_VERSION')) { if (\PHP_VERSION_ID >= 80300) { - putenv('SYMFONY_PHPUNIT_VERSION=12.0'); + putenv('SYMFONY_PHPUNIT_VERSION=12.1'); } else { putenv('SYMFONY_PHPUNIT_VERSION=11.5'); } diff --git a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php index 4ce80f15ba3e8..a605b16183158 100644 --- a/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php +++ b/src/Symfony/Component/Process/Tests/ExecutableFinderTest.php @@ -14,6 +14,7 @@ use PHPUnit\Framework\Attributes\RunInSeparateProcess; use PHPUnit\Framework\TestCase; use Symfony\Component\Process\ExecutableFinder; +use Symfony\Component\Process\Process; /** * @author Chris Smith @@ -122,17 +123,11 @@ public function testFindWithOpenBaseDir() $this->markTestSkipped('Cannot test when open_basedir is set'); } - putenv('PATH='.\dirname(\PHP_BINARY)); - $initialOpenBaseDir = ini_set('open_basedir', \dirname(\PHP_BINARY).\PATH_SEPARATOR.'/'); - - try { - $finder = new ExecutableFinder(); - $result = $finder->find($this->getPhpBinaryName()); + $process = new Process([\PHP_BINARY, '-d', 'open_basedir='.\dirname(\PHP_BINARY).\PATH_SEPARATOR.'/', __DIR__.'/Fixtures/open_basedir.php']); + $process->run(); + $result = $process->getOutput(); - $this->assertSamePath(\PHP_BINARY, $result); - } finally { - ini_set('open_basedir', $initialOpenBaseDir); - } + $this->assertSamePath(\PHP_BINARY, $result); } #[RunInSeparateProcess] diff --git a/src/Symfony/Component/Process/Tests/Fixtures/open_basedir.php b/src/Symfony/Component/Process/Tests/Fixtures/open_basedir.php new file mode 100644 index 0000000000000..d86e66fa2dfe6 --- /dev/null +++ b/src/Symfony/Component/Process/Tests/Fixtures/open_basedir.php @@ -0,0 +1,23 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +require_once __DIR__.'/../../ExecutableFinder.php'; + +use Symfony\Component\Process\ExecutableFinder; + +putenv('PATH='.dirname(PHP_BINARY)); + +function getPhpBinaryName(): string +{ + return basename(PHP_BINARY, '\\' === DIRECTORY_SEPARATOR ? '.exe' : ''); +} + +echo (new ExecutableFinder())->find(getPhpBinaryName());