Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow PHP 8 #33

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
27 changes: 16 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,34 @@
},
"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"
"squizlabs/php_codesniffer": "^3.6",
"symfony/phpunit-bridge": "^5.3"
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
}
},
"autoload": {
"psr-4": {
"OpsWay\\ZohoBooks\\": "src/"
}
},
"autoload-dev": {
"psr-4": { "OpsWay\\ZohoBooks\\Tests\\": "tests/" }
},
"extra": {
"branch-alias": {
"dev-master": "0.1-dev"
"psr-4": {
"OpsWay\\ZohoBooks\\Tests\\": "tests/"
}
},
"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/"
}
Expand Down
3 changes: 1 addition & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
>
<php>
Expand All @@ -20,7 +19,7 @@
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="./coverage.xml" highlight="true"/>
<log type="coverage-clover" target="./coverage.xml"/>
</logging>
<filter>
<whitelist addUncoveredFilesFromWhitelist="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
/**
Expand All @@ -24,58 +25,55 @@ 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())
->method('getConfig')
->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()
Expand Down