Skip to content

Commit 52ebcfc

Browse files
authored
Merge pull request #39 from j0k3r/php-8
Test on PHP 8
2 parents 282e54f + 3801c0f commit 52ebcfc

22 files changed

+248
-272
lines changed

Diff for: .github/workflows/coding-standards.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
strategy:
1717
matrix:
1818
php:
19-
- "7.3"
19+
- "7.4"
2020

2121
steps:
2222
- name: "Checkout"
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
coverage: "none"
2929
php-version: "${{ matrix.php }}"
30-
tools: cs2pr, composer:v1
30+
tools: composer:v2
3131
ini-values: "date.timezone=Europe/Paris"
3232
env:
3333
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -36,4 +36,4 @@ jobs:
3636
uses: "ramsey/composer-install@v1"
3737

3838
- name: "Run PHP CS Fixer"
39-
run: "vendor/bin/php-cs-fixer fix --verbose --dry-run --format=checkstyle | cs2pr"
39+
run: "vendor/bin/php-cs-fixer fix --verbose --dry-run"

Diff for: .github/workflows/continuous-integration.yml

+15-8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ jobs:
2525
- "7.2"
2626
- "7.3"
2727
- "7.4"
28+
- "8.0"
29+
- "8.1"
2830

2931
steps:
3032
- name: "Checkout"
@@ -37,7 +39,7 @@ jobs:
3739
with:
3840
php-version: "${{ matrix.php }}"
3941
coverage: "none"
40-
tools: composer:v1
42+
tools: composer:v2
4143
extensions: curl
4244
ini-values: "date.timezone=Europe/Paris"
4345
env:
@@ -69,7 +71,7 @@ jobs:
6971
with:
7072
php-version: "${{ matrix.php }}"
7173
coverage: "pcov"
72-
tools: composer:v1
74+
tools: composer:v2
7375
extensions: curl
7476
ini-values: "date.timezone=Europe/Paris"
7577
env:
@@ -78,14 +80,19 @@ jobs:
7880
- name: "Install dependencies with Composer"
7981
uses: "ramsey/composer-install@v1"
8082

83+
- name: "Setup logs"
84+
run: "mkdir -p build/logs"
85+
8186
- name: "Run PHPUnit (with coverage)"
82-
run: "php vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover"
87+
run: "php vendor/bin/simple-phpunit -v --coverage-clover build/logs/clover.xml"
8388

84-
- name: "Retrieve ocular.phar"
85-
run: "wget https://scrutinizer-ci.com/ocular.phar"
89+
- name: "Retrieve Coveralls phar"
90+
run: "wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.2/php-coveralls.phar"
8691

87-
- name: "Enable ocular.phar"
88-
run: "chmod +x ocular.phar"
92+
- name: "Enable Coveralls phar"
93+
run: "chmod +x php-coveralls.phar"
8994

9095
- name: "Upload coverage"
91-
run: "php ocular.phar code-coverage:upload --format=php-clover coverage.clover"
96+
run: "php php-coveralls.phar -v -x build/logs/clover.xml"
97+
env:
98+
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ vendor
44
coverage
55
build
66
.php_cs.cache
7+
.php-cs-fixer.cache
78
.phpunit.result.cache

Diff for: .scrutinizer.yml

-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
tools:
2-
external_code_coverage:
3-
timeout: 1200
42
php_code_sniffer:
53
config:
64
standard: "PSR2"

Diff for: README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# PHP Imgur API Client
22

