Skip to content

Commit fe8a712

Browse files
committed
Merge pull request #4 from atoum/looper_interface
use looper interface
2 parents afc7843 + 2a6de1a commit fe8a712

File tree

3 files changed

+24
-39
lines changed

3 files changed

+24
-39
lines changed

classes/extension.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,10 @@ public function __construct(atoum\configurator $configurator = null)
3737
$autoLoopHandler = function(\mageekguy\atoum\scripts\runner $script, $argument, $values) use ($configuration) {
3838
$script->enableLoopMode();
3939

40-
$customPrompt = new prompt();
41-
$customPrompt->setOutputWriter($script->getPrompt()->getOutputWriter());
42-
$customPrompt->setInputReader($script->getPrompt()->getInputReader());
43-
$customPrompt->setRunner($script->getRunner());
44-
$customPrompt->setConfiguration($configuration);
45-
$script->setPrompt($customPrompt);
40+
$watcherStrategy = new scripts\runner\loopers\watcher($script);
41+
$watcherStrategy->setConfiguration($configuration);
4642

43+
$script->setLooper($watcherStrategy);
4744
};
4845

4946
$script

classes/prompt.php renamed to classes/scripts/runner/loopers/watcher.php

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,40 @@
11
<?php
22

3-
namespace mageekguy\atoum\autoloop;
3+
namespace mageekguy\atoum\autoloop\scripts\runner\loopers;
44

55
use Lurker\Event\FilesystemEvent;
66
use Lurker\ResourceWatcher;
7+
use mageekguy\atoum\autoloop\configuration;
8+
use mageekguy\atoum\scripts\runner;
9+
use mageekguy\atoum\scripts\runner\looper;
710

8-
class prompt extends \mageekguy\atoum\script\prompt
11+
class watcher implements looper
912
{
1013
/**
11-
* @var \mageekguy\atoum\runner
14+
* @var configuration
1215
*/
13-
protected $runner;
16+
protected $configuration;
1417

1518
/**
16-
* @var configuration
19+
* @var runner
1720
*/
18-
protected $configuration;
21+
private $runner;
1922

2023
/**
21-
* @param string $message
22-
*
23-
* @return string
24+
* @param runner $runner
2425
*/
25-
public function ask($message)
26+
public function __construct(runner $runner)
2627
{
27-
$runAgainText = "Press <Enter> to reexecute, press any other key and <Enter> to stop...";
28-
if ($message != $runAgainText) {
29-
return parent::ask($message);
30-
}
28+
$this->runner = $runner;
29+
}
3130

31+
/**
32+
* @return string
33+
*/
34+
public function runAgain()
35+
{
3236
/** @var \mageekguy\atoum\writers\std\out $outputWriter */
33-
$outputWriter = $this->getOutputWriter();
37+
$outputWriter = $this->runner->getOutputWriter();
3438

3539
$watcher = new ResourceWatcher;
3640

@@ -44,7 +48,7 @@ public function ask($message)
4448
$watcher->addListener($watchedFile, $onEvent);
4549
}
4650

47-
foreach ($this->getRunner()->getTestPaths() as $path) {
51+
foreach ($this->runner->getRunner()->getTestPaths() as $path) {
4852
$watcher->track($path, $path);
4953
$watcher->addListener($path, $onEvent);
5054
}
@@ -56,22 +60,6 @@ public function ask($message)
5660
return '';
5761
}
5862

59-
/**
60-
* @return \mageekguy\atoum\runner
61-
*/
62-
public function getRunner()
63-
{
64-
return $this->runner;
65-
}
66-
67-
/**
68-
* @param $runner
69-
*/
70-
public function setRunner($runner)
71-
{
72-
$this->runner = $runner;
73-
}
74-
7563
/**
7664
* @return configuration
7765
*/

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
}
1818
},
1919
"require": {
20-
"atoum/atoum": ">=2.5.0,<3.0",
20+
"atoum/atoum": ">=2.6.0,<3.0",
2121
"henrikbjorn/lurker": ">=1.1,<2.0"
2222
}
2323
}

0 commit comments

Comments
 (0)