From 17752f4b3d2efd9758640392e9bc915958f008da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Ot=C3=A1vio=20Ferreira?= Date: Thu, 29 Jul 2021 10:22:59 -0300 Subject: [PATCH 1/4] refactor: Compatibility with PHP 8 --- .travis.yml | 2 ++ composer.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1c5e371..1167a6d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,8 @@ php: - 7.1 - 7.2 - 7.3 + - 7.4 + - 8.0 sudo: false diff --git a/composer.json b/composer.json index d1c56b9..f45193b 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ } ], "require": { - "php": "^5.6 || ^7.0", + "php": ">=7.3", "psr/http-message": "^1.0", "guzzlehttp/guzzle": "^6.0", "laminas/laminas-diactoros": "^2.0", From 1bdc9ea5430858eee5b3e4788a6f5a75622b8046 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Ot=C3=A1vio=20Ferreira?= Date: Thu, 29 Jul 2021 10:23:23 -0300 Subject: [PATCH 2/4] refactor: Upgrade phpunit.xml config --- phpunit.xml | 24 +++++++++++++----------- tests/Proxy/ProxyTest.php | 3 +-- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/phpunit.xml b/phpunit.xml index 8034fdf..da13ea1 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,5 +1,7 @@ - - - - tests/Proxy/ - - - - - ./src - - + + + ./src + + + + + tests/Proxy/ + + diff --git a/tests/Proxy/ProxyTest.php b/tests/Proxy/ProxyTest.php index b46017e..3294432 100644 --- a/tests/Proxy/ProxyTest.php +++ b/tests/Proxy/ProxyTest.php @@ -48,8 +48,7 @@ public function to_applies_filters() { $applied = false; - $this->proxy->forward(ServerRequestFactory::fromGlobals())->filter(function ($request, $response) use (&$applied - ) { + $this->proxy->forward(ServerRequestFactory::fromGlobals())->filter(function ($request, $response) use (&$applied) { $applied = true; })->to('http://www.example.com'); From 41770830c62ecacb83959fac7f6e42049b5713eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Ot=C3=A1vio=20Ferreira?= Date: Thu, 29 Jul 2021 11:10:24 -0300 Subject: [PATCH 3/4] refactor: Upgrade deps --- composer.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index f45193b..b32150c 100644 --- a/composer.json +++ b/composer.json @@ -18,15 +18,15 @@ "require": { "php": ">=7.3", "psr/http-message": "^1.0", - "guzzlehttp/guzzle": "^6.0", - "laminas/laminas-diactoros": "^2.0", + "guzzlehttp/guzzle": "^7.3", + "laminas/laminas-diactoros": "^2.6", "relay/relay": "^1.0", - "laminas/laminas-httphandlerrunner": "^1.1" + "laminas/laminas-httphandlerrunner": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^5.0|^6.0|^7.0", - "php-coveralls/php-coveralls": "^2.0", - "mockery/mockery": "^1.1" + "phpunit/phpunit": "^9.0", + "php-coveralls/php-coveralls": "^2.4", + "mockery/mockery": "^1.4" }, "autoload": { "psr-4": { From b2e85a322c448112d8060a740a345a583d4b6013 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Victor=20Ot=C3=A1vio=20Ferreira?= Date: Thu, 29 Jul 2021 11:26:08 -0300 Subject: [PATCH 4/4] refactor: Automated tests with GitHub Actions --- .github/workflows/test.yml | 33 +++++++++++++++++++ .travis.yml | 4 +-- composer.json | 3 ++ .../Proxy/Adapter/Dummy/DummyAdapterTest.php | 2 +- .../Adapter/Guzzle/GuzzleAdapterTest.php | 2 +- .../Proxy/Filter/RemoveEncodingFilterTest.php | 2 +- .../Proxy/Filter/RemoveLocationFilterTest.php | 2 +- .../Filter/RewriteLocationFilterTest.php | 2 +- tests/Proxy/ProxyTest.php | 4 +-- 9 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/ .github/workflows/test.yml b/ .github/workflows/test.yml new file mode 100644 index 0000000..c6243ef --- /dev/null +++ b/ .github/workflows/test.yml @@ -0,0 +1,33 @@ +name: Tests with PHPUnit + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Validate composer.json and composer.lock + run: composer validate --strict + + - name: Cache Composer packages + id: composer-cache + uses: actions/cache@v2 + with: + path: vendor + key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php- + + - name: Install dependencies + run: composer install --prefer-dist --no-progress + + - name: Run test suite + run: composer run-script test diff --git a/.travis.yml b/.travis.yml index 1167a6d..b6273b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,13 @@ language: php php: - - 7.1 - - 7.2 - 7.3 - 7.4 - 8.0 sudo: false -dist: trusty +dist: bionic before_script: - composer self-update diff --git a/composer.json b/composer.json index b32150c..c1ee65d 100644 --- a/composer.json +++ b/composer.json @@ -37,5 +37,8 @@ "psr-4": { "Proxy\\": "tests" } + }, + "scripts": { + "test": "vendor/bin/phpunit" } } diff --git a/tests/Proxy/Adapter/Dummy/DummyAdapterTest.php b/tests/Proxy/Adapter/Dummy/DummyAdapterTest.php index 62a869b..a4a52cc 100644 --- a/tests/Proxy/Adapter/Dummy/DummyAdapterTest.php +++ b/tests/Proxy/Adapter/Dummy/DummyAdapterTest.php @@ -13,7 +13,7 @@ class DummyAdapterTest extends TestCase */ private $adapter; - public function setUp() + public function setUp(): void { $this->adapter = new DummyAdapter(); } diff --git a/tests/Proxy/Adapter/Guzzle/GuzzleAdapterTest.php b/tests/Proxy/Adapter/Guzzle/GuzzleAdapterTest.php index 9f9940b..0bdc338 100644 --- a/tests/Proxy/Adapter/Guzzle/GuzzleAdapterTest.php +++ b/tests/Proxy/Adapter/Guzzle/GuzzleAdapterTest.php @@ -32,7 +32,7 @@ class GuzzleAdapterTest extends TestCase */ private $body = 'Totally awesome response body'; - public function setUp() + public function setUp(): void { $mock = new MockHandler([ $this->createResponse(), diff --git a/tests/Proxy/Filter/RemoveEncodingFilterTest.php b/tests/Proxy/Filter/RemoveEncodingFilterTest.php index c407695..7a397ca 100644 --- a/tests/Proxy/Filter/RemoveEncodingFilterTest.php +++ b/tests/Proxy/Filter/RemoveEncodingFilterTest.php @@ -13,7 +13,7 @@ class RemoveEncodingFilterTest extends TestCase */ private $filter; - public function setUp() + public function setUp(): void { $this->filter = new RemoveEncodingFilter(); } diff --git a/tests/Proxy/Filter/RemoveLocationFilterTest.php b/tests/Proxy/Filter/RemoveLocationFilterTest.php index ea96bde..a9a4971 100644 --- a/tests/Proxy/Filter/RemoveLocationFilterTest.php +++ b/tests/Proxy/Filter/RemoveLocationFilterTest.php @@ -13,7 +13,7 @@ class RemoveLocationFilterTest extends TestCase */ private $filter; - public function setUp() + public function setUp(): void { $this->filter = new RemoveLocationFilter(); } diff --git a/tests/Proxy/Filter/RewriteLocationFilterTest.php b/tests/Proxy/Filter/RewriteLocationFilterTest.php index 3bcc5f4..c67b71e 100644 --- a/tests/Proxy/Filter/RewriteLocationFilterTest.php +++ b/tests/Proxy/Filter/RewriteLocationFilterTest.php @@ -11,7 +11,7 @@ class RewriteLocationFilterTest extends TestCase */ private $filter; - public function setUp() + public function setUp(): void { $this->filter = new RewriteLocationFilter(); } diff --git a/tests/Proxy/ProxyTest.php b/tests/Proxy/ProxyTest.php index 3294432..851d26b 100644 --- a/tests/Proxy/ProxyTest.php +++ b/tests/Proxy/ProxyTest.php @@ -17,17 +17,17 @@ class ProxyTest extends TestCase */ private $proxy; - public function setUp() + public function setUp(): void { $this->proxy = new Proxy(new DummyAdapter()); } /** * @test - * @expectedException UnexpectedValueException */ public function to_throws_exception_if_no_request_is_given() { + $this->expectException('UnexpectedValueException'); $this->proxy->to('http://www.example.com'); }