Skip to content

Commit fab0380

Browse files
authored
Merge pull request #51 from j0k3r/fix/ga
Fix GitHub Actions
2 parents a1f75bf + 75af9ed commit fab0380

File tree

8 files changed

+31
-14
lines changed

8 files changed

+31
-14
lines changed

.github/workflows/coding-standards.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ on:
1111
jobs:
1212
coding-standards:
1313
name: "CS Fixer (PHP ${{ matrix.php }})"
14-
runs-on: "ubuntu-20.04"
14+
runs-on: "ubuntu-latest"
1515

1616
strategy:
1717
matrix:
1818
php:
19-
- "7.4"
19+
- "8.2"
2020

2121
steps:
2222
- name: "Checkout"
23-
uses: "actions/checkout@v4"
23+
uses: "actions/checkout@v5"
2424

2525
- name: "Install PHP"
2626
uses: "shivammathur/setup-php@v2"

.github/workflows/continuous-integration.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ env:
1414
jobs:
1515
phpunit:
1616
name: "PHPUnit (PHP ${{ matrix.php }})"
17-
runs-on: "ubuntu-20.04"
17+
runs-on: "ubuntu-latest"
1818

1919
strategy:
2020
matrix:
@@ -26,7 +26,7 @@ jobs:
2626

2727
steps:
2828
- name: "Checkout"
29-
uses: "actions/checkout@v4"
29+
uses: "actions/checkout@v5"
3030
with:
3131
fetch-depth: 2
3232

@@ -49,7 +49,7 @@ jobs:
4949

5050
phpunit-coverage:
5151
name: "PHPUnit with coverage (PHP ${{ matrix.php }})"
52-
runs-on: "ubuntu-20.04"
52+
runs-on: "ubuntu-latest"
5353

5454
strategy:
5555
matrix:
@@ -58,7 +58,7 @@ jobs:
5858

5959
steps:
6060
- name: "Checkout"
61-
uses: "actions/checkout@v4"
61+
uses: "actions/checkout@v5"
6262
with:
6363
fetch-depth: 2
6464

lib/Imgur/Client.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public function setHttpClient(HttpClientInterface $httpClient): void
8888
public function getOption(string $name): ?string
8989
{
9090
if (!\array_key_exists($name, $this->options)) {
91-
throw new InvalidArgumentException(sprintf('Undefined option called: "%s"', $name));
91+
throw new InvalidArgumentException(\sprintf('Undefined option called: "%s"', $name));
9292
}
9393

9494
return $this->options[$name];
@@ -100,7 +100,7 @@ public function getOption(string $name): ?string
100100
public function setOption(string $name, ?string $value = null): void
101101
{
102102
if (!\array_key_exists($name, $this->options)) {
103-
throw new InvalidArgumentException(sprintf('Undefined option called: "%s"', $name));
103+
throw new InvalidArgumentException(\sprintf('Undefined option called: "%s"', $name));
104104
}
105105

106106
$this->options[$name] = $value;

lib/Imgur/Exception/MissingArgumentException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ public function __construct($required, int $code = 0)
1313
$required = [$required];
1414
}
1515

16-
parent::__construct(sprintf('One or more of required ("%s") parameters is missing!', implode('", "', $required)), $code);
16+
parent::__construct(\sprintf('One or more of required ("%s") parameters is missing!', implode('", "', $required)), $code);
1717
}
1818
}

lib/Imgur/Middleware/ErrorMiddleware.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,17 @@ public function checkError(ResponseInterface $response): ?ResponseInterface
8585
throw new ErrorException($message, $response->getStatusCode());
8686
}
8787

88+
if (\is_array($responseData) && isset($responseData['errors'])) {
89+
$errorMessage = $responseData['errors'];
90+
91+
$message = '';
92+
foreach ($responseData['errors'] as $error) {
93+
$message .= $error['detail'];
94+
}
95+
96+
throw new ErrorException($message, $response->getStatusCode());
97+
}
98+
8899
throw new RuntimeException(\is_array($responseData) && isset($responseData['message']) ? $responseData['message'] : $responseData, $response->getStatusCode());
89100
}
90101

phpstan.neon

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ parameters:
55
- tests
66

77
bootstrapFiles:
8-
- vendor/bin/.phpunit/phpunit-8.5-0/vendor/autoload.php
9-
10-
checkMissingIterableValueType: false
8+
- vendor/bin/.phpunit/phpunit-9.6-0/vendor/autoload.php
119

1210
ignoreErrors:
1311
# because the test is skipped
1412
-
1513
message: '#Unreachable statement#'
1614
path: %currentWorkingDirectory%/tests/Api/TopicTest.php
15+
-
16+
message: '#Unreachable statement#'
17+
path: %currentWorkingDirectory%/tests/Api/ImageTest.php
18+
19+
-
20+
identifier: missingType.iterableValue

tests/Api/AlbumTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class AlbumTest extends ApiTestCase
1515
public function testBaseReal(): void
1616
{
1717
$this->expectException(\Imgur\Exception\ErrorException::class);
18-
$this->expectExceptionMessage('Authentication required');
18+
$this->expectExceptionMessage('The requester is not authorized to access the resource.');
1919

2020
$httpClient = new HttpClient();
2121
$client = new Client(null, $httpClient);

tests/Api/ImageTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ public function testBaseReal(): void
1717
$this->expectException(\Imgur\Exception\ErrorException::class);
1818
$this->expectExceptionMessage('Authentication required');
1919

20+
$this->markTestSkipped('Image endpoint does not always return 401 with no authentication ...');
21+
2022
$httpClient = new HttpClient();
2123
$client = new Client(null, $httpClient);
2224
$image = new Image($client);

0 commit comments

Comments
 (0)