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 1c5e371..b6273b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +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 d1c56b9..c1ee65d 100644 --- a/composer.json +++ b/composer.json @@ -16,17 +16,17 @@ } ], "require": { - "php": "^5.6 || ^7.0", + "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": { @@ -37,5 +37,8 @@ "psr-4": { "Proxy\\": "tests" } + }, + "scripts": { + "test": "vendor/bin/phpunit" } } 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/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 b46017e..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'); } @@ -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');