From 94c6e44ca1b35b3e4a467a53f22cdd88b0a45671 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Wed, 2 Jun 2021 23:19:44 -0300 Subject: [PATCH 1/2] Allow PHP 8 --- .travis.yml | 6 ++++-- composer.json | 23 ++++++++++++++--------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0ae993f..003f5c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,9 +6,11 @@ matrix: - php: 5.6 - php: 7.0 - php: 7.1 + - php: 7.2 + - php: 7.3 + - php: 7.4 + - php: 8.0 fast_finish: true - allow_failures: - - php: nightly before_script: - composer install diff --git a/composer.json b/composer.json index 5a949db..b6b4c45 100644 --- a/composer.json +++ b/composer.json @@ -13,12 +13,20 @@ }, "prefer-stable": true, "require": { - "php": "^5.6 | ^7.0", - "guzzlehttp/guzzle": "^6.0" + "php": "^5.6 || ^7.0 || ^8.0", + "guzzlehttp/guzzle": "^6.0 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^5.7", - "squizlabs/php_codesniffer": "^2.7" + "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.5 || ^9.5", + "squizlabs/php_codesniffer": "^3.6" + }, + "config": { + "sort-packages": true + }, + "extra": { + "branch-alias": { + "dev-master": "0.1-dev" + } }, "autoload": { "psr-4": { @@ -26,11 +34,8 @@ } }, "autoload-dev": { - "psr-4": { "OpsWay\\ZohoBooks\\Tests\\": "tests/" } - }, - "extra": { - "branch-alias": { - "dev-master": "0.1-dev" + "psr-4": { + "OpsWay\\ZohoBooks\\Tests\\": "tests/" } }, "scripts": { From 892745771e0e6ef6c11bd27cea36abd2c80c6361 Mon Sep 17 00:00:00 2001 From: Javier Spagnoletti Date: Thu, 3 Jun 2021 06:28:56 -0300 Subject: [PATCH 2/2] Use "symfony/phpunit-bridge" in order to allow testing between multiple PHPUnit versions --- composer.json | 8 ++-- phpunit.xml.dist | 3 +- .../ZohoBooks/Tests/Api => }/BaseApiTest.php | 46 +++++++++---------- 3 files changed, 27 insertions(+), 30 deletions(-) rename tests/Api/{OpsWay/ZohoBooks/Tests/Api => }/BaseApiTest.php (78%) diff --git a/composer.json b/composer.json index b6b4c45..549519d 100644 --- a/composer.json +++ b/composer.json @@ -17,8 +17,8 @@ "guzzlehttp/guzzle": "^6.0 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.5 || ^9.5", - "squizlabs/php_codesniffer": "^3.6" + "squizlabs/php_codesniffer": "^3.6", + "symfony/phpunit-bridge": "^5.3" }, "config": { "sort-packages": true @@ -39,8 +39,8 @@ } }, "scripts": { - "test": "phpunit --no-coverage", - "test-cover": "phpunit", + "test": "simple-phpunit --no-coverage", + "test-cover": "simple-phpunit", "cs-check": "phpcs -n --standard=PSR2 --extensions=php src/", "cs-fix": "phpcbf --standard=PSR2 --extensions=php src/" } diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 23ec715..40f19f5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -8,7 +8,6 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="false" bootstrap="vendor/autoload.php" > @@ -20,7 +19,7 @@ - + diff --git a/tests/Api/OpsWay/ZohoBooks/Tests/Api/BaseApiTest.php b/tests/Api/BaseApiTest.php similarity index 78% rename from tests/Api/OpsWay/ZohoBooks/Tests/Api/BaseApiTest.php rename to tests/Api/BaseApiTest.php index 5c43789..8d96739 100644 --- a/tests/Api/OpsWay/ZohoBooks/Tests/Api/BaseApiTest.php +++ b/tests/Api/BaseApiTest.php @@ -6,13 +6,14 @@ use OpsWay\ZohoBooks\Client; use GuzzleHttp\Client as BaseClient; use GuzzleHttp\ClientInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class BaseApiTest extends TestCase { const ORG_ID = 1; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var Client&MockObject */ private $client; /** @@ -24,13 +25,18 @@ class BaseApiTest extends TestCase */ private $customHttpClient; - public function setUp() + public function setUp(): void { + parent::setUp(); + $this->client = $this->createMock(Client::class); $this->baseApi = new BaseApi($this->client, self::ORG_ID); $this->customHttpClient = $this->createMock(BaseClient::class); } + /** + * @doesNotPerformAssertions + */ public function testCustomHttpClient() { $this->customHttpClient->expects($this->any()) @@ -38,44 +44,36 @@ public function testCustomHttpClient() ->with('http_errors') ->willReturn(false) ; - $client = $this->getMockBuilder(Client::class) - ->setConstructorArgs(['authToken', null, null, $this->customHttpClient]) - ->getMock() - ; + + new Client('authToken', null, null, $this->customHttpClient); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp /Request option "http_errors" must be set to `false` at HTTP client/ - */ public function testCustomHttpClientWithWrongHttpErrorsConfig() { - $this->customHttpClient->expects($this->any()) + $this->customHttpClient->expects($this->once()) ->method('getConfig') ->with('http_errors') ->willReturn(true) ; - $client = $this->getMockBuilder(Client::class) - ->setConstructorArgs(['authToken', null, null, $this->customHttpClient]) - ->getMock() - ; + + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessageMatches('/Request option "http_errors" must be set to `false` at HTTP client/'); + + new Client('authToken', null, null, $this->customHttpClient); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessageRegExp /If argument 4 is provided, argument 5 must be omitted or passed with an empty array as value/ - */ public function testCustomHttpClientWithRequestOptions() { - $this->customHttpClient->expects($this->any()) + $this->customHttpClient->expects($this->never()) ->method('getConfig') ->with('http_errors') ->willReturn(true) ; - $client = $this->getMockBuilder(Client::class) - ->setConstructorArgs(['authToken', null, null, $this->customHttpClient, ['verify' => true]]) - ->getMock() - ; + + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessageMatches('/If argument 4 is provided, argument 5 must be omitted or passed with an empty array as value/'); + + new Client('authToken', null, null, $this->customHttpClient, ['verify' => true]); } public function testGetList()