diff --git a/.gitignore b/.gitignore index b644c64..d77e7b5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,5 @@ composer.lock vendor coverage +/.phpunit.result.cache +/phpunit.xml diff --git a/.travis.yml b/.travis.yml index beefe35..afc6904 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,13 @@ language: php -dist: trusty +dist: focal matrix: include: - - php: 7.1 - - php: 7.2 - php: 7.3 + dist: xenial - php: 7.4 + - php: 8.0 env: ANALYSIS='true' - php: nightly diff --git a/composer.json b/composer.json index 167bb3d..65a2b3b 100644 --- a/composer.json +++ b/composer.json @@ -12,16 +12,20 @@ "homepage": "http://joshlockhart.com" } ], + "config": { + "sort-packages": true + }, "require": { - "php": "^7.1", + "php": "^7.3|^8.0", "psr/http-factory": "^1.0", "psr/http-message": "^1.0", "psr/http-server-handler": "^1.0", "psr/http-server-middleware": "^1.0" }, "require-dev": { - "phpunit/phpunit": "^7.5", "phpspec/prophecy": "^1.10", + "phpspec/prophecy-phpunit": "^2.0", + "phpunit/phpunit": "^9.0", "squizlabs/php_codesniffer": "^3.5.8" }, "autoload": { diff --git a/tests/GuardTest.php b/tests/GuardTest.php index 06e6e37..f4cb45a 100644 --- a/tests/GuardTest.php +++ b/tests/GuardTest.php @@ -13,6 +13,7 @@ use Exception; use PHPUnit\Framework\TestCase; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Psr\Http\Message\ResponseFactoryInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; @@ -24,26 +25,28 @@ class GuardTest extends TestCase { - /** - * @expectedException Exception - * @expectedExceptionMessage CSRF middleware instantiation failed. Minimum strength is 16. - */ + use ProphecyTrait; + public function testStrengthLowerThan16ThrowsException() { $storage = []; $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class); - $mw = new Guard($responseFactoryProphecy->reveal(), 'test', $storage, null, 200, 15); + + $this->expectException(Exception::class); + $this->expectExceptionMessage('CSRF middleware instantiation failed. Minimum strength is 16.'); + new Guard($responseFactoryProphecy->reveal(), 'test', $storage, null, 200, 15); } /** - * @expectedException RuntimeException - * @expectedExceptionMessage Invalid CSRF storage. * Use session_start() before instantiating the Guard middleware or provide array storage. */ public function testSetStorageThrowsExceptionWhenFallingBackOnSessionThatHasNotBeenStarted() { $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class); - $mw = new Guard($responseFactoryProphecy->reveal(), 'test'); + + $this->expectException(Exception::class); + $this->expectExceptionMessage('Invalid CSRF storage.'); + new Guard($responseFactoryProphecy->reveal(), 'test'); } /** @@ -53,7 +56,7 @@ public function testSetStorageSetsKeysOnSessionObjectWhenNotExist() { session_start(); $responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class); - $mw = new Guard($responseFactoryProphecy->reveal(), 'test'); + new Guard($responseFactoryProphecy->reveal(), 'test'); $this->assertArrayHasKey('test', $_SESSION); }