33
![CI](https://github.com/j0k3r/php-imgur-api-client/workflows/CI/badge.svg)
4-
[![Code Coverage](https://scrutinizer-ci.com/g/j0k3r/php-imgur-api-client/badges/coverage.png?branch=master)](https://scrutinizer-ci.com/g/j0k3r/php-imgur-api-client/?branch=master)
4+
[![Coverage Status](https://coveralls.io/repos/j0k3r/php-imgur-api-client/badge.svg?branch=master&service=github)](https://coveralls.io/github/j0k3r/php-imgur-api-client?branch=master)
55
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/j0k3r/php-imgur-api-client/badges/quality-score.png?branch=master)](https://scrutinizer-ci.com/g/j0k3r/php-imgur-api-client/?branch=master)
66
[![Total Downloads](https://poser.pugx.org/j0k3r/php-imgur-api-client/downloads)](https://packagist.org/packages/j0k3r/php-imgur-api-client)
77
[![License](https://poser.pugx.org/j0k3r/php-imgur-api-client/license)](https://packagist.org/packages/j0k3r/php-imgur-api-client)

Diff for: composer.json

+3
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,8 @@
4141
"require-dev": {
4242
"friendsofphp/php-cs-fixer": "^2.0",
4343
"symfony/phpunit-bridge": "^5.0"
44+
},
45+
"config": {
46+
"sort-packages": true
4447
}
4548
}

Diff for: phpunit.xml.dist

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
</testsuite>
1717
</testsuites>
1818

19+
<php>
20+
<!-- until all deps are compatible with PHP 8.1 -->
21+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
22+
</php>
23+
1924
<filter>
2025
<whitelist>
2126
<directory>./lib/</directory>

Diff for: tests/Api/AccountTest.php

+13-16
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@
88
use GuzzleHttp\Psr7\Response;
99
use Imgur\Api\Account;
1010
use Imgur\Client;
11+
use Imgur\Exception\InvalidArgumentException;
1112
use Imgur\HttpClient\HttpClient;
1213

1314
class AccountTest extends ApiTestCase
1415
{
15-
/**
16-
* @expectedException \Imgur\Exception\ErrorException
17-
* @expectedExceptionMessage Authentication required
18-
*/
1916
public function testBaseReal()
2017
{
18+
$this->expectException(\Imgur\Exception\ErrorException::class);
19+
$this->expectExceptionMessage('Authentication required');
20+
2121
$guzzleClient = new GuzzleClient(['base_uri' => 'https://api.imgur.com/3/']);
2222
$httpClient = new HttpClient([], $guzzleClient);
2323
$client = new Client(null, $httpClient);
@@ -116,12 +116,11 @@ public function testGalleryFavorites()
116116
$this->assertSame($expectedValue, $api->galleryFavorites());
117117
}
118118

119-
/**
120-
* @expectedException \Imgur\Exception\InvalidArgumentException
121-
* @expectedExceptionMessage is wrong. Possible values are
122-
*/
123119
public function testGalleryFavoritesWrongValues()
124120
{
121+
$this->expectException(InvalidArgumentException::class);
122+
$this->expectExceptionMessage('is wrong. Possible values are');
123+
125124
$this->getApiMock()->galleryFavorites('me', 0, 'bad sort');
126125
}
127126

@@ -409,12 +408,11 @@ public function testComments()
409408
$this->assertSame($expectedValue, $api->comments());
410409
}
411410

412-
/**
413-
* @expectedException \Imgur\Exception\InvalidArgumentException
414-
* @expectedExceptionMessage is wrong. Possible values are
415-
*/
416411
public function testCommentsWrongValues()
417412
{
413+
$this->expectException(InvalidArgumentException::class);
414+
$this->expectExceptionMessage('is wrong. Possible values are');
415+
418416
$this->getApiMock()->comments('me', 0, 'bad sort');
419417
}
420418

@@ -460,12 +458,11 @@ public function testCommentIds()
460458
$this->assertSame($expectedValue, $api->commentIds());
461459
}
462460

463-
/**
464-
* @expectedException \Imgur\Exception\InvalidArgumentException
465-
* @expectedExceptionMessage is wrong. Possible values are
466-
*/
467461
public function testCommentIdsWrongValues()
468462
{
463+
$this->expectException(InvalidArgumentException::class);
464+
$this->expectExceptionMessage('is wrong. Possible values are');
465+
469466
$this->getApiMock()->commentIds('me', 0, 'bad sort');
470467
}
471468

Diff for: tests/Api/AlbumOrImageTest.php

+10-12
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use GuzzleHttp\Psr7\Response;
99
use Imgur\Api\AlbumOrImage;
1010
use Imgur\Client;
11+
use Imgur\Exception\ErrorException;
1112
use Imgur\HttpClient\HttpClient;
1213
use PHPUnit\Framework\TestCase;
1314

@@ -54,12 +55,11 @@ public function testWithAlbumId()
5455
$this->assertSame('ok !', $api->find('8pCqe'));
5556
}
5657

57-
/**
58-
* @expectedException \Imgur\Exception\ErrorException
59-
* @expectedExceptionMessage Unable to find an album OR an image with the id
60-
*/
6158
public function testWithBadId()
6259
{
60+
$this->expectException(ErrorException::class);
61+
$this->expectExceptionMessage('id');
62+
6363
$mock = new MockHandler([
6464
new Response(404, ['Content-Type' => 'application/json'], json_encode([
6565
'data' => [
@@ -91,12 +91,11 @@ public function testWithBadId()
9191
$api->find('xxxxxxx');
9292
}
9393

94-
/**
95-
* @expectedException \Imgur\Exception\ErrorException
96-
* @expectedExceptionMessage oops
97-
*/
9894
public function testWithImageIdButBadResponse()
9995
{
96+
$this->expectException(ErrorException::class);
97+
$this->expectExceptionMessage('oops');
98+
10099
$mock = new MockHandler([
101100
new Response(500, ['Content-Type' => 'application/json'], json_encode([
102101
'data' => [
@@ -119,12 +118,11 @@ public function testWithImageIdButBadResponse()
119118
$api->find('ZOY11VC');
120119
}
121120

122-
/**
123-
* @expectedException \Imgur\Exception\ErrorException
124-
* @expectedExceptionMessage oops
125-
*/
126121
public function testWithAlbumIdButBadResponse()
127122
{
123+
$this->expectException(ErrorException::class);
124+
$this->expectExceptionMessage('oops');
125+
128126
$mock = new MockHandler([
129127
new Response(404, ['Content-Type' => 'application/json'], json_encode([
130128
'data' => [

Diff for: tests/Api/AlbumTest.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212

1313
class AlbumTest extends ApiTestCase
1414
{
15-
/**
16-
* @expectedException \Imgur\Exception\ErrorException
17-
* @expectedExceptionMessage Authentication required
18-
*/
1915
public function testBaseReal()
2016
{
17+
$this->expectException(\Imgur\Exception\ErrorException::class);
18+
$this->expectExceptionMessage('Authentication required');
19+
2120
$guzzleClient = new GuzzleClient(['base_uri' => 'https://api.imgur.com/3/']);
2221
$httpClient = new HttpClient([], $guzzleClient);
2322
$client = new Client(null, $httpClient);

Diff for: tests/Api/CommentTest.php

+12-16
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212

1313
class CommentTest extends ApiTestCase
1414
{
15-
/**
16-
* @expectedException \Imgur\Exception\ErrorException
17-
* @expectedExceptionMessage Authentication required
18-
*/
1915
public function testBaseReal()
2016
{
17+
$this->expectException(\Imgur\Exception\ErrorException::class);
18+
$this->expectExceptionMessage('Authentication required');
19+
2120
$guzzleClient = new GuzzleClient(['base_uri' => 'https://api.imgur.com/3/']);
2221
$httpClient = new HttpClient([], $guzzleClient);
2322
$client = new Client(null, $httpClient);
@@ -115,12 +114,11 @@ public function testCreate()
115114
$this->assertSame($expectedValue, $api->create(['image_id' => 'ZOY11VC', 'comment' => 'I agree']));
116115
}
117116

118-
/**
119-
* @expectedException \Imgur\Exception\MissingArgumentException
120-
* @expectedExceptionMessage parameters is missing
121-
*/
122117
public function testCreateParamMissing()
123118
{
119+
$this->expectException(\Imgur\Exception\MissingArgumentException::class);
120+
$this->expectExceptionMessage('parameters is missing');
121+
124122
$this->getApiMock()->create('726305564');
125123
}
126124

@@ -177,12 +175,11 @@ public function testCreateReply()
177175
$this->assertSame($expectedValue, $api->createReply('726305565', ['image_id' => 'ZOY11VC', 'comment' => 'I agree']));
178176
}
179177

180-
/**
181-
* @expectedException \Imgur\Exception\MissingArgumentException
182-
* @expectedExceptionMessage parameters is missing
183-
*/
184178
public function testCreateReplyParamMissing()
185179
{
180+
$this->expectException(\Imgur\Exception\MissingArgumentException::class);
181+
$this->expectExceptionMessage('parameters is missing');
182+
186183
$this->getApiMock()->createReply('726305564', []);
187184
}
188185

@@ -203,12 +200,11 @@ public function testVote()
203200
$this->assertSame($expectedValue, $api->vote('726305564', 'up'));
204201
}
205202

206-
/**
207-
* @expectedException \Imgur\Exception\InvalidArgumentException
208-
* @expectedExceptionMessage is wrong. Possible values are
209-
*/
210203
public function testVoteWrongVoteValue()
211204
{
205+
$this->expectException(\Imgur\Exception\InvalidArgumentException::class);
206+
$this->expectExceptionMessage('is wrong. Possible values are');
207+
212208
$this->getApiMock()->vote('726305564', 'bad vote');
213209
}
214210

Diff for: tests/Api/ConversationTest.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212

1313
class ConversationTest extends ApiTestCase
1414
{
15-
/**
16-
* @expectedException \Imgur\Exception\ErrorException
17-
* @expectedExceptionMessage Authentication required
18-
*/
1915
public function testBaseReal()
2016
{
17+
$this->expectException(\Imgur\Exception\ErrorException::class);
18+
$this->expectExceptionMessage('Authentication required');
19+
2120
$guzzleClient = new GuzzleClient(['base_uri' => 'https://api.imgur.com/3/']);
2221
$httpClient = new HttpClient([], $guzzleClient);
2322
$client = new Client(null, $httpClient);
@@ -118,12 +117,11 @@ public function testMessageCreate()
118117
$this->assertSame($expectedValue, $api->messageCreate(['recipient' => 'imgur', 'body' => 'YO !']));
119118
}
120119

121-
/**
122-
* @expectedException \Imgur\Exception\MissingArgumentException
123-
* @expectedExceptionMessage parameters is missing
124-
*/
125120
public function testMessageCreateParamMissing()
126121
{
122+
$this->expectException(\Imgur\Exception\MissingArgumentException::class);
123+
$this->expectExceptionMessage('parameters is missing');
124+
127125
$this->getApiMock()->messageCreate([]);
128126
}
129127

0 commit comments

Comments
 (0)