Skip to content

Commit 614e687

Browse files
committed
Add support for PHP 8.
Backwards Breaking; Remove support for PHP 7.2 and earlier.
1 parent 2b27091 commit 614e687

10 files changed

Lines changed: 41 additions & 25 deletions

.github/workflows/php.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
runs-on: ubuntu-18.04
1212
strategy:
1313
matrix:
14-
php-versions: ['7.0', '7.1', '7.2', '7.3', '7.4']
14+
php-versions: ['7.3', '7.4', '8.0', '8.1']
1515
steps:
1616
- name: Checkout
1717
uses: actions/checkout@v2

.scrutinizer.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ filter:
55
before_commands:
66
- 'composer install'
77
build:
8+
environment:
9+
php:
10+
pecl_extensions:
11+
- mongodb
812
nodes:
913
analysis:
1014
tests:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ This is a PHP client for [REST](http://en.wikipedia.org/wiki/Representational_st
1515

1616
## Requirements
1717

18-
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.
18+
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.
1919

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

composer.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
],
2222
"license": "MIT",
2323
"require": {
24-
"php": "^7.0",
24+
"php": "^7.3 || ^8.0",
2525
"ext-curl": "*",
2626
"ext-json": "*",
2727
"lib-curl": "~7.15",
2828
"fig/http-message-util": "^1.1",
2929
"guzzlehttp/guzzle": "^6.3",
3030
"psr/http-message": "^1.0",
3131
"psr/simple-cache": "^1.0",
32-
"subjective-php/psr-cache-helper": "^1.1",
33-
"traderinteractive/util": "^3.0"
32+
"subjective-php/psr-cache-helper": "^2.0",
33+
"traderinteractive/util": "^4.0"
3434
},
3535
"config": {
3636
"sort-packages": true
@@ -39,11 +39,10 @@
3939
"subjective-php/psr-cache-mongodb": "Used for Caching with Mongo"
4040
},
4141
"require-dev": {
42-
"helmich/mongomock": "^2.1",
43-
"php-coveralls/php-coveralls": "^2.1",
44-
"phpunit/phpunit": "^6.5.2",
42+
"helmich/mongomock": "^2.5",
43+
"phpunit/phpunit": "^9.0",
4544
"squizlabs/php_codesniffer": "^3.2",
46-
"subjective-php/psr-cache-mongodb": "^2.1"
45+
"subjective-php/psr-cache-mongodb": "^3.0"
4746
},
4847
"autoload": {
4948
"psr-4": { "TraderInteractive\\Api\\": "src" }

tests/CacheFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public function provideMakeData() : array
6464
/**
6565
* @test
6666
* @covers ::make
67-
* @expectedException \RuntimeException
68-
* @expectedExceptionMessage Cannot create cache instance of 'Invalid'
6967
*/
7068
public function cannotMakeUnsupportedCacheInstance()
7169
{
70+
$this->expectException(\RuntimeException::class);
71+
$this->expectExceptionMessage("Cannot create cache instance of 'Invalid'");
7272
CacheFactory::make('Invalid', []);
7373
}
7474
}

