Skip to content

Test on PHP 8 #39

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

Merged
merged 8 commits into from
Dec 3, 2021
Merged
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: 3 additions & 3 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
php:
- "7.3"
- "7.4"

steps:
- name: "Checkout"
Expand All @@ -27,7 +27,7 @@ jobs:
with:
coverage: "none"
php-version: "${{ matrix.php }}"
tools: cs2pr, composer:v1
tools: composer:v2
ini-values: "date.timezone=Europe/Paris"
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -36,4 +36,4 @@ jobs:
uses: "ramsey/composer-install@v1"

- name: "Run PHP CS Fixer"
run: "vendor/bin/php-cs-fixer fix --verbose --dry-run --format=checkstyle | cs2pr"
run: "vendor/bin/php-cs-fixer fix --verbose --dry-run"
23 changes: 15 additions & 8 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ jobs:
- "7.2"
- "7.3"
- "7.4"
- "8.0"
- "8.1"

steps:
- name: "Checkout"
Expand All @@ -37,7 +39,7 @@ jobs:
with:
php-version: "${{ matrix.php }}"
coverage: "none"
tools: composer:v1
tools: composer:v2
extensions: curl
ini-values: "date.timezone=Europe/Paris"
env:
Expand Down Expand Up @@ -69,7 +71,7 @@ jobs:
with:
php-version: "${{ matrix.php }}"
coverage: "pcov"
tools: composer:v1
tools: composer:v2
extensions: curl
ini-values: "date.timezone=Europe/Paris"
env:
Expand All @@ -78,14 +80,19 @@ jobs:
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v1"

- name: "Setup logs"
run: "mkdir -p build/logs"

- name: "Run PHPUnit (with coverage)"
run: "php vendor/bin/simple-phpunit -v --coverage-clover=coverage.clover"
run: "php vendor/bin/simple-phpunit -v --coverage-clover build/logs/clover.xml"

- name: "Retrieve ocular.phar"
run: "wget https://scrutinizer-ci.com/ocular.phar"
- name: "Retrieve Coveralls phar"
run: "wget https://github.com/php-coveralls/php-coveralls/releases/download/v2.4.2/php-coveralls.phar"

- name: "Enable ocular.phar"
run: "chmod +x ocular.phar"
- name: "Enable Coveralls phar"
run: "chmod +x php-coveralls.phar"

- name: "Upload coverage"
run: "php ocular.phar code-coverage:upload --format=php-clover coverage.clover"
run: "php php-coveralls.phar -v -x build/logs/clover.xml"
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ vendor
coverage
build
.php_cs.cache
.php-cs-fixer.cache
.phpunit.result.cache
2 changes: 0 additions & 2 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
tools:
external_code_coverage:
timeout: 1200
php_code_sniffer:
config:
standard: "PSR2"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# PHP Imgur API Client

