Skip to content

Commit

Permalink
Merge pull request #53 from chrisryan/master
Browse files Browse the repository at this point in the history
Add support for PHP 8.
  • Loading branch information
chrisryan authored Sep 20, 2022
2 parents 2b27091 + b7b07d7 commit 5a0e236
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
php-versions: ['7.3', '7.4', '8.0', '8.1']
steps:
- name: Checkout
uses: actions/checkout@v2
Expand Down
4 changes: 4 additions & 0 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ filter:
before_commands:
- 'composer install'
build:
environment:
php:
pecl_extensions:
- mongodb
nodes:
analysis:
tests:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This is a PHP client for [REST](http://en.wikipedia.org/wiki/Representational_st

## Requirements

This api client requires PHP 7.0 or newer and uses composer to install further PHP dependencies. See the [composer specification](composer.json) for more details.
This api client requires PHP 7.3 or newer and uses composer to install further PHP dependencies. See the [composer specification](composer.json) for more details.

When contributing, access to a working mongo database for testing is needed. See the [Contribution Guidelines](.github/CONTRIBUTING.md) for more details.

Expand Down
13 changes: 6 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
],
"license": "MIT",
"require": {
"php": "^7.0",
"php": "^7.3 || ^8.0",
"ext-curl": "*",
"ext-json": "*",
"lib-curl": "~7.15",
"fig/http-message-util": "^1.1",
"guzzlehttp/guzzle": "^6.3",
"psr/http-message": "^1.0",
"psr/simple-cache": "^1.0",
"subjective-php/psr-cache-helper": "^1.1",
"traderinteractive/util": "^3.0"
"subjective-php/psr-cache-helper": "^2.0",
"traderinteractive/util": "^4.0"
},
"config": {
"sort-packages": true
Expand All @@ -39,11 +39,10 @@
"subjective-php/psr-cache-mongodb": "Used for Caching with Mongo"
},
"require-dev": {
"helmich/mongomock": "^2.1",
"php-coveralls/php-coveralls": "^2.1",
"phpunit/phpunit": "^6.5.2",
"helmich/mongomock": "^2.5",
"phpunit/phpunit": "^9.0",
"squizlabs/php_codesniffer": "^3.2",
"subjective-php/psr-cache-mongodb": "^2.1"
"subjective-php/psr-cache-mongodb": "^3.0"
},
"autoload": {
"psr-4": { "TraderInteractive\\Api\\": "src" }
Expand Down
4 changes: 2 additions & 2 deletions tests/CacheFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@ public function provideMakeData() : array
/**
* @test
* @covers ::make
* @expectedException \RuntimeException
* @expectedExceptionMessage Cannot create cache instance of 'Invalid'
*/
public function cannotMakeUnsupportedCacheInstance()
{
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage("Cannot create cache instance of 'Invalid'");
CacheFactory::make('Invalid', []);
}
}
8 changes: 4 additions & 4 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@ function (RequestInterface $request) use (&$tokenCount) {
* @test
* @group unit
* @covers ::end
* @expectedException Exception
* @expectedExceptionMessage Invalid Credentials
*/
public function exceptionIsThrownOnBadCredentials()
{
$this->expectException(\Exception::class);
$this->expectExceptionMessage('Invalid Credentials');
$tokenCount = 0;
$adapter = new FakeAdapter(
function (RequestInterface $request) use (&$tokenCount) {
Expand Down Expand Up @@ -355,10 +355,10 @@ function (RequestInterface $request) use (&$tokenCount) {
* @test
* @group unit
* @covers ::__construct
* @expectedException \Exception
*/
public function throwsWithHttpCodeNot200()
{
$this->expectException(\Exception::class);
$adapter = new FakeAdapter(
function (RequestInterface $request) {
return new Psr7Response(
Expand Down Expand Up @@ -753,10 +753,10 @@ function (RequestInterface $request) {
* @test
* @group unit
* @dataProvider constructorBadData
* @expectedException \InvalidArgumentException
*/
public function constructWithInvalidParameters($adapter, $authentication, $apiBaseUrl, $cacheMode, $cache)
{
$this->expectException(\InvalidArgumentException::class);
$client = new Client($adapter, $authentication, $apiBaseUrl, $cacheMode, $cache);
}

Expand Down
17 changes: 15 additions & 2 deletions tests/CollectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function directUsage()
* Verifies code does not explode when rewind() consectutively
*
* @test
* @covers ::rewind
* @group edgecase
*/
public function consecutiveRewind()
Expand All @@ -68,6 +69,7 @@ public function consecutiveRewind()
* Verifies code does not explode when current() consectutively
*
* @test
* @covers ::current
* @group edgecase
*/
public function consecutiveCurrent()
Expand All @@ -81,6 +83,7 @@ public function consecutiveCurrent()
* Verifies code does not explode when next() consectutively
*
* @test
* @covers ::next
* @group edgecase
*/
public function consecutiveNext()
Expand Down Expand Up @@ -133,10 +136,11 @@ public function current()
* Verfies current() throws when collection is empty
*
* @test
* @expectedException \OutOfBoundsException
* @covers ::current
*/
public function currentWithEmpty()
{
$this->expectException(\OutOfBoundsException::class);
$collection = new Collection($this->getClient([]), 'empty');
$collection->current();
}
Expand All @@ -145,16 +149,20 @@ public function currentWithEmpty()
* Verfies key() throws when collection is empty
*
* @test
* @expectedException \OutOfBoundsException
* @covers ::key
*/
public function keyWithEmpty()
{
$this->expectException(\OutOfBoundsException::class);
$collection = new Collection($this->getClient([]), 'empty');
$collection->key();
}

/**
* @test
* @covers ::key
* @covers ::current
* @covers ::next
*/
public function multiIteration()
{
Expand All @@ -181,6 +189,8 @@ public function multiIteration()
* Verify Collection can handle an empty response
*
* @test
* @covers ::valid
* @covers ::count
*/
public function emptyResult()
{
Expand All @@ -193,6 +203,9 @@ public function emptyResult()
* Verify Collection can handle a response with a single item
*
* @test
* @covers ::key
* @covers ::current
* @covers ::next
*/
public function oneItemCollection()
{
Expand Down
8 changes: 4 additions & 4 deletions tests/GuzzleAdapterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ final class GuzzleAdapterTest extends TestCase
* @covers ::__construct
* @covers ::start
* @covers ::end
* @expectedException \Exception
*/
public function requestThrowsOnUnsupporetedMethod()
{
$this->expectException(\Exception::class);
$adapter = new GuzzleAdapter();
$request = new Request('SILLY', 'a resource', [], null);
$adapter->end($adapter->start($request));
Expand Down Expand Up @@ -85,11 +85,11 @@ public function badProtocolInOneUrl()
* @test
* @covers ::__construct
* @covers ::end
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage $endHandle not found
*/
public function badHandle()
{
$this->expectException(\InvalidArgumentException::class);
$this->expectExceptionMessage('$endHandle not found');
(new GuzzleAdapter())->end(0);
}

Expand All @@ -110,7 +110,7 @@ public function getHeaders()
);

foreach ($response->getHeaders() as $header) {
$this->assertInternalType('array', $header);
$this->assertIsArray($header);
}
}
}
4 changes: 2 additions & 2 deletions tests/ResponseSerializerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ public function provideValidSerializationData() : array
/**
* @test
* @covers ::serialize
* @expectedException \TraderInteractive\Api\SerializerException
* @expectedExceptionMessage Cannot serialize value of type 'array'
*/
public function serializeAcceptsOnlyResponses()
{
$this->expectException(\TraderInteractive\Api\SerializerException::class);
$this->expectExceptionMessage("Cannot serialize value of type 'array'");
$serializer = new ResponseSerializer();
$serializer->serialize(['foo']);
}
Expand Down
4 changes: 2 additions & 2 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public function getResponseHeaders()
/**
* @test
* @covers ::__construct
* @expectedException \InvalidArgumentException
*/
public function constructWithInvalidHttpCode()
{
$this->expectException(\InvalidArgumentException::class);
new Response(99, [], []);
}

Expand Down Expand Up @@ -100,12 +100,12 @@ public function fromPsr7ResponseEmptyBody()
/**
* @test
* @covers ::fromPsr7Response
* @expectedException \UnexpectedValueException
*
* @return void
*/
public function fromPsr7ResponseWithInvalidJson()
{
$this->expectException(\UnexpectedValueException::class);
Response::fromPsr7Response(
new Psr7\Response(200, ['Content-Type' => 'application/json'], '{"foo":"bar"')
);
Expand Down
2 changes: 1 addition & 1 deletion tests/provisioning/set-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ done
exec 6>&-
exec 6<&-

$@
"$@"

0 comments on commit 5a0e236

Please sign in to comment.