-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New feature to run phpunit-watcher with a random seed.
- Loading branch information
1 parent
c50b121
commit a56d37e
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Spatie\PhpUnitWatcher\Screens; | ||
|
||
class RandomSeed extends Screen | ||
{ | ||
public function draw() | ||
{ | ||
$this->terminal | ||
->comment('Random seed usage') | ||
->write('Type a seed and press Enter to run tests in random order but with a specific seed.') | ||
->write('Press Enter with an empty pattern to execute all tests in random order.') | ||
->emptyLine() | ||
->comment('Start typing to add a random seed') | ||
->prompt('seed > '); | ||
|
||
return $this; | ||
} | ||
|
||
public function registerListeners() | ||
{ | ||
$this->terminal->on('data', function ($line) { | ||
$phpunitArguments = '--order-by=random'; | ||
if ($line !== '') { | ||
$phpunitArguments .= " --random-order-seed={$line}"; | ||
} | ||
|
||
$phpunitScreen = $this->terminal->getPreviousScreen(); | ||
|
||
$options = $phpunitScreen->options; | ||
|
||
$options['phpunit']['arguments'] = $phpunitArguments; | ||
|
||
$this->terminal->displayScreen(new Phpunit($options)); | ||
}); | ||
|
||
return $this; | ||
} | ||
} |