@@ 5-36 (lines=32) @@ | ||
2 | ||
3 | namespace Spatie\PhpUnitWatcher\Screens; |
|
4 | ||
5 | class FilterFileName extends Screen |
|
6 | { |
|
7 | public function draw() |
|
8 | { |
|
9 | $this->terminal |
|
10 | ->comment('Pattern mode usage') |
|
11 | ->write('Type a pattern and press Enter to only run tests in the giving path or file.') |
|
12 | ->write('Press Enter with an empty pattern to execute all tests in all files.') |
|
13 | ->emptyLine() |
|
14 | ->comment('Start typing to filter by a test name.') |
|
15 | ->prompt('pattern > '); |
|
16 | ||
17 | return $this; |
|
18 | } |
|
19 | ||
20 | public function registerListeners() |
|
21 | { |
|
22 | $this->terminal->on('data', function ($line) { |
|
23 | if ($line == '') { |
|
24 | $this->terminal->goBack(); |
|
25 | ||
26 | return; |
|
27 | } |
|
28 | ||
29 | $phpunitArguments = "{$line}"; |
|
30 | ||
31 | $this->terminal->displayScreen(new Phpunit($phpunitArguments)); |
|
32 | }); |
|
33 | ||
34 | return $this; |
|
35 | } |
|
36 | } |
|
37 |
@@ 5-36 (lines=32) @@ | ||
2 | ||
3 | namespace Spatie\PhpUnitWatcher\Screens; |
|
4 | ||
5 | class FilterTestName extends Screen |
|
6 | { |
|
7 | public function draw() |
|
8 | { |
|
9 | $this->terminal |
|
10 | ->comment('Pattern mode usage') |
|
11 | ->write('Type a pattern and press Enter to apply pattern to all tests.') |
|
12 | ->write('Press Enter with an empty pattern to keep the current pattern.') |
|
13 | ->emptyLine() |
|
14 | ->comment('Start typing to filter by a test name.') |
|
15 | ->prompt('pattern > '); |
|
16 | ||
17 | return $this; |
|
18 | } |
|
19 | ||
20 | public function registerListeners() |
|
21 | { |
|
22 | $this->terminal->on('data', function ($line) { |
|
23 | if ($line == '') { |
|
24 | $this->terminal->goBack(); |
|
25 | ||
26 | return; |
|
27 | } |
|
28 | ||
29 | $phpunitArguments = "--filter={$line}"; |
|
30 | ||
31 | $this->terminal->displayScreen(new Phpunit($phpunitArguments)); |
|
32 | }); |
|
33 | ||
34 | return $this; |
|
35 | } |
|
36 | } |
|
37 |