Skip to content

Commit 6a7570c

Browse files
authored
Upgraded code base to support PHP 8.0 & PHPUnit 9 (#47)
* Upgraded code base to support PHP ^8.0 and PHPUnit * Refactor to make test PHPUnit 9 compliant * Forced lusitanian/oauth dependency with a commit hash that's PHP 8 compliant * Allow PHP 7.4 tests and removed PHP 8.1 (due to Composer dependencies issues) * Prevent crash iv config.php file cannot be found while runnning tests * Added PHPUnit testsuite's name and updated current schema
1 parent 1a832b8 commit 6a7570c

File tree

9 files changed

+21
-19
lines changed

9 files changed

+21
-19
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
matrix:
1010
os: [ ubuntu-latest, macos-latest, windows-latest ]
1111
# All supported PHP versions https://www.php.net/supported-versions.php
12-
php: [ '7.2', '7.3', '7.4' ]
12+
php: [ '7.3', '7.4', '8.0' ]
1313

1414
runs-on: ${{matrix.os}}
1515

@@ -28,10 +28,10 @@ jobs:
2828
composer install
2929
3030
- name: Test
31+
run: |
32+
composer test
3133
env:
3234
FLICKR_API_KEY: ${{ secrets.FLICKR_API_KEY }}
3335
FLICKR_API_SECRET: ${{ secrets.FLICKR_API_SECRET }}
3436
FLICKR_ACCESS_TOKEN: ${{ secrets.FLICKR_ACCESS_TOKEN }}
3537
FLICKR_ACCESS_SECRET: ${{ secrets.FLICKR_ACCESS_SECRET }}
36-
run: |
37-
composer test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
/tests/config.php
88
/config.php
99
/cache/
10-
10+
.phpunit.result.cache

composer.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,20 @@
1414
}
1515
},
1616
"require": {
17-
"php": ">=5.6",
17+
"php": "^7.3 || ^8.0",
1818
"ext-curl": "*",
1919
"ext-json": "*",
2020
"ext-libxml": "*",
2121
"ext-simplexml": "*",
22-
"lusitanian/oauth": "^0.8",
22+
"lusitanian/oauth": "dev-master#ee5a83310c6014b6cc07ac0610ec9d67ba452664 as 0.8.12",
2323
"psr/cache": "^1.0"
2424
},
2525
"require-dev": {
26-
"jakub-onderka/php-parallel-lint": "1.0.0",
2726
"squizlabs/php_codesniffer": "^3.0",
2827
"mediawiki/minus-x": "^0.3",
29-
"phpunit/phpunit": "^5.0",
30-
"tedivm/stash": "^0.14"
28+
"phpunit/phpunit": "^9.5",
29+
"tedivm/stash": "^0.17.1",
30+
"php-parallel-lint/php-parallel-lint": "^1.3"
3131
},
3232
"scripts": {
3333
"test": [

phpunit.xml.dist

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.8/phpunit.xsd"
2+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
33
colors="true"
44
bootstrap="vendor/autoload.php">
55

66
<testsuites>
7-
<testsuite>
7+
<testsuite name="Library's tests">
88
<directory>tests</directory>
99
</testsuite>
1010
</testsuites>

src/PhotosetsApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function addPhoto($photosetId, $photoId)
3535
* @param string $description A description of the photoset. May contain limited HTML.
3636
* @param int $primaryPhotoId The ID of the photo to represent this set. The photo must belong
3737
* to the calling user.
38-
* @return bool
38+
* @return bool|mixed[]
3939
*/
4040
public function create($title, $description, $primaryPhotoId)
4141
{

src/TestApi.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class TestApi extends ApiMethodGroup
1515
* @param array $args
1616
* @return string[]|bool
1717
*/
18-
public function testEcho($args = [])
18+
public function testEcho(array $args = [])
1919
{
2020
return $this->flickr->request('flickr.test.echo', $args, true);
2121
}

tests/ApiMethodGroup/PhotosetsApiTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class PhotosetsApiTest extends TestCase
88
{
99
protected $testPhotoId;
1010

11-
public function setUp()
11+
public function setUp(): void
1212
{
1313
parent::setUp();
1414
$flickr = $this->getFlickr(true);
@@ -17,9 +17,9 @@ public function setUp()
1717
$this->testPhotoId = $uploaded['photoid'];
1818
}
1919

20-
public function tearDown()
20+
public function tearDown(): void
2121
{
22-
$this->getFlickr(true)->photos_delete($this->testPhotoId);
22+
$this->getFlickr(true)->photos()->delete($this->testPhotoId);
2323
}
2424

2525
public function testCreate()

tests/ApiMethodGroup/TestApiTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public function testEchoWithInvalidKey()
2626
public function testEcho()
2727
{
2828
$flickr = $this->getFlickr();
29+
2930
$echo = $flickr->test()->testEcho(['foo' => 'bar']);
30-
static::assertArraySubset(['foo' => 'bar', 'method' => 'flickr.test.echo'], $echo);
31+
32+
$this->assertArrayHasKey('foo', $echo);
3133
}
3234
}

tests/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ abstract class TestCase extends PhpUnitTestCase
1717
* available in tests/config.php.
1818
* @return PhpFlickr
1919
*/
20-
public function getFlickr($authenticate = false)
20+
public function getFlickr(bool $authenticate = false): PhpFlickr
2121
{
2222
if ($this->flickr instanceof PhpFlickr) {
2323
return $this->flickr;
@@ -28,7 +28,7 @@ public function getFlickr($authenticate = false)
2828
$apiSecret = getenv('FLICKR_API_SECRET');
2929
$accessToken = getenv('FLICKR_ACCESS_TOKEN');
3030
$accessTokenSecret = getenv('FLICKR_ACCESS_SECRET');
31-
if (empty($apiKey)) {
31+
if (empty($apiKey) && file_exists(__DIR__ . '/config.php')) {
3232
require __DIR__ . '/config.php';
3333
}
3434
if (empty($apiKey)) {

0 commit comments

Comments
 (0)