From ee756579a7d9af56f0aa36d4437e5c1c67f42309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Thu, 10 Aug 2023 16:44:43 +0200 Subject: [PATCH] Fix setting static property in tests on PHP 8.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Côme Chilliet --- tests/lib/Files/ViewTest.php | 4 ++-- tests/lib/TestCase.php | 6 +++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 18a6fca05b0..200b54d5829 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -1568,10 +1568,10 @@ class ViewTest extends \Test\TestCase { $defaultRootValue->setAccessible(true); $oldRoot = $defaultRootValue->getValue(); $defaultView = new View('/foo/files'); - $defaultRootValue->setValue($defaultView); + $defaultRootValue->setValue(null, $defaultView); $view = new View($root); $result = self::invokePrivate($view, 'shouldEmitHooks', [$path]); - $defaultRootValue->setValue($oldRoot); + $defaultRootValue->setValue(null, $oldRoot); $this->assertEquals($shouldEmit, $result); } diff --git a/tests/lib/TestCase.php b/tests/lib/TestCase.php index a242a51a887..f5fc9a6e8f2 100644 --- a/tests/lib/TestCase.php +++ b/tests/lib/TestCase.php @@ -230,7 +230,11 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase { $property->setAccessible(true); if (!empty($parameters)) { - $property->setValue($object, array_pop($parameters)); + if ($property->isStatic()) { + $property->setValue(null, array_pop($parameters)); + } else { + $property->setValue($object, array_pop($parameters)); + } } if (is_object($object)) {