diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index bb5914c..1f903e5 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -17,7 +17,7 @@ jobs: timeout-minutes: 20 strategy: matrix: - php: [ 5.6, 7.0, 7.1, 7.2, 7.3, 7.4 ] + php: [ '7.3', '7.4', '8.0', '8.1' ] dependencies: - "lowest" - "highest" @@ -56,7 +56,7 @@ jobs: - name: Setup PHP uses: shivammathur/setup-php@2.15.0 with: - php-version: '7.4' + php-version: '8.1' id: php - name: Build Release Artifacts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 6d1425b..c587736 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,7 +47,7 @@ We welcome direct contributions to the php-http-client code base. Thank you! ##### Prerequisites ##### -- PHP 5.6 or 7.0 +- PHP version 7.3, 7.4, 8.0, or 8.1 - [Composer](https://getcomposer.org/) ##### Initial setup: ##### diff --git a/Dockerfile b/Dockerfile index da1ef10..2261ad9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.1-apache +FROM php:8.1 ARG sendgrid_apikey ENV SENDGRID_API_KEY=$sendgrid_apikey @@ -7,7 +7,8 @@ COPY . /var/www/client WORKDIR /var/www/client RUN apt-get update && \ - apt-get install -y git zip zlib1g-dev && docker-php-ext-install zip + apt-get install -y git libzip-dev && \ + docker-php-ext-install zip RUN curl --silent --show-error https://getcomposer.org/installer | php RUN php composer.phar install diff --git a/Makefile b/Makefile index f14433b..db07641 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ ci-install: clean composer install --no-dev install: clean - composer install --no-suggest --no-scripts --no-progress --no-interaction + composer install --no-scripts --no-progress --no-interaction test: install vendor/bin/phpunit test/unit diff --git a/README.md b/README.md index 9ef4b34..e86f3a4 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ All updates to this library are documented in our [CHANGELOG](CHANGELOG.md). ## Prerequisites -- PHP version 5.6, 7.0, 7.1, 7.2, 7.3, or 7.4 +- PHP version 7.3, 7.4, 8.0, or 8.1 ## Install with Composer diff --git a/UPGRADE.md b/UPGRADE.md new file mode 100644 index 0000000..eb3b944 --- /dev/null +++ b/UPGRADE.md @@ -0,0 +1,8 @@ +# Upgrade Guide + +_MAJOR version bumps will have upgrade notes posted here._ + +[2022-05-04] 3.x.x to 4.x.x +--------------------------- + +### CHANGED - Drop support for PHP versions 5.6, 7.0, 7.1, and 7.2 which are EOL. diff --git a/composer.json b/composer.json index 0c637fa..2d0ead0 100644 --- a/composer.json +++ b/composer.json @@ -16,14 +16,13 @@ } ], "require": { - "php": ">=5.6", + "php": ">=7.3", "ext-curl": "*", "ext-json": "*", "ext-mbstring": "*" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.5", - "sebastian/version": "^1.0.6", + "phpunit/phpunit": "^9", "squizlabs/php_codesniffer": "~2.0", "friendsofphp/php-cs-fixer": "^2.16" }, diff --git a/test/unit/ClientTest.php b/test/unit/ClientTest.php index 41f2ca8..cfea449 100644 --- a/test/unit/ClientTest.php +++ b/test/unit/ClientTest.php @@ -15,7 +15,7 @@ class ClientTest extends TestCase /** @var array */ private $headers; - protected function setUp() + protected function setUp(): void { $this->host = 'https://localhost:4010'; $this->headers = [ @@ -27,13 +27,11 @@ protected function setUp() public function testConstructor() { - $this->assertAttributeEquals($this->host, 'host', $this->client); - $this->assertAttributeEquals($this->headers, 'headers', $this->client); - $this->assertAttributeEquals('/v3', 'version', $this->client); - $this->assertAttributeEquals([], 'path', $this->client); - $this->assertAttributeEquals([], 'curlOptions', $this->client); - $this->assertAttributeEquals(false, 'retryOnLimit', $this->client); - $this->assertAttributeEquals(['get', 'post', 'patch', 'put', 'delete'], 'methods', $this->client); + $this->assertEquals($this->host, $this->client->getHost()); + $this->assertEquals($this->headers, $this->client->getHeaders()); + $this->assertEquals('/v3', $this->client->getVersion()); + $this->assertEquals([], $this->client->getPath()); + $this->assertEquals([], $this->client->getCurlOptions()); } public function test_() @@ -42,34 +40,34 @@ public function test_() $client->setCurlOptions(['foo' => 'bar']); $client = $client->_('test'); - $this->assertAttributeEquals(['test'], 'path', $client); - $this->assertAttributeEquals(['foo' => 'bar'], 'curlOptions', $client); + $this->assertEquals(['test'], $client->getPath()); + $this->assertEquals(['foo' => 'bar'], $client->getCurlOptions()); } public function test__call() { $client = $this->client->get(); - $this->assertAttributeEquals('https://localhost:4010/v3/', 'url', $client); + $this->assertEquals('https://localhost:4010/v3/', $client->url); $queryParams = ['limit' => 100, 'offset' => 0]; $client = $this->client->get(null, $queryParams); - $this->assertAttributeEquals('https://localhost:4010/v3/?limit=100&offset=0', 'url', $client); + $this->assertEquals('https://localhost:4010/v3/?limit=100&offset=0', $client->url); $requestBody = ['name' => 'A New Hope']; $client = $this->client->get($requestBody); - $this->assertAttributeEquals($requestBody, 'requestBody', $client); + $this->assertEquals($requestBody, $client->requestBody); $requestHeaders = ['X-Mock: 200']; $client = $this->client->get(null, null, $requestHeaders); - $this->assertAttributeEquals($requestHeaders, 'requestHeaders', $client); + $this->assertEquals($requestHeaders, $client->requestHeaders); $client = $this->client->version('/v4'); - $this->assertAttributeEquals('/v4', 'version', $client); + $this->assertEquals('/v4', $client->getVersion()); $client = $this->client->path_to_endpoint(); - $this->assertAttributeEquals(['path_to_endpoint'], 'path', $client); + $this->assertEquals(['path_to_endpoint'], $client->getPath()); $client = $client->one_more_segment(); - $this->assertAttributeEquals(['path_to_endpoint', 'one_more_segment'], 'path', $client); + $this->assertEquals(['path_to_endpoint', 'one_more_segment'], $client->getPath()); } public function testGetHost() @@ -212,7 +210,7 @@ public function testThrowExceptionOnInvalidCall() public function testMakeRequestWithUntrustedRootCert() { $this->expectException(InvalidRequest::class); - $this->expectExceptionMessageRegExp('/certificate/i'); + $this->expectExceptionMessageMatches('/certificate/i'); $client = new Client('https://untrusted-root.badssl.com/'); $client->makeRequest('GET', 'https://untrusted-root.badssl.com/'); @@ -223,12 +221,12 @@ public function testFormRepeatUrlArgs() $client = new Client('https://localhost:4010'); $testParams = [ - 'thing' => 'stuff', - 'foo' => [ - 'bar', - 'bat', - 'baz', - ], + 'thing' => 'stuff', + 'foo' => [ + 'bar', + 'bat', + 'baz', + ], ]; $result = $this->callMethod($client, 'buildUrl', [$testParams]); $this->assertEquals($result, 'https://localhost:4010/?thing=stuff&foo=bar&foo=bat&foo=baz'); diff --git a/test/unit/MockClient.php b/test/unit/MockClient.php index ae7ed79..b1c897a 100644 --- a/test/unit/MockClient.php +++ b/test/unit/MockClient.php @@ -6,9 +6,9 @@ class MockClient extends Client { - protected $requestBody; - protected $requestHeaders; - protected $url; + public $requestBody; + public $requestHeaders; + public $url; public function makeRequest($method, $url, $requestBody = null, $requestHeaders = null, $retryOnLimit = false) { diff --git a/test/unit/ResponseTest.php b/test/unit/ResponseTest.php index 3366ec6..9f83b89 100644 --- a/test/unit/ResponseTest.php +++ b/test/unit/ResponseTest.php @@ -2,8 +2,8 @@ namespace SendGrid\Test; -use SendGrid\Response; use PHPUnit\Framework\TestCase; +use SendGrid\Response; class ResponseTest extends TestCase { @@ -11,15 +11,15 @@ public function testConstructor() { $response = new Response(); - $this->assertAttributeEquals(200, 'statusCode', $response); - $this->assertAttributeEquals('', 'body', $response); - $this->assertAttributeEquals([], 'headers', $response); + $this->assertEquals(200, $response->statusCode()); + $this->assertEquals('', $response->body()); + $this->assertEquals([], $response->headers()); $response = new Response(201, 'test', ['Content-Encoding: gzip']); - $this->assertAttributeEquals(201, 'statusCode', $response); - $this->assertAttributeEquals('test', 'body', $response); - $this->assertAttributeEquals(['Content-Encoding: gzip'], 'headers', $response); + $this->assertEquals(201, $response->statusCode()); + $this->assertEquals('test', $response->body()); + $this->assertEquals(['Content-Encoding: gzip'], $response->headers()); } public function testStatusCode()