From 88aa0710c4184c8851dc66b707d4352329c6c80c Mon Sep 17 00:00:00 2001 From: Ben Ramsey Date: Thu, 9 May 2019 16:40:04 -0500 Subject: [PATCH] Allow use of newer PHPUnit on newer versions of PHP This allows the 0.x series of this library to have passing tests on PHP 5.4 all the way up to PHP 7.3. I added an allowance for using the PHPUnit 7 series on versions of PHP that support it, and I made a few slight changes to tests and phpunit.xml.dist that allow the tests to continue running on both the older version of PHPUnit and the newer versions. FYI, when you choose to upgrade to PHPUnit 8.x for the 1.x series of this library, you'll need to make more changes to the tests that won't be backwards compatible with earlier versions of PHPUnit. --- composer.json | 2 +- phpunit.xml.dist | 2 +- test/ScopeFactoryTest.php | 4 ++-- test/TransformerAbstractTest.php | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 95a7a8fa..843c20c6 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "illuminate/contracts": "~5.0", "mockery/mockery": "~0.9", "pagerfanta/pagerfanta": "~1.0.0", - "phpunit/phpunit": "^4.8.35", + "phpunit/phpunit": "^4.8.35 || ^7.5", "squizlabs/php_codesniffer": "~1.5", "zendframework/zend-paginator": "~2.3" }, diff --git a/phpunit.xml.dist b/phpunit.xml.dist index b45c2438..ba62bebc 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -13,7 +13,7 @@ - + diff --git a/test/ScopeFactoryTest.php b/test/ScopeFactoryTest.php index c40c7bac..d9a6ba33 100644 --- a/test/ScopeFactoryTest.php +++ b/test/ScopeFactoryTest.php @@ -69,7 +69,7 @@ private function createSut() */ private function createManager() { - return $this->getMock('League\\Fractal\\Manager'); + return $this->getMockBuilder('League\\Fractal\\Manager')->getMock(); } /** @@ -77,6 +77,6 @@ private function createManager() */ private function createResource() { - return $this->getMock('League\\Fractal\\Resource\\ResourceInterface'); + return $this->getMockBuilder('League\\Fractal\\Resource\\ResourceInterface')->getMock(); } } diff --git a/test/TransformerAbstractTest.php b/test/TransformerAbstractTest.php index a4c9cf84..56429e8a 100755 --- a/test/TransformerAbstractTest.php +++ b/test/TransformerAbstractTest.php @@ -300,7 +300,8 @@ public function testParamBagIsProvidedForIncludes() $transformer->setAvailableIncludes(['book']); $scope = new Scope($manager, new Item([], $transformer)); - $included = $transformer->processIncludedResources($scope, []); + + $this->assertFalse($transformer->processIncludedResources($scope, [])); } /**