forked from peckphp/peck
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckCommandTest.php
More file actions
96 lines (65 loc) · 2.69 KB
/
CheckCommandTest.php
File metadata and controls
96 lines (65 loc) · 2.69 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
declare(strict_types=1);
use Peck\Console\Commands\CheckCommand;
use Symfony\Component\Console\Tester\CommandTester;
it('may fail', function (): void {
$commandTester = new CommandTester(new CheckCommand);
$commandTester->execute([
'--path' => 'tests/Fixtures/ClassesToTest/FolderThatShouldBeIgnored',
]);
$output = $commandTester->getDisplay();
expect(trim($output))->toContain('Did you mean: property, propriety, properer, properest')
->and($commandTester->getStatusCode())->toBe(1);
});
it('may pass', function (): void {
$commandTester = new CommandTester(new CheckCommand);
$commandTester->execute([]);
$output = $commandTester->getDisplay();
expect(trim($output))->toContain('PASS No misspellings found in your project.')
->and($commandTester->getStatusCode())->toBe(0);
});
it('may pass with lineless issues', function (): void {
$commandTester = new CommandTester(new CheckCommand);
$commandTester->execute([
'--path' => 'tests/Fixtures/FolderWithTypoos',
]);
$output = $commandTester->getDisplay();
expect(trim($output))->toContain('Misspelling')
->and($commandTester->getStatusCode())->toBe(1);
});
it('may pass with init option', function (): void {
$commandTester = new CommandTester(new CheckCommand);
$commandTester->execute([
'--init' => true,
]);
$output = $commandTester->getDisplay();
expect(trim($output))->toContain('INFO Configuration file already exists.')
->and($commandTester->getStatusCode())->toBe(1);
});
it('may pass with ignore-all option', function (): void {
$commandTester = new CommandTester(new CheckCommand);
$commandTester->execute([
'--ignore-all' => true,
]);
$output = $commandTester->getDisplay();
expect(trim($output))->toContain('PASS No misspellings found in your project.')
->and($commandTester->getStatusCode())->toBe(0);
});
it('may fail with text option', function (): void {
$commandTester = new CommandTester(new CheckCommand);
$commandTester->execute([
'--text' => 'This is a test with a typoo.',
]);
$output = $commandTester->getDisplay();
expect(trim($output))->toContain('Did you mean: typo, typos, type, topi')
->and($commandTester->getStatusCode())->toBe(1);
});
it('may pass with text option', function (): void {
$commandTester = new CommandTester(new CheckCommand);
$commandTester->execute([
'--text' => 'This is a test without any typos.',
]);
$output = $commandTester->getDisplay();
expect(trim($output))->toContain('PASS No misspellings found in the given text.')
->and($commandTester->getStatusCode())->toBe(0);
});