From 66fd858a02a6f518bd8586f41afc7bb57ee9fd2e Mon Sep 17 00:00:00 2001 From: David Garcia Date: Sat, 30 Jan 2021 06:39:30 +0000 Subject: [PATCH] PHP 8.x support (#727) * Set dependencies for 7.3 and 8.x * Set GitHub Actions for PHP 7.3, 7.4 and 8.0 * Set Ubuntu version that supports PHP from 7.1 to 7.4 According to warnings raised by GitHub Actions, the alias for the latest Ubuntu version will upgrade soon to the newer 20.04 LTS instead of 18.04. Aiming to ensure the compatibility with previous PHP versions, it's safer to force the Ubuntu 18.04 that has the previous PHP version as built-in versions in the OS https://github.com/marketplace/actions/setup-php-action#github-hosted-runners * Fix dependencies for PHP ^7.3 and ^8.0 support * Run test suite with PHP versions from 7.3 to 8.1 * Broken Prophecy dependency for PHPUnit on PHP 8.1 This broken dependency doesn't allow us to run PHPUnit tests and ensure it works. Keeping the ^8.0 version should allow installations for non-maintainers on newer versions too. https://packagist.org/packages/phpspec/prophecy#1.12.2 requires - php: ^7.2 || ~8.0, <8.1 - ... * Use the latest Ubuntu version instead of a specific version * Prepare Changelog for PHP 8.0 --- .github/workflows/php.yml | 7 ++++--- .gitignore | 1 + CHANGELOG.md | 10 ++++++++++ composer.json | 20 ++++++++++---------- tests/Api/StatsTest.php | 6 +++--- tests/Api/TestCase.php | 2 +- tests/HttpClient/RequestBuilderTest.php | 4 ++-- tests/Message/BatchMessageTest.php | 2 +- tests/Message/MessageBuilderTest.php | 2 +- 9 files changed, 33 insertions(+), 21 deletions(-) diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 3364648..9f45e20 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,8 +11,9 @@ jobs: strategy: matrix: + # https://github.com/marketplace/actions/setup-php-action#github-hosted-runners operating-system: [ 'ubuntu-latest' ] - php-versions: [ '7.1', '7.2', '7.3', '7.4' ] + php-versions: [ '7.3', '7.4', '8.0' ] runs-on: ${{ matrix.operating-system }} @@ -37,13 +38,13 @@ jobs: run: composer test - name: PHP Stan - if: matrix.php-versions == '7.1' + if: matrix.php-versions == '7.3' run: | phpstan --version phpstan analyse - name: Scrunitizer CI - if: matrix.php-versions == '7.1' + if: matrix.php-versions == '7.3' run: | wget https://scrutinizer-ci.com/ocular.phar php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml diff --git a/.gitignore b/.gitignore index 77b11fa..27b106d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ composer.lock phpunit.phar phpunit.xml modd.conf +.phpunit.result.cache diff --git a/CHANGELOG.md b/CHANGELOG.md index eef50bc..0c808cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. +## [Unreleased] + +### Added + +- Support for PHP 8.x + +### Removed + +- Support for PHP 7.1 and 7.2 as they both have reached their end of life + ## 3.2.0 ### Added diff --git a/composer.json b/composer.json index 8279ff5..b4d80d2 100644 --- a/composer.json +++ b/composer.json @@ -2,18 +2,18 @@ "name": "mailgun/mailgun-php", "description": "The Mailgun SDK provides methods for all API functions.", "require": { - "php": "^7.1", - "psr/http-client": "^1.0", - "php-http/multipart-stream-builder": "^1.0", - "php-http/client-common": "^1.9 || ^2.0", - "php-http/discovery": "^1.6", - "webmozart/assert": "^1.6" + "php": "^7.3 || ^8.0", + "psr/http-client": "^1.0.1", + "php-http/multipart-stream-builder": "^1.1.2", + "php-http/client-common": "^2.2.1", + "php-http/discovery": "^1.9.1", + "webmozart/assert": "^1.9.1" }, "require-dev": { - "phpunit/phpunit": "^7.5", - "php-http/guzzle6-adapter": "^1.0 || ^2.0", - "nyholm/psr7": "^1.0", - "nyholm/nsa": "^1.1" + "phpunit/phpunit": "^9.3", + "php-http/guzzle7-adapter": "^0.1.1", + "nyholm/psr7": "^1.3.1", + "nyholm/nsa": "^1.2.1" }, "autoload": { "psr-4": { diff --git a/tests/Api/StatsTest.php b/tests/Api/StatsTest.php index 4d06563..240f1f6 100644 --- a/tests/Api/StatsTest.php +++ b/tests/Api/StatsTest.php @@ -12,6 +12,7 @@ declare(strict_types=1); namespace Mailgun\Tests\Api; use GuzzleHttp\Psr7\Response; +use Mailgun\Exception\InvalidArgumentException; use Mailgun\Hydrator\ModelHydrator; use Mailgun\Model\Stats\TotalResponse; use Mailgun\Model\Stats\TotalResponseItem; @@ -44,11 +45,10 @@ class StatsTest extends TestCase $this->assertContainsOnlyInstancesOf(TotalResponseItem::class, $total->getStats()); } - /** - * @expectedException \Mailgun\Exception\InvalidArgumentException - */ public function testTotalInvalidArgument() { + $this->expectException(InvalidArgumentException::class); + $api = $this->getApiMock(); $api->total(''); } diff --git a/tests/Api/TestCase.php b/tests/Api/TestCase.php index 0122317..b7e6726 100644 --- a/tests/Api/TestCase.php +++ b/tests/Api/TestCase.php @@ -37,7 +37,7 @@ abstract class TestCase extends \PHPUnit\Framework\TestCase private $hydrateClass; - protected function setUp() + protected function setUp(): void { $this->reset(); } diff --git a/tests/HttpClient/RequestBuilderTest.php b/tests/HttpClient/RequestBuilderTest.php index 4e17164..6042122 100644 --- a/tests/HttpClient/RequestBuilderTest.php +++ b/tests/HttpClient/RequestBuilderTest.php @@ -40,7 +40,7 @@ class RequestBuilderTest extends MailgunTestCase /** * Environment preset. */ - protected function setUp() + protected function setUp(): void { parent::setUp(); @@ -61,7 +61,7 @@ class RequestBuilderTest extends MailgunTestCase /** * Environment reset. */ - protected function tearDown() + protected function tearDown(): void { parent::tearDown(); diff --git a/tests/Message/BatchMessageTest.php b/tests/Message/BatchMessageTest.php index 487e1c8..b1e1937 100644 --- a/tests/Message/BatchMessageTest.php +++ b/tests/Message/BatchMessageTest.php @@ -25,7 +25,7 @@ class BatchMessageTest extends MailgunTestCase */ private $batchMessage; - public function setUp() + public function setUp(): void { $messageApi = $this->getMockBuilder(Message::class) ->disableOriginalConstructor() diff --git a/tests/Message/MessageBuilderTest.php b/tests/Message/MessageBuilderTest.php index c16a9ec..5e32ade 100644 --- a/tests/Message/MessageBuilderTest.php +++ b/tests/Message/MessageBuilderTest.php @@ -22,7 +22,7 @@ class MessageBuilderTest extends MailgunTestCase */ private $messageBuilder; - public function setUp() + public function setUp(): void { $this->messageBuilder = new MessageBuilder(); }