From b1dcb2882d5a7b0d57697471dfdd8179f9e5ea06 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Mon, 18 Jan 2021 11:31:48 +0100 Subject: [PATCH 1/4] Drop PHP versions before 7.2 --- .github/workflows/ci.yaml | 6 ------ composer.json | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a847bd61..339483c1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -70,12 +70,6 @@ jobs: strategy: matrix: php-version: - - "5.3" - - "5.4" - - "5.5" - - "5.6" - - "7.0" - - "7.1" - "7.2" - "7.3" - "7.4" diff --git a/composer.json b/composer.json index 90353e46..9e957a1b 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^5.3.3 || ^7.0 || ^8.0", + "php": ">=7.2", "symfony/polyfill-ctype": "^1.8" }, "conflict": { @@ -22,7 +22,7 @@ "vimeo/psalm": "<3.9.1" }, "require-dev": { - "phpunit/phpunit": "^4.8.36 || ^7.5.13 || ^8.5.13" + "phpunit/phpunit": "^8.5.13" }, "extra": { "branch-alias": { From baa9848f0bef389dad718a690b50f46f38204271 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Mon, 18 Jan 2021 11:37:11 +0100 Subject: [PATCH 2/4] Remove derprecaed phpunit code --- tests/AssertTest.php | 13 +++++++------ tests/BaseTestCase.php | 26 -------------------------- tests/ProjectCodeTest.php | 2 +- 3 files changed, 8 insertions(+), 33 deletions(-) diff --git a/tests/AssertTest.php b/tests/AssertTest.php index 15527cfa..193112a2 100644 --- a/tests/AssertTest.php +++ b/tests/AssertTest.php @@ -598,7 +598,7 @@ public function testAssert($method, $args, $success, $multibyte = false, $minVer } if (!$success) { - $this->setExpectedException('\InvalidArgumentException'); + $this->expectException('\InvalidArgumentException'); } call_user_func_array(array('Webmozart\Assert\Assert', $method), $args); @@ -620,7 +620,7 @@ public function testNullOr($method, $args, $success, $multibyte = false, $minVer } if (!$success && null !== reset($args)) { - $this->setExpectedException('\InvalidArgumentException'); + $this->expectException('\InvalidArgumentException'); } call_user_func_array(array('Webmozart\Assert\Assert', 'nullOr'.ucfirst($method)), $args); @@ -651,7 +651,7 @@ public function testAllArray($method, $args, $success, $multibyte = false, $minV } if (!$success) { - $this->setExpectedException('\InvalidArgumentException'); + $this->expectException('\InvalidArgumentException'); } $arg = array_shift($args); @@ -676,7 +676,7 @@ public function testAllTraversable($method, $args, $success, $multibyte = false, } if (!$success) { - $this->setExpectedException('\InvalidArgumentException'); + $this->expectException('\InvalidArgumentException'); } $arg = array_shift($args); @@ -716,14 +716,15 @@ public function getStringConversions() */ public function testConvertValuesToStrings($method, $args, $exceptionMessage) { - $this->setExpectedException('\InvalidArgumentException', $exceptionMessage); + $this->expectException('\InvalidArgumentException', $exceptionMessage); + $this->expectExceptionMessage($exceptionMessage); call_user_func_array(array('Webmozart\Assert\Assert', $method), $args); } public function testAnUnknownMethodThrowsABadMethodCall() { - $this->setExpectedException('\BadMethodCallException'); + $this->expectException('\BadMethodCallException'); Assert::nonExistentMethod(); } diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php index 07a99c7b..2281e2ee 100644 --- a/tests/BaseTestCase.php +++ b/tests/BaseTestCase.php @@ -9,30 +9,4 @@ */ class BaseTestCase extends TestCase { - /** - * The setExpectedException got removed in later phpunit versions, - * and instead it got split up into three functions. - * - * So if the newer functions exist we call those where needed, and otherwise - * we just use the original function. - * - * @param string $exceptionName - * @param string $exceptionMessage - * @param int $exceptionCode - */ - public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = null) - { - if (method_exists($this, 'expectException')) { - $this->expectException($exceptionName); - if ($exceptionMessage) { - $this->expectExceptionMessage($exceptionMessage); - } - if ($exceptionCode) { - $this->expectExceptionCode($exceptionCode); - } - - return; - } - parent::setExpectedException($exceptionName, $exceptionMessage, $exceptionCode); - } } diff --git a/tests/ProjectCodeTest.php b/tests/ProjectCodeTest.php index 822f5d69..73a90ccc 100644 --- a/tests/ProjectCodeTest.php +++ b/tests/ProjectCodeTest.php @@ -119,7 +119,7 @@ public function testHasThrowsAnnotation($method) ) ); - $this->assertContains( + $this->assertStringContainsString( '@throws InvalidArgumentException', $doc, sprintf( From 0e2a1af855f24b1297512b088e4db3721097dde3 Mon Sep 17 00:00:00 2001 From: Nyholm Date: Mon, 18 Jan 2021 13:20:45 +0100 Subject: [PATCH 3/4] Fixes according to review --- composer.json | 2 +- tests/AssertTest.php | 5 +++-- tests/BaseTestCase.php | 12 ------------ 3 files changed, 4 insertions(+), 15 deletions(-) delete mode 100644 tests/BaseTestCase.php diff --git a/composer.json b/composer.json index 9e957a1b..f7cdb34c 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": ">=7.2", + "php": "^7.2 || ^8.0", "symfony/polyfill-ctype": "^1.8" }, "conflict": { diff --git a/tests/AssertTest.php b/tests/AssertTest.php index 193112a2..2b90c67b 100644 --- a/tests/AssertTest.php +++ b/tests/AssertTest.php @@ -16,6 +16,7 @@ use Error; use Exception; use LogicException; +use PHPUnit\Framework\TestCase; use RuntimeException; use stdClass; use Webmozart\Assert\Assert; @@ -25,7 +26,7 @@ * * @author Bernhard Schussek */ -class AssertTest extends BaseTestCase +class AssertTest extends TestCase { private static $resource; @@ -422,7 +423,7 @@ public function getTests() // no tests for readable()/writable() for now array('classExists', array(__CLASS__), true), array('classExists', array(__NAMESPACE__.'\Foobar'), false), - array('subclassOf', array(__CLASS__, 'Webmozart\Assert\Tests\BaseTestCase'), true), + array('subclassOf', array(__CLASS__, 'PHPUnit\Framework\TestCase'), true), array('subclassOf', array(__CLASS__, 'stdClass'), false), array('interfaceExists', array('\Countable'), true), array('interfaceExists', array(__CLASS__), false), diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php deleted file mode 100644 index 2281e2ee..00000000 --- a/tests/BaseTestCase.php +++ /dev/null @@ -1,12 +0,0 @@ - Date: Mon, 18 Jan 2021 13:26:34 +0100 Subject: [PATCH 4/4] Typo --- tests/ProjectCodeTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/ProjectCodeTest.php b/tests/ProjectCodeTest.php index 73a90ccc..814a113d 100644 --- a/tests/ProjectCodeTest.php +++ b/tests/ProjectCodeTest.php @@ -2,6 +2,7 @@ namespace Webmozart\Assert\Tests; +use PHPUnit\Framework\TestCase; use ReflectionClass; use ReflectionMethod; use Webmozart\Assert\Bin\MixinGenerator; @@ -9,7 +10,7 @@ /** * @coversNothing */ -class ProjectCodeTest extends BaseTestCase +class ProjectCodeTest extends TestCase { private static $readmeContent; private static $assertDocComment;