From 65a123c61f3e41c1efda52c3956e6d00c02b0e16 Mon Sep 17 00:00:00 2001 From: webimpress Date: Tue, 24 Oct 2017 17:27:32 +0100 Subject: [PATCH 1/3] Updated test to work with PHPUnit 6 Replaced deprecated method `setExpectedException` --- test/ArrayObjectTest.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/ArrayObjectTest.php b/test/ArrayObjectTest.php index df77c5bad..855c20c8e 100644 --- a/test/ArrayObjectTest.php +++ b/test/ArrayObjectTest.php @@ -105,10 +105,8 @@ public function testAsort() public function testCount() { if (version_compare(PHP_VERSION, '7.2', '>=')) { - $this->setExpectedException( - 'PHPUnit_Framework_Error_Warning', - 'Parameter must be an array or an object that implements Countable' - ); + $this->expectException(\PHPUnit_Framework_Error_Warning::class); + $this->expectExceptionMessage('Parameter must be an array or an object that implements Countable'); } $ar = new ArrayObject(new TestAsset\ArrayObjectObjectVars()); $this->assertCount(1, $ar); From 8347817249c733143f6b5adb70f88712704b36d2 Mon Sep 17 00:00:00 2001 From: webimpress Date: Tue, 24 Oct 2017 17:37:22 +0100 Subject: [PATCH 2/3] Tests fix - use proper exception depends on PHPUnit version --- test/ArrayObjectTest.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test/ArrayObjectTest.php b/test/ArrayObjectTest.php index 855c20c8e..e98a8e5dd 100644 --- a/test/ArrayObjectTest.php +++ b/test/ArrayObjectTest.php @@ -10,6 +10,7 @@ namespace ZendTest\Stdlib; use InvalidArgumentException; +use PHPUnit\Framework\Error\Warning; use PHPUnit\Framework\TestCase; use Zend\Stdlib\ArrayObject; @@ -102,10 +103,21 @@ public function testAsort() $this->assertSame($sorted, $ar->getArrayCopy()); } + /** + * PHPUnit 5.7 does not namespace error classes; retrieve appropriate one + * based on what is available. + * + * @return string + */ + protected function getExpectedWarningClass() + { + return class_exists(Warning::class) ? Warning::class : \PHPUnit_Framework_Error_Warning::class; + } + public function testCount() { if (version_compare(PHP_VERSION, '7.2', '>=')) { - $this->expectException(\PHPUnit_Framework_Error_Warning::class); + $this->expectException($this->getExpectedWarningClass()); $this->expectExceptionMessage('Parameter must be an array or an object that implements Countable'); } $ar = new ArrayObject(new TestAsset\ArrayObjectObjectVars()); From fd8745df44c263223ca065211bff23a4e62354be Mon Sep 17 00:00:00 2001 From: webimpress Date: Tue, 24 Oct 2017 17:40:29 +0100 Subject: [PATCH 3/3] Use clearer php version comparision --- test/ArrayObjectTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/ArrayObjectTest.php b/test/ArrayObjectTest.php index e98a8e5dd..d61c08eb0 100644 --- a/test/ArrayObjectTest.php +++ b/test/ArrayObjectTest.php @@ -116,7 +116,7 @@ protected function getExpectedWarningClass() public function testCount() { - if (version_compare(PHP_VERSION, '7.2', '>=')) { + if (PHP_VERSION_ID >= 70200) { $this->expectException($this->getExpectedWarningClass()); $this->expectExceptionMessage('Parameter must be an array or an object that implements Countable'); }