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 diff --git a/composer.json b/composer.json index bcd43fa..0aa5722 100644 --- a/composer.json +++ b/composer.json @@ -16,8 +16,8 @@ "psr/http-client": "^1.0" }, "require-dev": { - "nyholm/psr7": "^1.3", - "phpunit/phpunit": "^6.5", + "guzzlehttp/psr7": "^1.7", + "phpunit/phpunit": ">=6.5", "squizlabs/php_codesniffer": "^3.5", "webclient/fake-http-client": "^1.0" }, 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 diff --git a/stuff/Handler.php b/stuff/Handler.php index 3b0e2fb..31343a4 100644 --- a/stuff/Handler.php +++ b/stuff/Handler.php @@ -4,7 +4,7 @@ namespace Stuff\Webclient\Extension\Redirect; -use Nyholm\Psr7\Response; +use GuzzleHttp\Psr7\Response; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Server\RequestHandlerInterface; @@ -40,6 +40,6 @@ public function handle(ServerRequestInterface $request): ResponseInterface $headers['Location'] = $request->getUri()->withQuery($get)->__toString(); $status = 302; } - return new Response($status, $headers, (string)$visit, '1.1'); + return new Response($status, $headers, (string)$visit); } } diff --git a/tests/RedirectClientTest.php b/tests/RedirectClientTest.php index c558f2c..321a8c9 100644 --- a/tests/RedirectClientTest.php +++ b/tests/RedirectClientTest.php @@ -4,8 +4,8 @@ namespace Tests\Webclient\Extension\Redirect; +use GuzzleHttp\Psr7\Request; use Stuff\Webclient\Extension\Redirect\Handler; -use Nyholm\Psr7\Request; use PHPUnit\Framework\TestCase; use Psr\Http\Client\ClientExceptionInterface; use Webclient\Extension\Redirect\Client; @@ -28,10 +28,9 @@ public function testRedirects(int $maxRedirects, int $needRedirects, int $expect $client = new Client(new FakeClient(new Handler()), $maxRedirects); - $request = new Request('GET', 'http://localhost?redirects=' . $needRedirects, ['Accept' => 'text/plain']); + $request = new Request('GET', 'http://localhost/?redirects=' . $needRedirects, ['Accept' => 'text/plain']); $response = $client->sendRequest($request); - $this->assertSame($expectRedirects, (int)$response->getBody()->__toString()); }