Fix setting static property in tests on PHP 8.3

Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
This commit is contained in:
Côme Chilliet 2023-08-10 16:44:43 +02:00
parent 2ea6c5364d
commit ee756579a7
No known key found for this signature in database
GPG key ID: A3E2F658B28C760A
2 changed files with 7 additions and 3 deletions

View file

@ -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);
}

View file

@ -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)) {