1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
|
From: William Desportes <williamdes@wdes.fr>
Date: Sun, 13 Apr 2025 13:30:40 +0200
Subject: Fix PHP 8 testing code
Ref: https://github.com/sebastianbergmann/phpunit/issues/5062#issuecomment-1416362657
---
tests/Phing/Test/Task/Optional/RSTTaskTest.php | 2 +-
.../Test/Task/System/Condition/HasFreeSpaceConditionTest.php | 12 +++++++++++-
tests/bootstrap.php | 2 +-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/tests/Phing/Test/Task/Optional/RSTTaskTest.php b/tests/Phing/Test/Task/Optional/RSTTaskTest.php
index ca0d9de..2b9a0b2 100644
--- a/tests/Phing/Test/Task/Optional/RSTTaskTest.php
+++ b/tests/Phing/Test/Task/Optional/RSTTaskTest.php
@@ -38,7 +38,7 @@ class RSTTaskTest extends BuildFileTest
public function setUp(): void
{
//needed for PEAR's System class
- error_reporting(error_reporting() & ~E_STRICT & ~E_DEPRECATED);
+ error_reporting(error_reporting() & ~E_DEPRECATED);
chdir(PHING_TEST_BASE . '/etc/tasks/ext/rst');
$this->configureProject(
diff --git a/tests/Phing/Test/Task/System/Condition/HasFreeSpaceConditionTest.php b/tests/Phing/Test/Task/System/Condition/HasFreeSpaceConditionTest.php
index 831e11b..3156383 100644
--- a/tests/Phing/Test/Task/System/Condition/HasFreeSpaceConditionTest.php
+++ b/tests/Phing/Test/Task/System/Condition/HasFreeSpaceConditionTest.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
namespace Phing\Task\System\Condition;
use Phing\Test\Support\BuildFileTest;
@@ -23,7 +25,15 @@ class HasFreeSpaceConditionTest extends BuildFileTest
public function testInvalidPartition()
{
- $this->expectBuildExceptionContaining(__FUNCTION__, __FUNCTION__, 'disk_free_space(): No such file or directory');
+ $warning = '';
+ set_error_handler(static function (int $errno, string $errstr) use (&$warning): void {
+ $warning = $errstr;
+ }, E_WARNING);
+
+ $this->expectBuildExceptionContaining(__FUNCTION__, __FUNCTION__, 'Error while retrieving free space.');
+ $this->assertSame('disk_free_space(): No such file or directory', $warning);
+
+ restore_error_handler();
}
public function testEnoughSpace()
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 6e51f7f..3b6bef3 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -19,4 +19,4 @@ if (file_exists(__DIR__ . '/../vendor/autoload.php')) {
Phing::setProperty('phing.home', realpath(__DIR__ . '/../'));
Phing::startup();
-error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_STRICT);
+error_reporting(E_ALL & ~E_DEPRECATED & ~E_NOTICE);
|