-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFunctionPathsTest.php
More file actions
34 lines (28 loc) · 1.1 KB
/
Copy pathFunctionPathsTest.php
File metadata and controls
34 lines (28 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php
declare(strict_types=1);
require_once dirname(__DIR__, 1) . '/src/bootstrap.php';
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Paths\FunctionPaths;
final class FunctionPathsTest extends TestCase
{
public static function caseProvider(): array
{
return array_reduce(glob(__DIR__ . "/cases/*.php"), function (array $carry, string $actual_file): array {
$expected_file = str_replace(".php", ".c2s", $actual_file);
if (file_exists($expected_file)) {
$carry[$actual_file] = [$actual_file, $expected_file];
}
return $carry;
}, []);
}
#[DataProvider('caseProvider')]
public function testCases($actual_file, $expected_file): void
{
$actual_paths = implode("\n", array_filter(array_map(function (FunctionPaths $path): string {
return $path->toString();
}, iterator_to_array(FunctionPaths::fromFileName($actual_file)))));
$expected_paths = trim(file_get_contents($expected_file));
$this->assertEquals($actual_paths, $expected_paths);
}
}