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 8eabd20..e338a84 100644 --- a/composer.json +++ b/composer.json @@ -19,8 +19,9 @@ "psr/http-server-handler": "^1.0" }, "require-dev": { - "nyholm/psr7": "^1.3", - "phpunit/phpunit": "^6.5", + "psr/http-factory": "^1.0", + "guzzlehttp/psr7": "^1.7", + "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 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(); + } }