diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57967cf..b521e6d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,6 +11,17 @@ jobs: strategy: matrix: php: + - 8.3 + - 8.2 + - 8.1 + - 8.0 + - 7.4 + - 7.3 + - 7.2 + - 7.1 + - 7.0 + - 5.6 + - 5.5 - 5.4 - 5.3 steps: @@ -21,3 +32,6 @@ jobs: coverage: xdebug - run: composer install - run: vendor/bin/phpunit --coverage-text + if: ${{ matrix.php >= 7.3 }} + - run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy + if: ${{ matrix.php < 7.3 }} diff --git a/composer.json b/composer.json index 66c804a..a6464b0 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,7 @@ "php": ">=5.3" }, "require-dev": { - "phpunit/phpunit": "^4.8.36" + "phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36" }, "autoload": { "psr-0": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index f66a042..bb9f22c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,20 +1,22 @@ - + + cacheResult="false" + colors="true" + convertDeprecationsToExceptions="true"> ./tests/ - - + + ./src/ - - + + diff --git a/phpunit.xml.legacy b/phpunit.xml.legacy new file mode 100644 index 0000000..f66a042 --- /dev/null +++ b/phpunit.xml.legacy @@ -0,0 +1,21 @@ + + + + + + + ./tests/ + + + + + ./src/ + + + + + + diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php index b669223..a645127 100644 --- a/tests/FactoryTest.php +++ b/tests/FactoryTest.php @@ -6,7 +6,10 @@ class FactoryTest extends TestCase { private $factory; - public function setUp() + /** + * @before + */ + public function setUpFactory() { $this->factory = new Factory(); } diff --git a/tests/Model/AbstractModelTest.php b/tests/Model/AbstractModelTest.php index 1358533..7324850 100644 --- a/tests/Model/AbstractModelTest.php +++ b/tests/Model/AbstractModelTest.php @@ -8,7 +8,10 @@ abstract class AbstractModelTest extends TestCase abstract protected function createModel($value); - public function setUp() + /** + * @before + */ + public function setUpSerializer() { $this->serializer = new RecursiveSerializer(); } diff --git a/tests/Model/ErrorReplyTest.php b/tests/Model/ErrorReplyTest.php index 2585b08..16497fb 100644 --- a/tests/Model/ErrorReplyTest.php +++ b/tests/Model/ErrorReplyTest.php @@ -6,7 +6,7 @@ class ErrorReplyTest extends AbstractModelTest { protected function createModel($value) { - return new ErrorReply($value); + return new ErrorReply((string) $value); } public function testError() diff --git a/tests/Model/MultiBulkReplyTest.php b/tests/Model/MultiBulkReplyTest.php index 04dd389..ff4a0c3 100644 --- a/tests/Model/MultiBulkReplyTest.php +++ b/tests/Model/MultiBulkReplyTest.php @@ -36,10 +36,10 @@ public function testNullMultiBulkReply() /** * @param MultiBulkReply $model * @depends testNullMultiBulkReply - * @expectedException UnexpectedValueException */ public function testNullMultiBulkReplyIsNotARequest(MultiBulkReply $model) { + $this->setExpectedException('UnexpectedValueException'); $model->getRequestModel(); } @@ -91,10 +91,10 @@ public function testMixedReply() /** * @param MultiBulkReply $model * @depends testMixedReply - * @expectedException UnexpectedValueException */ public function testMixedReplyIsNotARequest(MultiBulkReply $model) { + $this->setExpectedException('UnexpectedValueException'); $model->getRequestModel(); } diff --git a/tests/Parser/AbstractParserTest.php b/tests/Parser/AbstractParserTest.php index 3d45c20..24c737c 100644 --- a/tests/Parser/AbstractParserTest.php +++ b/tests/Parser/AbstractParserTest.php @@ -13,7 +13,10 @@ abstract class AbstractParserTest extends TestCase abstract protected function createParser(); - public function setUp() + /** + * @before + */ + public function setUpParser() { $this->parser = $this->createParser(); $this->assertInstanceOf('Clue\Redis\Protocol\Parser\ParserInterface', $this->parser); diff --git a/tests/Parser/RequestParserTest.php b/tests/Parser/RequestParserTest.php index 645b673..bc95256 100644 --- a/tests/Parser/RequestParserTest.php +++ b/tests/Parser/RequestParserTest.php @@ -110,23 +110,19 @@ public function testWhitespaceInlineIsIgnored() $this->assertEquals(array(), $this->parser->pushIncoming($message)); } - /** - * @expectedException Clue\Redis\Protocol\Parser\ParserException - */ public function testInvalidMultiBulkMustContainBulk() { $message = "*1\r\n:123\r\n"; + $this->setExpectedException('Clue\Redis\Protocol\Parser\ParserException'); $this->parser->pushIncoming($message); } - /** - * @expectedException Clue\Redis\Protocol\Parser\ParserException - */ public function testInvalidBulkLength() { $message = "*1\r\n$-1\r\n"; + $this->setExpectedException('Clue\Redis\Protocol\Parser\ParserException'); $this->parser->pushIncoming($message); } } diff --git a/tests/Parser/ResponseParserTest.php b/tests/Parser/ResponseParserTest.php index d102621..17ed387 100644 --- a/tests/Parser/ResponseParserTest.php +++ b/tests/Parser/ResponseParserTest.php @@ -120,11 +120,9 @@ public function testParsingMultiBulkReplyWithNullElement() $this->assertEquals(array('foo', null, 'bar'), $data); } - /** - * @expectedException Clue\Redis\Protocol\Parser\ParserException - */ public function testParseError() { + $this->setExpectedException('Clue\Redis\Protocol\Parser\ParserException'); $this->parser->pushIncoming("invalid string\r\n"); } } diff --git a/tests/Serializer/AbstractSerializerTest.php b/tests/Serializer/AbstractSerializerTest.php index a6d1c40..e3dc625 100644 --- a/tests/Serializer/AbstractSerializerTest.php +++ b/tests/Serializer/AbstractSerializerTest.php @@ -1,16 +1,21 @@ serializer = $this->createSerializer(); } @@ -89,19 +94,15 @@ public function testErrorReply() $this->assertEquals($model->getMessageSerialized($this->serializer), $this->serializer->getReplyMessage(new Exception('ERR failure'))); } - /** - * @expectedException InvalidArgumentException - */ public function testInvalidArgument() { + $this->setExpectedException('InvalidArgumentException'); $this->serializer->createReplyModel((object)array()); } - /** - * @expectedException InvalidArgumentException - */ public function testInvalidReplyData() { + $this->setExpectedException('InvalidArgumentException'); $this->serializer->getReplyMessage((object)array()); } diff --git a/tests/TestCase.php b/tests/TestCase.php index ac3b704..3f65834 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -1,5 +1,21 @@ expectException($exception); + if ($exceptionMessage !== '') { + $this->expectExceptionMessage($exceptionMessage); + } + if ($exceptionCode !== null) { + $this->expectExceptionCode($exceptionCode); + } + } else { + // legacy PHPUnit + parent::setExpectedException($exception, $exceptionMessage, $exceptionCode); + } + } }