-
-
Notifications
You must be signed in to change notification settings - Fork 439
Expand file tree
/
Copy pathFnMatchPathNormalizerTest.php
More file actions
43 lines (35 loc) · 1.48 KB
/
FnMatchPathNormalizerTest.php
File metadata and controls
43 lines (35 loc) · 1.48 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
35
36
37
38
39
40
41
42
43
<?php
declare(strict_types=1);
namespace Rector\Tests\Skipper\FileSystem;
use Iterator;
use PHPUnit\Framework\Attributes\DataProvider;
use Rector\Skipper\FileSystem\FnMatchPathNormalizer;
use Rector\Skipper\FileSystem\PathNormalizer;
use Rector\Testing\PHPUnit\AbstractLazyTestCase;
final class FnMatchPathNormalizerTest extends AbstractLazyTestCase
{
private FnMatchPathNormalizer $fnMatchPathNormalizer;
protected function setUp(): void
{
parent::setUp();
$this->fnMatchPathNormalizer = $this->make(FnMatchPathNormalizer::class);
}
#[DataProvider('providePaths')]
public function testPaths(string $path, string $expectedNormalizedPath): void
{
$normalizedPath = $this->fnMatchPathNormalizer->normalizeForFnmatch($path);
$this->assertSame($expectedNormalizedPath, $normalizedPath);
}
/**
* @return Iterator<array<int, string>>
*/
public static function providePaths(): Iterator
{
yield ['path/with/no/asterisk', 'path/with/no/asterisk'];
yield ['*path/with/asterisk/begin', '*path/with/asterisk/begin*'];
yield ['path/with/asterisk/end*', '*path/with/asterisk/end*'];
yield ['*path/with/asterisk/begin/and/end*', '*path/with/asterisk/begin/and/end*'];
yield [__DIR__ . '/Fixture/path/with/../in/it', PathNormalizer::normalize(__DIR__ . '/Fixture/path/in/it')];
yield [__DIR__ . '/Fixture/path/with/../../in/it', PathNormalizer::normalize(__DIR__ . '/Fixture/in/it')];
}
}