From 1838a0fb31b481772481fc7e300e587d3380ac56 Mon Sep 17 00:00:00 2001 From: Tobias Nyholm Date: Mon, 18 Jan 2021 13:28:41 +0100 Subject: [PATCH] Drop PHP versions before 7.2 (#232) * Drop PHP versions before 7.2 * Remove derprecaed phpunit code * Fixes according to review * Typo --- .github/workflows/ci.yaml | 6 ------ composer.json | 4 ++-- tests/AssertTest.php | 18 ++++++++++-------- tests/BaseTestCase.php | 38 -------------------------------------- tests/ProjectCodeTest.php | 5 +++-- 5 files changed, 15 insertions(+), 56 deletions(-) delete mode 100644 tests/BaseTestCase.php 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..f7cdb34c 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ } ], "require": { - "php": "^5.3.3 || ^7.0 || ^8.0", + "php": "^7.2 || ^8.0", "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": { diff --git a/tests/AssertTest.php b/tests/AssertTest.php index 15527cfa..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), @@ -598,7 +599,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 +621,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 +652,7 @@ public function testAllArray($method, $args, $success, $multibyte = false, $minV } if (!$success) { - $this->setExpectedException('\InvalidArgumentException'); + $this->expectException('\InvalidArgumentException'); } $arg = array_shift($args); @@ -676,7 +677,7 @@ public function testAllTraversable($method, $args, $success, $multibyte = false, } if (!$success) { - $this->setExpectedException('\InvalidArgumentException'); + $this->expectException('\InvalidArgumentException'); } $arg = array_shift($args); @@ -716,14 +717,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 deleted file mode 100644 index 07a99c7b..00000000 --- a/tests/BaseTestCase.php +++ /dev/null @@ -1,38 +0,0 @@ -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..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; @@ -119,7 +120,7 @@ public function testHasThrowsAnnotation($method) ) ); - $this->assertContains( + $this->assertStringContainsString( '@throws InvalidArgumentException', $doc, sprintf(