From 5d01f3efd78273019b09818bfc162a9231066f96 Mon Sep 17 00:00:00 2001 From: Ivan Dudarev Date: Wed, 4 Nov 2020 19:06:58 +0700 Subject: [PATCH 1/3] change phpunit vesion for PHP 7.0 - 8.0 support --- composer.json | 2 +- phpunit.xml.dist | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 8eabd20..d0b1ff9 100644 --- a/composer.json +++ b/composer.json @@ -20,7 +20,7 @@ }, "require-dev": { "nyholm/psr7": "^1.3", - "phpunit/phpunit": "^6.5", + "phpunit/phpunit": ">=6.5", "squizlabs/php_codesniffer": "^3.5" }, "provide": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 66b98f0..6f90c5c 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,5 @@ - + tests From 8fd1fe435a77dd7aa8bd3ebde06519864657a8e0 Mon Sep 17 00:00:00 2001 From: Ivan Dudarev Date: Wed, 4 Nov 2020 19:23:34 +0700 Subject: [PATCH 2/3] replace nyholm/psr7 to guzzlehttp/psr7 for PHP 7.0 support --- composer.json | 3 ++- stuff/Factory/HttpFactory.php | 46 +++++++++++++++++++++++++++++++++++ tests/ClientTest.php | 19 +++++++++------ 3 files changed, 59 insertions(+), 9 deletions(-) create mode 100644 stuff/Factory/HttpFactory.php diff --git a/composer.json b/composer.json index d0b1ff9..e338a84 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,8 @@ "psr/http-server-handler": "^1.0" }, "require-dev": { - "nyholm/psr7": "^1.3", + "psr/http-factory": "^1.0", + "guzzlehttp/psr7": "^1.7", "phpunit/phpunit": ">=6.5", "squizlabs/php_codesniffer": "^3.5" }, diff --git a/stuff/Factory/HttpFactory.php b/stuff/Factory/HttpFactory.php new file mode 100644 index 0000000..1e8c1d6 --- /dev/null +++ b/stuff/Factory/HttpFactory.php @@ -0,0 +1,46 @@ +factory = new Psr17Factory(); - } - /** * @throws ClientExceptionInterface */ public function testSuccessWithRequest() { + $this->init(); $request = $this->factory->createRequest('GET', 'http://phpunit.de/?return=302&redirect=https://phpunit.de'); $client = new Client(new UniversalHandler($this->factory)); $response = $client->sendRequest($request); @@ -44,6 +39,7 @@ public function testSuccessWithRequest() */ public function testSuccessWithServerRequest() { + $this->init(); $request = $this->factory->createServerRequest( 'GET', 'https://phpunit.de', @@ -64,6 +60,7 @@ public function testSuccessWithServerRequest() */ public function testSuccessWithPreparedServerRequest() { + $this->init(); $request = $this->factory->createServerRequest( 'GET', 'https://phpunit.de', @@ -83,9 +80,15 @@ public function testSuccessWithPreparedServerRequest() */ public function testFailWithNetworkError() { + $this->init(); $request = $this->factory->createRequest('GET', '/'); $client = new Client(new ErrorHandler()); $this->expectException(NetworkExceptionInterface::class); $client->sendRequest($request); } + + private function init() + { + $this->factory = new HttpFactory(); + } } From 495fdcdc3a7904ab0def55d80b85df73010e2f88 Mon Sep 17 00:00:00 2001 From: Ivan Dudarev Date: Wed, 4 Nov 2020 19:24:15 +0700 Subject: [PATCH 3/3] added github actions CI configuration --- .github/workflows/ci.yml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..58bbeb8 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: [push, pull_request] + +jobs: + tests: + runs-on: ubuntu-latest + + strategy: + matrix: + php: [7.0, 7.1, 7.2, 7.3, 7.4, 8.0] + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Validate composer.json and composer.lock + run: composer validate + + - name: Install dependencies + run: composer install --prefer-dist --no-progress --no-interaction --no-suggest + + - name: Check code style + run: vendor/bin/phpcs + + - name: Run test suite + run: vendor/bin/phpunit \ No newline at end of file