From bd5e79bb051c6259f9359776fa9f44a4bb0aacb2 Mon Sep 17 00:00:00 2001 From: Marcel Hernandez Date: Sat, 26 Dec 2020 03:43:27 +0100 Subject: [PATCH] update dev dependencies, set up GitHub Actions and bump minimum version to PHP 7.3 --- .gitattributes | 2 +- .github/workflows/phpunit.yml | 35 +++++++++++++++++++ .gitignore | 1 - LICENSE | 2 +- composer.json | 20 +++++------ phpunit.xml | 35 +++++++++++++++++++ phpunit.xml.dist | 27 -------------- .../{ZendFactory.php => LaminasFactory.php} | 6 ++-- tests/Factory/SymfonyFactory.php | 12 ++++--- tests/FullSpectrumTest.php | 2 +- tests/Psr15/HmacMiddlewareTest.php | 2 +- tests/RequestsProvider.php | 4 +-- tests/VerifierTest.php | 2 +- 13 files changed, 97 insertions(+), 53 deletions(-) create mode 100644 .github/workflows/phpunit.yml create mode 100644 phpunit.xml delete mode 100644 phpunit.xml.dist rename tests/Factory/{ZendFactory.php => LaminasFactory.php} (83%) diff --git a/.gitattributes b/.gitattributes index cf62a55..6eed6bb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,5 +3,5 @@ /.gitignore export-ignore /.scrutinizer.yml export-ignore /.travis.yml export-ignore -/phpunit.xml.dist export-ignore +/phpunit.xml export-ignore /README.md export-ignore diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml new file mode 100644 index 0000000..409c635 --- /dev/null +++ b/.github/workflows/phpunit.yml @@ -0,0 +1,35 @@ +on: push + +jobs: + php73: + runs-on: ubuntu-latest + container: 1maa/php-dev:7.3 + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Run tests in PHP 7.3 + run: | + composer install + composer test + + php74: + runs-on: ubuntu-latest + container: 1maa/php-dev:7.4 + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Run tests in PHP 7.4 + run: | + composer install + composer test + + php80: + runs-on: ubuntu-latest + container: 1maa/php-dev:8.0 + steps: + - name: Checkout + uses: actions/checkout@v1 + - name: Run tests in PHP 8.0 + run: | + composer install + composer test diff --git a/.gitignore b/.gitignore index 189cef2..520ca3b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,5 @@ /build/ /composer.lock -/phpunit.xml /vendor/ *.phar diff --git a/LICENSE b/LICENSE index decb0c5..6e22f74 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2016-2019 Marcel Hernandez +Copyright (c) 2016-2021 Marcel Hernandez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/composer.json b/composer.json index cd3e22a..d66c582 100644 --- a/composer.json +++ b/composer.json @@ -1,8 +1,8 @@ { "name": "uma/psr7-hmac", "description": "An HMAC authentication library built on top of the PSR-7 specification", - "type": "library", "license": "MIT", + "type": "library", "keywords": ["http", "psr7", "hmac"], "homepage": "https://github.com/1ma/Psr7Hmac", "support": { @@ -10,22 +10,22 @@ "source": "https://github.com/1ma/Psr7Hmac" }, "require": { - "php": ">=7.1", - "psr/http-message": "^1.0.0", + "php": "^7.3.0 || ^7.4.0 || ^8.0.0", + "psr/http-message": "^1.0", "psr/http-server-middleware": "^1.0" }, "require-dev": { "guzzlehttp/psr7": "^1.3", "kambo/httpmessage": "^0.9.0", + "laminas/laminas-diactoros": "^2.5", "nyholm/psr7": "^1.0", - "phpmetrics/phpmetrics": "^2.4", - "phpunit/phpunit": "^7.5", + "phpmetrics/phpmetrics": "^2.7", + "phpunit/phpunit": "^9.5", "ringcentral/psr7": "^1.2", "slim/slim": "^3.4", - "symfony/psr-http-message-bridge": "^1.1", + "symfony/psr-http-message-bridge": "^2.0", "wandu/http": "^3.0", - "windwalker/http": "^3.1", - "zendframework/zend-diactoros": "^1.8" + "windwalker/http": "^3.1" }, "autoload": { "psr-4": { @@ -38,10 +38,10 @@ } }, "scripts": { - "test": "php vendor/bin/phpunit", + "test": "php -dzend.assertions=1 -dassert.exception=1 vendor/bin/phpunit", "metrics": [ "@test", - "vendor/bin/phpmetrics --junit=./build/phpunit/junit.xml --report-html=./build/phpmetrics ." + "vendor/bin/phpmetrics --junit=./build/junit.xml --report-html=./build/metrics ." ] }, "config": { diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..1cf7865 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,35 @@ + + + + + tests + + + + + + src + + + + + + + + + + + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist deleted file mode 100644 index b164180..0000000 --- a/phpunit.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - tests - - - - - - - - - - - - src - - - diff --git a/tests/Factory/ZendFactory.php b/tests/Factory/LaminasFactory.php similarity index 83% rename from tests/Factory/ZendFactory.php rename to tests/Factory/LaminasFactory.php index ca2765b..81b239f 100644 --- a/tests/Factory/ZendFactory.php +++ b/tests/Factory/LaminasFactory.php @@ -4,11 +4,11 @@ namespace UMA\Tests\Psr7Hmac\Factory; +use Laminas\Diactoros\Request; +use Laminas\Diactoros\Stream; use Psr\Http\Message\RequestInterface; -use Zend\Diactoros\Request; -use Zend\Diactoros\Stream; -class ZendFactory implements FactoryInterface +class LaminasFactory implements FactoryInterface { use StreamHelper; diff --git a/tests/Factory/SymfonyFactory.php b/tests/Factory/SymfonyFactory.php index c695845..9c74d38 100644 --- a/tests/Factory/SymfonyFactory.php +++ b/tests/Factory/SymfonyFactory.php @@ -4,17 +4,18 @@ namespace UMA\Tests\Psr7Hmac\Factory; +use Nyholm\Psr7\Factory\Psr17Factory; +use Nyholm\Psr7\ServerRequest as NyholmRequest; use Psr\Http\Message\RequestInterface; -use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory; +use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory; use Symfony\Component\HttpFoundation\Request as SymfonyRequest; -use Zend\Diactoros\ServerRequest as ZendRequest; final class SymfonyFactory implements FactoryInterface { /** * {@inheritdoc} * - * @return ZendRequest + * @return NyholmRequest */ public static function request(string $method, string $url, array $headers = [], string $body = null): RequestInterface { @@ -27,7 +28,8 @@ public static function request(string $method, string $url, array $headers = [], $symfonyRequest->headers->add($headers); - return (new DiactorosFactory()) + $factory = new Psr17Factory(); + return (new PsrHttpFactory($factory, $factory, $factory, $factory)) ->createRequest($symfonyRequest); } @@ -39,7 +41,7 @@ public static function requestClass(): string // This is indeed a white lie, as the HttpFoundation component // is not a PSR-7 implementation. - // Instead, the returned requests are actually Zend\Diactoros\ServerRequest + // Instead, the returned requests are actually Nyholm\Psr7\ServerRequest // instances produced by Symfony's own PSR-7 bridge. return SymfonyRequest::class; } diff --git a/tests/FullSpectrumTest.php b/tests/FullSpectrumTest.php index cc9a069..276970d 100644 --- a/tests/FullSpectrumTest.php +++ b/tests/FullSpectrumTest.php @@ -25,7 +25,7 @@ final class FullSpectrumTest extends TestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { $this->signer = new Signer(self::SECRET); } diff --git a/tests/Psr15/HmacMiddlewareTest.php b/tests/Psr15/HmacMiddlewareTest.php index 3b8dc03..ed8ecad 100644 --- a/tests/Psr15/HmacMiddlewareTest.php +++ b/tests/Psr15/HmacMiddlewareTest.php @@ -24,7 +24,7 @@ final class HmacMiddlewareTest extends TestCase */ private $signer; - protected function setUp() + protected function setUp(): void { $this->signer = new Signer(self::SAMPLE_SECRET); } diff --git a/tests/RequestsProvider.php b/tests/RequestsProvider.php index abb4a1c..8726a87 100644 --- a/tests/RequestsProvider.php +++ b/tests/RequestsProvider.php @@ -7,13 +7,13 @@ use Psr\Http\Message\RequestInterface; use UMA\Tests\Psr7Hmac\Factory\GuzzleFactory; use UMA\Tests\Psr7Hmac\Factory\KamboFactory; +use UMA\Tests\Psr7Hmac\Factory\LaminasFactory; use UMA\Tests\Psr7Hmac\Factory\NyholmFactory; use UMA\Tests\Psr7Hmac\Factory\RingCentralFactory; use UMA\Tests\Psr7Hmac\Factory\SlimFactory; use UMA\Tests\Psr7Hmac\Factory\SymfonyFactory; use UMA\Tests\Psr7Hmac\Factory\WanduFactory; use UMA\Tests\Psr7Hmac\Factory\WindwalkerFactory; -use UMA\Tests\Psr7Hmac\Factory\ZendFactory; trait RequestsProvider { @@ -120,13 +120,13 @@ private function requests(string $method, string $url, array $headers = [], stri return [ GuzzleFactory::requestClass() => [GuzzleFactory::request($method, $url, $headers, $body)], KamboFactory::requestClass() => [KamboFactory::request($method, $url, $headers, $body)], + LaminasFactory::requestClass() => [LaminasFactory::request($method, $url, $headers, $body)], NyholmFactory::requestClass() => [NyholmFactory::request($method, $url, $headers, $body)], RingCentralFactory::requestClass() => [RingCentralFactory::request($method, $url, $headers, $body)], SlimFactory::requestClass() => [SlimFactory::request($method, $url, $headers, $body)], SymfonyFactory::requestClass() => [SymfonyFactory::request($method, $url, $headers, $body)], WanduFactory::requestClass() => [WanduFactory::request($method, $url, $headers, $body)], WindwalkerFactory::requestClass() => [WindwalkerFactory::request($method, $url, $headers, $body)], - ZendFactory::requestClass() => [ZendFactory::request($method, $url, $headers, $body)], ]; } } diff --git a/tests/VerifierTest.php b/tests/VerifierTest.php index 147c457..441e311 100644 --- a/tests/VerifierTest.php +++ b/tests/VerifierTest.php @@ -24,7 +24,7 @@ final class VerifierTest extends TestCase /** * {@inheritdoc} */ - protected function setUp() + protected function setUp(): void { $this->verifier = new Verifier(); }