-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathDirectoryTest.php
59 lines (50 loc) · 1.92 KB
/
DirectoryTest.php
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
declare(strict_types=1);
use PhpSpellcheck\Source\Directory;
use PHPUnit\Framework\TestCase;
use function PhpSpellcheck\t;
class DirectoryTest extends TestCase
{
private const TEXT_FIXTURES_PATH = __DIR__ . '/../Fixtures/Text/Directory';
public function testToTexts(): void
{
$textsFromDirectory = (new Directory(self::TEXT_FIXTURES_PATH))->toTexts(['ctx' => 'in tests']);
$expectedValues = [
t("mispélling3\n", ['ctx' => 'in tests', 'filePath' => realpath(self::TEXT_FIXTURES_PATH . '/mispelling3.txt')]),
t(
"mispelling2\n",
['ctx' => 'in tests', 'filePath' => realpath(self::TEXT_FIXTURES_PATH . '/mispelling2.txt')]
),
t(
"mispelling4\n",
[
'ctx' => 'in tests',
'filePath' => realpath(self::TEXT_FIXTURES_PATH . '/SubDirectory/mispelling4.txt'),
]
),
];
$realValues = iterator_to_array($textsFromDirectory);
foreach ($expectedValues as $value) {
$this->assertContainsEquals($value, $realValues);
}
}
public function testToTextsMatchingRegex(): void
{
$textsFromDirectory = (new Directory(self::TEXT_FIXTURES_PATH, '/^((?!mispelling3\.txt).)*$/'))
->toTexts(['ctx' => 'in tests']);
$expectedValues = [
t(
"mispelling2\n",
['ctx' => 'in tests', 'filePath' => realpath(self::TEXT_FIXTURES_PATH . '/mispelling2.txt')]
),
t("mispelling4\n", [
'ctx' => 'in tests',
'filePath' => realpath(self::TEXT_FIXTURES_PATH . '/SubDirectory/mispelling4.txt'),
]),
];
$realValues = iterator_to_array($textsFromDirectory);
foreach ($expectedValues as $value) {
$this->assertContainsEquals($value, $realValues);
}
}
}