![CI](https://github.com/j0k3r/php-imgur-api-client/workflows/CI/badge.svg)
[![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)
[![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)
[![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)
[![Total Downloads](https://poser.pugx.org/j0k3r/php-imgur-api-client/downloads)](https://packagist.org/packages/j0k3r/php-imgur-api-client)
[![License](https://poser.pugx.org/j0k3r/php-imgur-api-client/license)](https://packagist.org/packages/j0k3r/php-imgur-api-client)
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.0",
"symfony/phpunit-bridge": "^5.0"
},
"config": {
"sort-packages": true
}
}
5 changes: 5 additions & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@
</testsuite>
</testsuites>

<php>
<!-- until all deps are compatible with PHP 8.1 -->
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak" />
</php>

<filter>
<whitelist>
<directory>./lib/</directory>
Expand Down
29 changes: 13 additions & 16 deletions tests/Api/AccountTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
use GuzzleHttp\Psr7\Response;
use Imgur\Api\Account;
use Imgur\Client;
use Imgur\Exception\InvalidArgumentException;
use Imgur\HttpClient\HttpClient;

class AccountTest extends ApiTestCase
{
/**
* @expectedException \Imgur\Exception\ErrorException
* @expectedExceptionMessage Authentication required
*/
public function testBaseReal()
{
$this->expectException(\Imgur\Exception\ErrorException::class);
$this->expectExceptionMessage('Authentication required');

$guzzleClient = new GuzzleClient(['base_uri' => 'https://api.imgur.com/3/']);
$httpClient = new HttpClient([], $guzzleClient);
$client = new Client(null, $httpClient);
Expand Down Expand Up @@ -116,12 +116,11 @@ public function testGalleryFavorites()
$this->assertSame($expectedValue, $api->galleryFavorites());
}

/**
* @expectedException \Imgur\Exception\InvalidArgumentException
* @expectedExceptionMessage is wrong. Possible values are
*/
public function testGalleryFavoritesWrongValues()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('is wrong. Possible values are');

$this->getApiMock()->galleryFavorites('me', 0, 'bad sort');
}

Expand Down Expand Up @@ -409,12 +408,11 @@ public function testComments()
$this->assertSame($expectedValue, $api->comments());
}

/**
* @expectedException \Imgur\Exception\InvalidArgumentException
* @expectedExceptionMessage is wrong. Possible values are
*/
public function testCommentsWrongValues()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('is wrong. Possible values are');

$this->getApiMock()->comments('me', 0, 'bad sort');
}

Expand Down Expand Up @@ -460,12 +458,11 @@ public function testCommentIds()
$this->assertSame($expectedValue, $api->commentIds());
}

/**
* @expectedException \Imgur\Exception\InvalidArgumentException
* @expectedExceptionMessage is wrong. Possible values are
*/
public function testCommentIdsWrongValues()
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('is wrong. Possible values are');

$this->getApiMock()->commentIds('me', 0, 'bad sort');
}

Expand Down
22 changes: 10 additions & 12 deletions tests/Api/AlbumOrImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use GuzzleHttp\Psr7\Response;
use Imgur\Api\AlbumOrImage;
use Imgur\Client;
use Imgur\Exception\ErrorException;
use Imgur\HttpClient\HttpClient;
use PHPUnit\Framework\TestCase;

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

/**
* @expectedException \Imgur\Exception\ErrorException
* @expectedExceptionMessage Unable to find an album OR an image with the id
*/
public function testWithBadId()
{
$this->expectException(ErrorException::class);
$this->expectExceptionMessage('id');

$mock = new MockHandler([
new Response(404, ['Content-Type' => 'application/json'], json_encode([
'data' => [
Expand Down Expand Up @@ -91,12 +91,11 @@ public function testWithBadId()
$api->find('xxxxxxx');
}

/**
* @expectedException \Imgur\Exception\ErrorException
* @expectedExceptionMessage oops
*/
public function testWithImageIdButBadResponse()
{
$this->expectException(ErrorException::class);
$this->expectExceptionMessage('oops');

$mock = new MockHandler([
new Response(500, ['Content-Type' => 'application/json'], json_encode([
'data' => [
Expand All @@ -119,12 +118,11 @@ public function testWithImageIdButBadResponse()
$api->find('ZOY11VC');
}

/**
* @expectedException \Imgur\Exception\ErrorException
* @expectedExceptionMessage oops
*/
public function testWithAlbumIdButBadResponse()
{
$this->expectException(ErrorException::class);
$this->expectExceptionMessage('oops');

$mock = new MockHandler([
new Response(404, ['Content-Type' => 'application/json'], json_encode([
'data' => [
Expand Down
7 changes: 3 additions & 4 deletions tests/Api/AlbumTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

class AlbumTest extends ApiTestCase
{
/**
* @expectedException \Imgur\Exception\ErrorException
* @expectedExceptionMessage Authentication required
*/
public function testBaseReal()
{
$this->expectException(\Imgur\Exception\ErrorException::class);
$this->expectExceptionMessage('Authentication required');

$guzzleClient = new GuzzleClient(['base_uri' => 'https://api.imgur.com/3/']);
$httpClient = new HttpClient([], $guzzleClient);
$client = new Client(null, $httpClient);
Expand Down
28 changes: 12 additions & 16 deletions tests/Api/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

class CommentTest extends ApiTestCase
{
/**
* @expectedException \Imgur\Exception\ErrorException
* @expectedExceptionMessage Authentication required
*/
public function testBaseReal()
{
$this->expectException(\Imgur\Exception\ErrorException::class);
$this->expectExceptionMessage('Authentication required');

$guzzleClient = new GuzzleClient(['base_uri' => 'https://api.imgur.com/3/']);
$httpClient = new HttpClient([], $guzzleClient);
$client = new Client(null, $httpClient);
Expand Down Expand Up @@ -115,12 +114,11 @@ public function testCreate()
$this->assertSame($expectedValue, $api->create(['image_id' => 'ZOY11VC', 'comment' => 'I agree']));
}

/**
* @expectedException \Imgur\Exception\MissingArgumentException
* @expectedExceptionMessage parameters is missing
*/
public function testCreateParamMissing()
{
$this->expectException(\Imgur\Exception\MissingArgumentException::class);
$this->expectExceptionMessage('parameters is missing');

$this->getApiMock()->create('726305564');
}

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

/**
* @expectedException \Imgur\Exception\MissingArgumentException
* @expectedExceptionMessage parameters is missing
*/
public function testCreateReplyParamMissing()
{
$this->expectException(\Imgur\Exception\MissingArgumentException::class);
$this->expectExceptionMessage('parameters is missing');

$this->getApiMock()->createReply('726305564', []);
}

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

/**
* @expectedException \Imgur\Exception\InvalidArgumentException
* @expectedExceptionMessage is wrong. Possible values are
*/
public function testVoteWrongVoteValue()
{
$this->expectException(\Imgur\Exception\InvalidArgumentException::class);
$this->expectExceptionMessage('is wrong. Possible values are');

$this->getApiMock()->vote('726305564', 'bad vote');
}

Expand Down
14 changes: 6 additions & 8 deletions tests/Api/ConversationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@

class ConversationTest extends ApiTestCase
{
/**
* @expectedException \Imgur\Exception\ErrorException
* @expectedExceptionMessage Authentication required
*/
public function testBaseReal()
{
$this->expectException(\Imgur\Exception\ErrorException::class);
$this->expectExceptionMessage('Authentication required');

$guzzleClient = new GuzzleClient(['base_uri' => 'https://api.imgur.com/3/']);
$httpClient = new HttpClient([], $guzzleClient);
$client = new Client(null, $httpClient);
Expand Down Expand Up @@ -118,12 +117,11 @@ public function testMessageCreate()
$this->assertSame($expectedValue, $api->messageCreate(['recipient' => 'imgur', 'body' => 'YO !']));
}

/**
* @expectedException \Imgur\Exception\MissingArgumentException
* @expectedExceptionMessage parameters is missing
*/
public function testMessageCreateParamMissing()
{
$this->expectException(\Imgur\Exception\MissingArgumentException::class);
$this->expectExceptionMessage('parameters is missing');

$this->getApiMock()->messageCreate([]);
}

Expand Down
Loading