diff --git a/.php_cs b/.php-cs-fixer.php similarity index 80% rename from .php_cs rename to .php-cs-fixer.php index d67e700..a519879 100644 --- a/.php_cs +++ b/.php-cs-fixer.php @@ -3,8 +3,9 @@ $finder = PhpCsFixer\Finder::create() ->in(__DIR__ . "/src") ->in(__DIR__ . "/tests"); +$config = new PhpCsFixer\Config(); -return PhpCsFixer\Config::create() +return $config ->setRules([ '@PSR2' => true, '@Symfony' => true, diff --git a/composer.json b/composer.json index 8e0ba2a..ca80da4 100644 --- a/composer.json +++ b/composer.json @@ -20,16 +20,17 @@ } }, "require": { - "php": ">=7.1", + "php": ">=8.1", "paragonie/random_compat": "^1.0|^2.0|9.99.99", - "psr/http-message": "^1.0" + "psr/http-message": "^1.0", + "nyholm/psr7": "^1.5" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2", + "friendsofphp/php-cs-fixer": "^v3.13.0", "guzzlehttp/psr7": "^1.2", - "phpunit/phpunit": "~7.0", - "symfony/http-foundation": "~2.8|~3.0", - "symfony/psr-http-message-bridge": "^1.0.2", - "zendframework/zend-diactoros": "^1.1" + "phpunit/phpunit": "^9.5.26", + "symfony/http-foundation": "^v6.1.8", + "symfony/psr-http-message-bridge": "^v2.1.3", + "laminas/laminas-diactoros": "^2.22.0" } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 2b6ab58..119018c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,26 +1,13 @@ - + + + + ./src + + ./tests - - - ./src - - diff --git a/tests/ContextTest.php b/tests/ContextTest.php index e6e22dc..391c8bd 100644 --- a/tests/ContextTest.php +++ b/tests/ContextTest.php @@ -8,7 +8,7 @@ class ContextTest extends TestCase { - protected function setUp() + protected function setUp(): void { $this->noDigestContext = new Context([ 'keys' => ['pda' => 'secret'], diff --git a/tests/KeyStoreTest.php b/tests/KeyStoreTest.php index 8e578eb..3c9032c 100644 --- a/tests/KeyStoreTest.php +++ b/tests/KeyStoreTest.php @@ -15,11 +15,9 @@ public function testFetchSuccess() $this->assertEquals('secret', $key->secret); } - /** - * @expectedException \HttpSignatures\Exception - */ public function testFetchFail() { + $this->expectException(\HttpSignatures\Exception::class); $ks = new KeyStore(['id' => 'secret']); $key = $ks->fetch('nope'); } diff --git a/tests/SignatureParametersParserTest.php b/tests/SignatureParametersParserTest.php index 1e300c7..9a28147 100644 --- a/tests/SignatureParametersParserTest.php +++ b/tests/SignatureParametersParserTest.php @@ -23,20 +23,16 @@ public function testParseReturnsExpectedAssociativeArray() ); } - /** - * @expectedException \HttpSignatures\SignatureParseException - */ public function testParseThrowsTypedException() { + $this->expectException(\HttpSignatures\SignatureParseException::class); $parser = new SignatureParametersParser('nope'); $parser->parse(); } - /** - * @expectedException \HttpSignatures\SignatureParseException - */ public function testParseExceptionForMissingComponents() { + $this->expectException(\HttpSignatures\SignatureParseException::class); $parser = new SignatureParametersParser( 'keyId="example",algorithm="hmac-sha1",headers="(request-target) date"' ); diff --git a/tests/SigningStringTest.php b/tests/SigningStringTest.php index d072b52..36d3abd 100644 --- a/tests/SigningStringTest.php +++ b/tests/SigningStringTest.php @@ -4,8 +4,9 @@ use GuzzleHttp\Psr7\Request; use HttpSignatures\HeaderList; -use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory; use HttpSignatures\SigningString; +use Nyholm\Psr7\Factory\Psr17Factory; +use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; use PHPUnit\Framework\TestCase; @@ -66,11 +67,9 @@ public function testSigningStringWithUnorderedQueryParametersSymfonyRequest() ); } - /** - * @expectedException \HttpSignatures\Exception - */ public function testSigningStringErrorForMissingHeader() { + $this->expectException(\HttpSignatures\Exception::class); $headerList = new HeaderList(['nope']); $ss = new SigningString($headerList, $this->message('/')); $ss->string(); @@ -85,10 +84,8 @@ private function symfonyMessage($path) { $symfonyRequest = SymfonyRequest::create($path, 'GET'); $symfonyRequest->headers->replace(['date' => 'Mon, 28 Jul 2014 15:39:13 -0700']); - - $psr7Factory = new DiactorosFactory(); - $psrRequest = $psr7Factory->createRequest($symfonyRequest)->withRequestTarget($symfonyRequest->getRequestUri()); - - return $psrRequest; + $psr17Factory = new Psr17Factory; + $psr7Factory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory); + return $psr7Factory->createRequest($symfonyRequest)->withRequestTarget($symfonyRequest->getRequestUri()); } } diff --git a/tests/VerifierTest.php b/tests/VerifierTest.php index c800ad8..5ea45d8 100644 --- a/tests/VerifierTest.php +++ b/tests/VerifierTest.php @@ -22,7 +22,7 @@ class VerifierTest extends TestCase */ private $message; - protected function setUp() + protected function setUp(): void { $this->setUpVerifier(); $this->setUpValidMessage();