Skip to content

Commit

Permalink
Added PHP 8 support.
Browse files Browse the repository at this point in the history
Dropped PHP 7.2 support because coverage not supported by PHPUnit 8.
  • Loading branch information
Bilge committed Dec 16, 2020
1 parent 6942058 commit 62549df
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 19 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/CI.yml
Expand Up @@ -14,8 +14,8 @@ jobs:
max-parallel: 1
matrix:
php:
- 7.2
- 7.4
- 8.0
- 7.3
dependencies:
- hi
- lo
Expand All @@ -27,6 +27,7 @@ jobs:
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug

- name: Validate composer.json
run: composer validate
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Expand Up @@ -8,7 +8,7 @@
}
],
"require": {
"php": "^7.2",
"php": "^7.3|^8",
"ext-json": "*",
"amphp/parallel": "^1.1",
"connectors/http": "^4",
Expand All @@ -20,9 +20,9 @@
},
"require-dev": {
"amphp/phpunit-util": "^1.2",
"athari/yalinqo": "^2.4.2",
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^7.5"
"mockery/mockery": "^1.3.3",
"nikic/iter": "^2.1",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/Resource/ScrapeUserReviews.php
Expand Up @@ -36,7 +36,7 @@ public function fetch(ImportConnector $connector): \Iterator
// Force Crawler creation.
$pages->current();
$count = $crawler->filter('.review_stat')->first()->filter('.giantNumber')->text();
$avatar = preg_replace('[_medium(?=\.jpg$)]', null, $crawler->filter('.playerAvatar > img')->attr('src'));
$avatar = preg_replace('[_medium(?=\.jpg$)]', '', $crawler->filter('.playerAvatar > img')->attr('src'));

return new UsersReviewsRecords($pages, +$count, $avatar, $this);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Scrape/AppDetailsParser.php
Expand Up @@ -312,7 +312,7 @@ private static function trimNodeText(Crawler $crawler): string
*/
private static function filterNumbers(string $input): int
{
return +preg_replace('[\D]', null, $input);
return +preg_replace('[\D]', '', $input);
}

/**
Expand Down
14 changes: 11 additions & 3 deletions test/Functional/Curator/CuratorListsTest.php
Expand Up @@ -129,7 +129,10 @@ public function testReorderCuratorList(): void

// Fetch first app from list.
$list = self::fetchList($listId);
$firstApp = from($list['apps'])->orderBy('$v["sort_order"]')->first();
usort($list['apps'], static function (array $a, array $b) {
return $a['sort_order'] <=> $b['sort_order'];
});
$firstApp = reset($list['apps']);

self::assertSame(
$appId1,
Expand All @@ -144,7 +147,10 @@ public function testReorderCuratorList(): void

// Fetch first app from list.
$list = self::fetchList($listId);
$firstApp = from($list['apps'])->orderBy('$v["sort_order"]')->first();
usort($list['apps'], static function (array $a, array $b) {
return $a['sort_order'] <=> $b['sort_order'];
});
$firstApp = reset($list['apps']);

self::assertSame(
$appId2,
Expand Down Expand Up @@ -188,7 +194,9 @@ private static function fetchList(string $listId): array

$lists = wait(self::iteratorToArray($listIterator));

$list = from($lists)->firstOrDefault(null, "\$v['listid'] === '$listId'");
$list = \iter\search(static function (array $list) use ($listId) {
return $list['listid'] === $listId;
}, $lists);
self::assertNotNull($list, 'Find specified curator list in curator list collection.');

return $list;
Expand Down
2 changes: 1 addition & 1 deletion test/Functional/Curator/CuratorTestCase.php
Expand Up @@ -23,7 +23,7 @@ abstract class CuratorTestCase extends TestCase
*/
protected static $session;

public static function setUpBeforeClass()
public static function setUpBeforeClass(): void
{
self::$porter = FixtureFactory::createPorter();
self::$session = wait(FixtureFactory::createSession(self::$porter));
Expand Down
6 changes: 3 additions & 3 deletions test/Functional/ScrapeAppDetailsTest.php
Expand Up @@ -89,9 +89,9 @@ public function testGame(\Closure $import): void
self::assertIsString($tagName = $tag['name']);

// Tags should not contain any whitespace
self::assertNotContains("\r", $tagName);
self::assertNotContains("\n", $tagName);
self::assertNotContains("\t", $tagName);
self::assertStringNotContainsString("\r", $tagName);
self::assertStringNotContainsString("\n", $tagName);
self::assertStringNotContainsString("\t", $tagName);

// Tags should not start or end with spaces.
self::assertStringStartsNotWith(' ', $tagName);
Expand Down
8 changes: 4 additions & 4 deletions test/phpunit.xml
Expand Up @@ -5,9 +5,9 @@
<testsuite name="default">
<directory>.</directory>
</testsuite>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<coverage processUncoveredFiles="true">
<include>
<directory>../src</directory>
</whitelist>
</filter>
</include>
</coverage>
</phpunit>

0 comments on commit 62549df

Please sign in to comment.