tests/ClientTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ function (RequestInterface $request) use (&$tokenCount) {
8181
* @test
8282
* @group unit
8383
* @covers ::end
84-
* @expectedException Exception
85-
* @expectedExceptionMessage Invalid Credentials
8684
*/
8785
public function exceptionIsThrownOnBadCredentials()
8886
{
87+
$this->expectException(\Exception::class);
88+
$this->expectExceptionMessage('Invalid Credentials');
8989
$tokenCount = 0;
9090
$adapter = new FakeAdapter(
9191
function (RequestInterface $request) use (&$tokenCount) {
@@ -355,10 +355,10 @@ function (RequestInterface $request) use (&$tokenCount) {
355355
* @test
356356
* @group unit
357357
* @covers ::__construct
358-
* @expectedException \Exception
359358
*/
360359
public function throwsWithHttpCodeNot200()
361360
{
361+
$this->expectException(\Exception::class);
362362
$adapter = new FakeAdapter(
363363
function (RequestInterface $request) {
364364
return new Psr7Response(
@@ -753,10 +753,10 @@ function (RequestInterface $request) {
753753
* @test
754754
* @group unit
755755
* @dataProvider constructorBadData
756-
* @expectedException \InvalidArgumentException
757756
*/
758757
public function constructWithInvalidParameters($adapter, $authentication, $apiBaseUrl, $cacheMode, $cache)
759758
{
759+
$this->expectException(\InvalidArgumentException::class);
760760
$client = new Client($adapter, $authentication, $apiBaseUrl, $cacheMode, $cache);
761761
}
762762

tests/CollectionTest.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ public function directUsage()
4848
* Verifies code does not explode when rewind() consectutively
4949
*
5050
* @test
51+
* @covers ::rewind
5152
* @group edgecase
5253
*/
5354
public function consecutiveRewind()
@@ -68,6 +69,7 @@ public function consecutiveRewind()
6869
* Verifies code does not explode when current() consectutively
6970
*
7071
* @test
72+
* @covers ::current
7173
* @group edgecase
7274
*/
7375
public function consecutiveCurrent()
@@ -81,6 +83,7 @@ public function consecutiveCurrent()
8183
* Verifies code does not explode when next() consectutively
8284
*
8385
* @test
86+
* @covers ::next
8487
* @group edgecase
8588
*/
8689
public function consecutiveNext()
@@ -133,10 +136,11 @@ public function current()
133136
* Verfies current() throws when collection is empty
134137
*
135138
* @test
136-
* @expectedException \OutOfBoundsException
139+
* @covers ::current
137140
*/
138141
public function currentWithEmpty()
139142
{
143+
$this->expectException(\OutOfBoundsException::class);
140144
$collection = new Collection($this->getClient([]), 'empty');
141145
$collection->current();
142146
}
@@ -145,16 +149,20 @@ public function currentWithEmpty()
145149
* Verfies key() throws when collection is empty
146150
*
147151
* @test
148-
* @expectedException \OutOfBoundsException
152+
* @covers ::key
149153
*/
150154
public function keyWithEmpty()
151155
{
156+
$this->expectException(\OutOfBoundsException::class);
152157
$collection = new Collection($this->getClient([]), 'empty');
153158
$collection->key();
154159
}
155160

156161
/**
157162
* @test
163+
* @covers ::key
164+
* @covers ::current
165+
* @covers ::next
158166
*/
159167
public function multiIteration()
160168
{
@@ -181,6 +189,8 @@ public function multiIteration()
181189
* Verify Collection can handle an empty response
182190
*
183191
* @test
192+
* @covers ::valid
193+
* @covers ::count
184194
*/
185195
public function emptyResult()
186196
{
@@ -193,6 +203,9 @@ public function emptyResult()
193203
* Verify Collection can handle a response with a single item
194204
*
195205
* @test
206+
* @covers ::key
207+
* @covers ::current
208+
* @covers ::next
196209
*/
197210
public function oneItemCollection()
198211
{

tests/GuzzleAdapterTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ final class GuzzleAdapterTest extends TestCase
2020
* @covers ::__construct
2121
* @covers ::start
2222
* @covers ::end
23-
* @expectedException \Exception
2423
*/
2524
public function requestThrowsOnUnsupporetedMethod()
2625
{
26+
$this->expectException(\Exception::class);
2727
$adapter = new GuzzleAdapter();
2828
$request = new Request('SILLY', 'a resource', [], null);
2929
$adapter->end($adapter->start($request));
@@ -85,11 +85,11 @@ public function badProtocolInOneUrl()
8585
* @test
8686
* @covers ::__construct
8787
* @covers ::end
88-
* @expectedException \InvalidArgumentException
89-
* @expectedExceptionMessage $endHandle not found
9088
*/
9189
public function badHandle()
9290
{
91+
$this->expectException(\InvalidArgumentException::class);
92+
$this->expectExceptionMessage('$endHandle not found');
9393
(new GuzzleAdapter())->end(0);
9494
}
9595

@@ -110,7 +110,7 @@ public function getHeaders()
110110
);
111111

112112
foreach ($response->getHeaders() as $header) {
113-
$this->assertInternalType('array', $header);
113+
$this->assertIsArray($header);
114114
}
115115
}
116116
}

tests/ResponseSerializerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,11 @@ public function provideValidSerializationData() : array
8080
/**
8181
* @test
8282
* @covers ::serialize
83-
* @expectedException \TraderInteractive\Api\SerializerException
84-
* @expectedExceptionMessage Cannot serialize value of type 'array'
8583
*/
8684
public function serializeAcceptsOnlyResponses()
8785
{
86+
$this->expectException(\TraderInteractive\Api\SerializerException::class);
87+
$this->expectExceptionMessage("Cannot serialize value of type 'array'");
8888
$serializer = new ResponseSerializer();
8989
$serializer->serialize(['foo']);
9090
}

tests/ResponseTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ public function getResponseHeaders()
5656
/**
5757
* @test
5858
* @covers ::__construct
59-
* @expectedException \InvalidArgumentException
6059
*/
6160
public function constructWithInvalidHttpCode()
6261
{
62+
$this->expectException(\InvalidArgumentException::class);
6363
new Response(99, [], []);
6464
}
6565

@@ -100,12 +100,12 @@ public function fromPsr7ResponseEmptyBody()
100100
/**
101101
* @test
102102
* @covers ::fromPsr7Response
103-
* @expectedException \UnexpectedValueException
104103
*
105104
* @return void
106105
*/
107106
public function fromPsr7ResponseWithInvalidJson()
108107
{
108+
$this->expectException(\UnexpectedValueException::class);
109109
Response::fromPsr7Response(
110110
new Psr7\Response(200, ['Content-Type' => 'application/json'], '{"foo":"bar"')
111111
);

0 commit comments

Comments
 (0)