From 2d7ab29d2f5ff158652454c2557f812c4dbc0234 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 11:52:27 -0500 Subject: [PATCH 01/10] Add github actions workflow --- .github/workflows/ci.yml | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 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..ac847d6 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + test: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + dependencies: ['lowest', 'highest'] + + name: PHP ${{ matrix.php }} - ${{ matrix.dependencies }} + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: xdebug + extensions: mbstring + + - name: Cache Composer packages + uses: actions/cache@v3 + with: + path: vendor + key: ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependencies }}-${{ hashFiles('**/composer.lock') }} + restore-keys: | + ${{ runner.os }}-php-${{ matrix.php }}-${{ matrix.dependencies }}- + + - name: Install dependencies (highest) + if: matrix.dependencies == 'highest' + run: composer update --no-interaction --no-progress + + - name: Install dependencies (lowest) + if: matrix.dependencies == 'lowest' + run: composer update --prefer-lowest --no-interaction --no-progress + + - name: Run test suite + run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover + env: + XDEBUG_MODE: coverage \ No newline at end of file From 94e062899c598f43b6475b87a517becac6ebb2c5 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 11:52:49 -0500 Subject: [PATCH 02/10] Remove travisCI --- .travis.yml | 29 ----------------------------- README.md | 2 -- 2 files changed, 31 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8d09dec..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -language: php - -php: - - 7.0 - - 7.1 - - 7.2 - - 7.3 - - 7.4 - - 8.0 - -env: - global: - - XDEBUG_MODE=coverage - matrix: - - COMPOSER_FLAGS="--prefer-lowest" - - COMPOSER_FLAGS="" - -cache: - directories: - - $HOME/.composer/cache - -before_script: - - travis_retry composer update ${COMPOSER_FLAGS} --no-interaction - -script: - - vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - -after_script: - - php vendor/bin/php-coveralls -v -x coverage.clover -o coveralls-upload.json diff --git a/README.md b/README.md index 64d46ee..a33c7f8 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # RingPHP Guzzle Handler [![Latest Version on Packagist](https://img.shields.io/packagist/v/lukewaite/ringphp-guzzle-handler.svg?style=flat-square)](https://packagist.org/packages/lukewaite/ringphp-guzzle-handler) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) -[![Build Status](https://img.shields.io/travis/lukewaite/ringphp-guzzle-handler/master.svg?style=flat-square)](https://travis-ci.org/lukewaite/ringphp-guzzle-handler) -[![Coveralls](https://img.shields.io/coveralls/github/lukewaite/ringphp-guzzle-handler/master.svg?style=flat-square)](https://coveralls.io/github/lukewaite/ringphp-guzzle-handler) [![Total Downloads](https://img.shields.io/packagist/dt/lukewaite/ringphp-guzzle-handler.svg?style=flat-square)](https://packagist.org/packages/lukewaite/ringphp-guzzle-handler) ## Usage From d096f7ff54ee3d82beb48d8ca83827fe0058d670 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 12:00:23 -0500 Subject: [PATCH 03/10] Remove coverage --- .github/workflows/ci.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ac847d6..0742e2c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,7 +26,6 @@ jobs: uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - coverage: xdebug extensions: mbstring - name: Cache Composer packages @@ -46,6 +45,4 @@ jobs: run: composer update --prefer-lowest --no-interaction --no-progress - name: Run test suite - run: vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover - env: - XDEBUG_MODE: coverage \ No newline at end of file + run: vendor/bin/phpunit From ed7285169e4576e852b16a27ed2c8f2ef0e40602 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 12:03:11 -0500 Subject: [PATCH 04/10] Add prophecy dev dep --- composer.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index c79e269..2ffbfaa 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ }, "require-dev": { "phpunit/phpunit": "^5.7.11||^6.0||^7.0||^8.0", - "php-coveralls/php-coveralls": "^2.1" + "php-coveralls/php-coveralls": "^2.1", + "phpspec/prophecy": "^1.10" }, "autoload": { "psr-4": { From 97ad02b01bb7698a3fbcde7d773674714cbf8a00 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 12:06:23 -0500 Subject: [PATCH 05/10] Change supported versions to 8.0 --- .github/workflows/ci.yml | 2 +- composer.json | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0742e2c..95ede8b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3'] + php: ['8.0', '8.1', '8.2', '8.3', '8.4'] dependencies: ['lowest', 'highest'] name: PHP ${{ matrix.php }} - ${{ matrix.dependencies }} diff --git a/composer.json b/composer.json index 2ffbfaa..e93b654 100644 --- a/composer.json +++ b/composer.json @@ -8,13 +8,13 @@ } ], "require": { - "php": ">=7.0", + "php": ">=8.0", "guzzlehttp/ringphp": "^1.1", - "guzzlehttp/guzzle": "^6.2", - "guzzlehttp/psr7": "^1.4" + "guzzlehttp/guzzle": "^6.2|^7.0", + "guzzlehttp/psr7": "^1.4|^2.0" }, "require-dev": { - "phpunit/phpunit": "^5.7.11||^6.0||^7.0||^8.0", + "phpunit/phpunit": "^9.0|^10.0|^11.0", "php-coveralls/php-coveralls": "^2.1", "phpspec/prophecy": "^1.10" }, From ff068cb51e17817251a1d4cfbf10d38149091752 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 12:07:48 -0500 Subject: [PATCH 06/10] Remove coverage --- phpunit.xml.dist | 3 --- 1 file changed, 3 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 0ab862f..c8970b5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -22,8 +22,5 @@ - - - From 0151b3455f9d08fbca1915c18d67a12a2cb5a9e6 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 12:16:52 -0500 Subject: [PATCH 07/10] Remove prophecy --- composer.json | 3 +- tests/GuzzleHandlerTest.php | 61 +++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 28 deletions(-) diff --git a/composer.json b/composer.json index e93b654..40aff4e 100644 --- a/composer.json +++ b/composer.json @@ -15,8 +15,7 @@ }, "require-dev": { "phpunit/phpunit": "^9.0|^10.0|^11.0", - "php-coveralls/php-coveralls": "^2.1", - "phpspec/prophecy": "^1.10" + "php-coveralls/php-coveralls": "^2.1" }, "autoload": { "psr-4": { diff --git a/tests/GuzzleHandlerTest.php b/tests/GuzzleHandlerTest.php index 9fdff12..af67aee 100644 --- a/tests/GuzzleHandlerTest.php +++ b/tests/GuzzleHandlerTest.php @@ -18,14 +18,17 @@ public function it_makes_a_request() { $response = new Response(200, ['Content-Type' => ['application/json']], 'testResponseBody'); - $client = $this->prophesize(Client::class); - $client->requestAsync('POST', 'https://example.com/', [ - 'body' => 'testBody', - 'headers' => ['host'=>['example.com']], - 'http_errors' => false - ])->willReturn(new FulfilledPromise($response)); - - $handler = new GuzzleHandler($client->reveal()); + $client = $this->createMock(Client::class); + $client->expects($this->once()) + ->method('requestAsync') + ->with('POST', 'https://example.com/', [ + 'body' => 'testBody', + 'headers' => ['host'=>['example.com']], + 'http_errors' => false + ]) + ->willReturn(new FulfilledPromise($response)); + + $handler = new GuzzleHandler($client); $response = $handler([ 'http_method' => 'POST', 'scheme' => 'https', @@ -43,15 +46,18 @@ public function it_makes_requests_with_authentication() { $response = new Response(200, ['Content-Type' => ['application/json']], 'testResponseBody'); - $client = $this->prophesize(Client::class); - $client->requestAsync('POST', 'https://example.com/', [ - 'body' => 'testBody', - 'headers' => ['host' => ['example.com']], - 'http_errors' => false, - 'auth' => ['user', 'password'] - ])->willReturn(new FulfilledPromise($response)); - - $handler = new GuzzleHandler($client->reveal()); + $client = $this->createMock(Client::class); + $client->expects($this->once()) + ->method('requestAsync') + ->with('POST', 'https://example.com/', [ + 'body' => 'testBody', + 'headers' => ['host' => ['example.com']], + 'http_errors' => false, + 'auth' => ['user', 'password'] + ]) + ->willReturn(new FulfilledPromise($response)); + + $handler = new GuzzleHandler($client); $response = $handler([ 'http_method' => 'POST', 'scheme' => 'https', @@ -87,7 +93,7 @@ public function it_should_format_transfer_stats_that_elasticsearch_needs($respon { $stats = $response['transfer_stats']; $this->assertEquals('https://example.com/', $stats['url']); - $this->assertInternalType('float', $stats['total_time']); + $this->assertIsFloat($stats['total_time']); $this->assertEquals('application/json', $stats['content_type']); $this->assertEquals('200', $stats['http_code']); } @@ -97,14 +103,17 @@ public function it_should_catch_guzzle_exceptions_and_pass_as_an_error() { $exception = new TransferException('Test Exception'); - $client = $this->prophesize(Client::class); - $client->requestAsync('POST', 'https://example.com/', [ - 'body' => 'testBody', - 'headers' => ['host' => ['example.com']], - 'http_errors' => false, - ])->willReturn(new RejectedPromise($exception)); - - $handler = new GuzzleHandler($client->reveal()); + $client = $this->createMock(Client::class); + $client->expects($this->once()) + ->method('requestAsync') + ->with('POST', 'https://example.com/', [ + 'body' => 'testBody', + 'headers' => ['host' => ['example.com']], + 'http_errors' => false, + ]) + ->willReturn(new RejectedPromise($exception)); + + $handler = new GuzzleHandler($client); $response = $handler([ 'http_method' => 'POST', 'scheme' => 'https', From 98acc18a93444ae81fa8036b9138b48148d96e69 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 12:18:53 -0500 Subject: [PATCH 08/10] Drop support for 8 and 8.1 --- .github/workflows/ci.yml | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95ede8b..02521fd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.0', '8.1', '8.2', '8.3', '8.4'] + php: ['8.2', '8.3', '8.4'] dependencies: ['lowest', 'highest'] name: PHP ${{ matrix.php }} - ${{ matrix.dependencies }} diff --git a/composer.json b/composer.json index 40aff4e..5feb9f6 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ } ], "require": { - "php": ">=8.0", + "php": ">=8.2", "guzzlehttp/ringphp": "^1.1", "guzzlehttp/guzzle": "^6.2|^7.0", "guzzlehttp/psr7": "^1.4|^2.0" From 6c247ad09a83b2f1d1c45fe3819ad12cd177d1a2 Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 12:23:11 -0500 Subject: [PATCH 09/10] Raise minimum guzzle version --- composer.json | 4 ++-- phpunit.xml.dist | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/composer.json b/composer.json index 5feb9f6..da4a335 100644 --- a/composer.json +++ b/composer.json @@ -10,8 +10,8 @@ "require": { "php": ">=8.2", "guzzlehttp/ringphp": "^1.1", - "guzzlehttp/guzzle": "^6.2|^7.0", - "guzzlehttp/psr7": "^1.4|^2.0" + "guzzlehttp/guzzle": "^7.0", + "guzzlehttp/psr7": "^2.0" }, "require-dev": { "phpunit/phpunit": "^9.0|^10.0|^11.0", diff --git a/phpunit.xml.dist b/phpunit.xml.dist index c8970b5..b6e0582 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,7 @@ - + + + src/ + + tests - - - src/ - - - - + + From ee3ed39c6cfa2b27a6fef0d4ee27ba039864652f Mon Sep 17 00:00:00 2001 From: Luke Waite Date: Tue, 11 Nov 2025 12:24:01 -0500 Subject: [PATCH 10/10] Make PHP support explicit --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index da4a335..2189215 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ } ], "require": { - "php": ">=8.2", + "php": "^8.2|^8.3|^8.4", "guzzlehttp/ringphp": "^1.1", "guzzlehttp/guzzle": "^7.0", "guzzlehttp/psr7": "^2.0"