From c57d0530599a35ae80bd6ab50aa879501394b8ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 21 Mar 2023 07:44:36 +0100 Subject: [PATCH 1/3] fix: PHPUnit 10 compatibility Changes due to changes in PHPUnit Facade, as `sealed` is no longer a static property. Since PHPUnit 10.0.17 --- classes/PHPMock.php | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/PHPMock.php b/classes/PHPMock.php index 40f08b8..df47504 100644 --- a/classes/PHPMock.php +++ b/classes/PHPMock.php @@ -100,7 +100,7 @@ public function registerForTearDown(Deactivatable $deactivatable) if (class_exists(Facade::class)) { $property = new ReflectionProperty(Facade::class, 'sealed'); $property->setAccessible(true); - $property->setValue(false); + $property->setValue(Facade::instance(), false); Facade::registerSubscriber( new MockDisabler($deactivatable) diff --git a/composer.json b/composer.json index 3683e25..8b8e15f 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ }, "require": { "php": ">=7", - "phpunit/phpunit": "^6 || ^7 || ^8 || ^9 || ^10", + "phpunit/phpunit": "^6 || ^7 || ^8 || ^9 || ^10.0.17", "php-mock/php-mock-integration": "^2.2.1" }, "require-dev": { From d9d52d75f9694f12ed0a89af0fd7d25610cf0a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 21 Mar 2023 07:49:15 +0100 Subject: [PATCH 2/3] use Facade::instance() --- classes/PHPMock.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/PHPMock.php b/classes/PHPMock.php index df47504..89edcaa 100644 --- a/classes/PHPMock.php +++ b/classes/PHPMock.php @@ -102,7 +102,7 @@ public function registerForTearDown(Deactivatable $deactivatable) $property->setAccessible(true); $property->setValue(Facade::instance(), false); - Facade::registerSubscriber( + Facade::instance()->registerSubscriber( new MockDisabler($deactivatable) ); From 3c95ff8eca42fb5c04e51ecfd5b0bc76471bf2c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 21 Mar 2023 07:52:47 +0100 Subject: [PATCH 3/3] change value of the property on the instance --- classes/PHPMock.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/classes/PHPMock.php b/classes/PHPMock.php index 89edcaa..166d9d2 100644 --- a/classes/PHPMock.php +++ b/classes/PHPMock.php @@ -98,15 +98,17 @@ private function addMatcher($mock, $name) public function registerForTearDown(Deactivatable $deactivatable) { if (class_exists(Facade::class)) { + $facade = Facade::instance(); + $property = new ReflectionProperty(Facade::class, 'sealed'); $property->setAccessible(true); - $property->setValue(Facade::instance(), false); + $property->setValue($facade, false); - Facade::instance()->registerSubscriber( + $facade->registerSubscriber( new MockDisabler($deactivatable) ); - $property->setValue(true); + $property->setValue($facade, true); return; }