Skip to content

Commit b4c905f

Browse files
committed
Fix SupportedPhpExtensions test
1 parent c47df1d commit b4c905f

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/Integrations/SupportedPhpExtensions.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@ public function get(string $phpVersion = null): array
1717
try {
1818
$contents = $this->fetch();
1919

20-
return $this->cache = str($contents)
21-
->explode("\n")
20+
return $this->cache = collect($contents)
2221
->filter(fn (string $extension): bool => is_null($phpVersion) || str($extension)->contains($phpVersion))
2322
->map(fn (string $extension): string => str($extension)->trim()->before(' '))
2423
->filter()
24+
->values()
2525
->toArray();
2626
} catch (\ErrorException) {
2727
return [];
2828
}
2929
}
3030

31-
protected function fetch(): string|false
31+
protected function fetch(): array|false
3232
{
33-
return file_get_contents(self::URL);
33+
return file(self::URL);
3434
}
3535
}

tests/Unit/Integrations/SupportedPhpExtensionsTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ protected function setUp(): void
2424
->passthru();
2525
$mock->shouldReceive('fetch')
2626
->once()
27-
->andReturn(<<<'RES'
28-
apcu 8.1 8.2
29-
pdo_mysql 8.2
30-
pdo_pgsql 8.0 8.1
31-
memcached 8.0
32-
redis 8.1
33-
RES);
27+
->andReturn([
28+
'apcu 8.1 8.2',
29+
'pdo_mysql 8.2',
30+
'pdo_pgsql 8.0 8.1',
31+
'memcached 8.0',
32+
'redis 8.1',
33+
]);
3434
});
3535
}
3636

@@ -44,10 +44,10 @@ public function providePhpVersions(): array
4444
}
4545

4646
/** @dataProvider providePhpVersions */
47-
public function testItFiltersVersions(): void
47+
public function testItFiltersVersions($expected, $version): void
4848
{
49-
$supported = app(SupportedPhpExtensions::class)->get('8.2');
49+
$supported = app(SupportedPhpExtensions::class)->get($version);
5050

51-
self::assertEquals(['apcu', 'pdo_mysql'], $supported);
51+
self::assertEquals($expected, $supported);
5252
}
5353
}

0 commit comments

Comments
 (0)