Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Improve autorunner and field's report.

Rename scripts\runner::runAtShutdown() to scripts\runner::autorun().
Improve management of default value's argument in fields.
Improve cli/html coverage field.
Replace call to 'include' and 'require' by call to 'include_oncd' and 'require_once' in README.
Improve VIM report.
Update ressources/configurations.
  • Loading branch information...
commit 751c2d76086aaec917f929eaee9d593a2383226b 1 parent 6fcbf0c
@mageekguy authored
Showing with 294 additions and 482 deletions.
  1. +8 −6 README.markdown
  2. +2 −12 classes/report/fields/runner/atoum/cli.php
  3. +48 −19 classes/report/fields/runner/coverage/cli.php
  4. +30 −12 classes/report/fields/runner/coverage/html.php
  5. +3 −18 classes/report/fields/runner/duration/cli.php
  6. +6 −36 classes/report/fields/runner/errors/cli.php
  7. +6 −36 classes/report/fields/runner/exceptions/cli.php
  8. +4 −24 classes/report/fields/runner/failures/cli.php
  9. +6 −36 classes/report/fields/runner/outputs/cli.php
  10. +3 −18 classes/report/fields/runner/php/path/cli.php
  11. +4 −24 classes/report/fields/runner/php/version/cli.php
  12. +3 −19 classes/report/fields/runner/result/cli.php
  13. +5 −30 classes/report/fields/runner/tests/coverage/cli.php
  14. +3 −18 classes/report/fields/runner/tests/duration/cli.php
  15. +3 −18 classes/report/fields/runner/tests/memory/cli.php
  16. +3 −18 classes/report/fields/test/duration/cli.php
  17. +3 −18 classes/report/fields/test/memory/cli.php
  18. +2 −12 classes/report/fields/test/run/cli.php
  19. +41 −29 classes/reports/asynchronous/vim.php
  20. +30 −30 classes/reports/realtime/cli.php
  21. +19 −19 classes/scripts/runner.php
  22. +1 −1  ressources/configurations/runner/builder.php.dist
  23. +1 −1  ressources/configurations/runner/cli.php.dist
  24. +1 −1  ressources/configurations/runner/coverage.php.dist
  25. +1 −1  ressources/configurations/runner/vim.php.dist
  26. +1 −1  scripts/phar/resources/stub.php
  27. +1 −1  scripts/runner.php
  28. +56 −24 tests/units/classes/report/fields/runner/coverage/html.php
View
14 README.markdown
@@ -59,12 +59,12 @@ Le code source d'*atoum* est également disponible via [son dépôt sur github](
namespace vendor\project\tests\units;
- require 'path/to/mageekguy.atoum.phar';
+ require_once 'path/to/mageekguy.atoum.phar';
- include 'path/to/project/classes/helloWorld.php';
+ include_once 'path/to/project/classes/helloWorld.php';
- use \mageekguy\atoum;
- use \vendor\project;
+ use mageekguy\atoum;
+ use vendor\project;
class helloWorld extends atoum\test
{
@@ -136,8 +136,10 @@ Vous devez cette fois obtenir le résultat suivant, ou équivalent :
require_once 'path/to/mageekguy.atoum.phar';
- use \mageekguy\atoum;
- use \vendor\project;
+ include_once 'path/to/project/classes/helloWorld.php';
+
+ use mageekguy\atoum;
+ use vendor\project;
class helloWorld extends atoum\test
{
View
14 classes/report/fields/runner/atoum/cli.php
@@ -18,19 +18,9 @@ public function __construct(prompt $prompt = null, colorizer $colorizer = null,
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($colorizer === null)
- {
- $colorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setColorizer($colorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setColorizer($colorizer ?: new colorizer())
;
}
View
67 classes/report/fields/runner/coverage/cli.php
@@ -4,27 +4,32 @@
use
\mageekguy\atoum,
+ \mageekguy\atoum\locale,
+ \mageekguy\atoum\cli\prompt,
+ \mageekguy\atoum\cli\colorizer,
\mageekguy\atoum\report
;
class cli extends report\fields\runner\coverage
{
- const defaultPrompt = '> ';
+ protected $prompt = null;
+ protected $titleColorizer = null;
+ protected $coverageColorizer = null;
- protected $prompt = '';
-
- public function __construct(atoum\locale $locale = null, $prompt = null)
+ public function __construct(prompt $prompt = null, colorizer $titleColorizer = null, colorizer $coverageColorizer = null, locale $locale = null)
{
parent::__construct($locale);
$this
- ->setPrompt($prompt ?: self::defaultPrompt)
+ ->setPrompt($prompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setCoverageColorizer($coverageColorizer ?: new colorizer())
;
}
- public function setPrompt($prompt)
+ public function setPrompt(prompt $prompt)
{
- $this->prompt = (string) $prompt;
+ $this->prompt = $prompt;
return $this;
}
@@ -34,22 +39,46 @@ public function getPrompt()
return $this->prompt;
}
- public function __toString()
+ public function setTitleColorizer(colorizer $colorizer)
{
- $string = $this->prompt;
+ $this->titleColorizer = $colorizer;
- if ($this->coverage === null)
- {
- $string .= $this->locale->_('Code coverage: unknown.');
- }
- else
- {
- $string .= sprintf($this->locale->_('Code coverage: %3.2f%%.'), round($this->coverage->getValue() * 100, 2));
- }
+ return $this;
+ }
- $string .= PHP_EOL;
+ public function getTitleColorizer()
+ {
+ return $this->titleColorizer;
+ }
+
+ public function setCoverageColorizer(colorizer $colorizer)
+ {
+ $this->coverageColorizer = $colorizer;
- return $string;
+ return $this;
+ }
+
+ public function getCoverageColorizer()
+ {
+ return $this->coverageColorizer;
+ }
+
+ public function __toString()
+ {
+ return $this->prompt .
+ sprintf(
+ '%s: %s.',
+ $this->titleColorizer->colorize($this->locale->_('Code coverage')),
+ $this->coverageColorizer->colorize(
+ $this->coverage === null
+ ?
+ $this->locale->_('unknown')
+ :
+ sprintf($this->locale->_('%3.2f%%'), round($this->coverage->getValue() * 100, 2))
+ )
+ ) .
+ PHP_EOL
+ ;
}
}
View
42 classes/report/fields/runner/coverage/html.php
@@ -2,39 +2,45 @@
namespace mageekguy\atoum\report\fields\runner\coverage;
+require_once(__DIR__ . '/../../../../../constants.php');
+
use
\mageekguy\atoum,
+ \mageekguy\atoum\locale,
\mageekguy\atoum\report,
\mageekguy\atoum\template,
- \mageekguy\atoum\exceptions
+ \mageekguy\atoum\exceptions,
+ \mageekguy\atoum\cli\prompt,
+ \mageekguy\atoum\cli\colorizer
;
class html extends report\fields\runner\coverage\cli
{
const htmlExtensionFile = '.html';
- const defaultAlternatePrompt = '=> ';
+ protected $urlPrompt = null;
+ protected $urlColorizer = null;
protected $adapter = null;
protected $rootUrl = '';
protected $projectName = '';
- protected $alternatePrompt = '';
protected $srcDirectories = array();
protected $templatesDirectory = null;
protected $destinationDirectory = null;
protected $templateParser = null;
protected $reflectionClassInjector = null;
- public function __construct($projectName, $templatesDirectory, $destinationDirectory, template\parser $parser = null, atoum\adapter $adapter = null, atoum\locale $locale = null, $prompt = null, $alternatePrompt = null)
+ public function __construct($projectName, $destinationDirectory, $templatesDirectory = null, prompt $prompt = null, colorizer $titleColorizer = null, colorizer $coverageColorizer = null, prompt $urlPrompt = null, colorizer $urlColorizer = null, template\parser $parser = null, atoum\adapter $adapter = null, locale $locale = null)
{
- parent::__construct($locale, $prompt);
+ parent::__construct($prompt, $titleColorizer, $coverageColorizer, $locale);
$this
+ ->setUrlPrompt($urlPrompt ?: new prompt())
+ ->setUrlColorizer($urlColorizer ?: new colorizer())
->setProjectName($projectName)
- ->setTemplatesDirectory($templatesDirectory)
+ ->setTemplatesDirectory($templatesDirectory ?: atoum\directory . '/ressources/templates/coverage')
->setDestinationDirectory($destinationDirectory)
->setTemplateParser($parser ?: new template\parser())
->setAdapter($adapter ?: new atoum\adapter())
- ->setAlternatePrompt($alternatePrompt ?: self::defaultAlternatePrompt)
->setRootUrl('/')
;
}
@@ -308,7 +314,7 @@ public function __toString()
$sourceFileTemplates->resetData();
}
- $string .= $this->alternatePrompt . sprintf($this->locale->_('Details of code coverage are available at %s.'), $this->rootUrl) . PHP_EOL;
+ $string .= $this->urlPrompt . $this->urlColorizer->colorize(sprintf($this->locale->_('Details of code coverage are available at %s.'), $this->rootUrl)) . PHP_EOL;
}
return $string;
@@ -326,16 +332,28 @@ public function getAdapter()
return $this->adapter;
}
- public function setAlternatePrompt($prompt)
+ public function setUrlPrompt(prompt $prompt)
+ {
+ $this->urlPrompt = $prompt;
+
+ return $this;
+ }
+
+ public function getUrlPrompt()
+ {
+ return $this->urlPrompt;
+ }
+
+ public function setUrlColorizer(colorizer $colorizer)
{
- $this->alternatePrompt = (string) $prompt;
+ $this->urlColorizer = $colorizer;
return $this;
}
- public function getAlternatePrompt()
+ public function getUrlColorizer()
{
- return $this->alternatePrompt;
+ return $this->urlColorizer;
}
public function addSrcDirectory($srcDirectory, \closure $filterClosure = null)
View
21 classes/report/fields/runner/duration/cli.php
@@ -20,25 +20,10 @@ public function __construct(prompt $prompt = null, colorizer $titleColorizer = n
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($durationColorizer === null)
- {
- $durationColorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setTitleColorizer($titleColorizer)
- ->setDurationColorizer($durationColorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setDurationColorizer($durationColorizer ?: new colorizer())
;
}
View
42 classes/report/fields/runner/errors/cli.php
@@ -23,43 +23,13 @@ public function __construct(prompt $titlePrompt = null, colorizer $titleColorize
{
parent::__construct($locale);
- if ($titlePrompt === null)
- {
- $titlePrompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($methodPrompt === null)
- {
- $methodPrompt = new prompt();
- }
-
- if ($methodColorizer === null)
- {
- $methodColorizer = new colorizer();
- }
-
- if ($errorPrompt === null)
- {
- $errorPrompt = new prompt();
- }
-
- if ($errorColorizer === null)
- {
- $errorColorizer = new colorizer();
- }
-
$this
- ->setTitlePrompt($titlePrompt)
- ->setTitleColorizer($titleColorizer)
- ->setMethodPrompt($methodPrompt)
- ->setMethodColorizer($methodColorizer)
- ->setErrorPrompt($errorPrompt)
- ->setErrorColorizer($errorColorizer)
+ ->setTitlePrompt($titlePrompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setMethodPrompt($methodPrompt ?: new prompt())
+ ->setMethodColorizer($methodColorizer ?: new colorizer())
+ ->setErrorPrompt($errorPrompt ?: new prompt())
+ ->setErrorColorizer($errorColorizer ?: new colorizer())
;
}
View
42 classes/report/fields/runner/exceptions/cli.php
@@ -23,43 +23,13 @@ public function __construct(prompt $titlePrompt = null, colorizer $titleColorize
{
parent::__construct($locale);
- if ($titlePrompt === null)
- {
- $titlePrompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($methodPrompt === null)
- {
- $methodPrompt = new prompt();
- }
-
- if ($methodColorizer === null)
- {
- $methodColorizer = new colorizer();
- }
-
- if ($exceptionPrompt === null)
- {
- $exceptionPrompt = new prompt();
- }
-
- if ($exceptionColorizer === null)
- {
- $exceptionColorizer = new colorizer();
- }
-
$this
- ->setTitlePrompt($titlePrompt)
- ->setTitleColorizer($titleColorizer)
- ->setMethodPrompt($methodPrompt)
- ->setMethodColorizer($methodColorizer)
- ->setExceptionPrompt($exceptionPrompt)
- ->setExceptionColorizer($exceptionColorizer)
+ ->setTitlePrompt($titlePrompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setMethodPrompt($methodPrompt ?: new prompt())
+ ->setMethodColorizer($methodColorizer ?: new colorizer())
+ ->setExceptionPrompt($exceptionPrompt ?: new prompt())
+ ->setExceptionColorizer($exceptionColorizer ?: new colorizer())
;
}
View
28 classes/report/fields/runner/failures/cli.php
@@ -21,31 +21,11 @@ public function __construct(prompt $titlePrompt = null, colorizer $titleColorize
{
parent::__construct($locale);
- if ($titlePrompt === null)
- {
- $titlePrompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($methodPrompt === null)
- {
- $methodPrompt = new prompt();
- }
-
- if ($methodColorizer === null)
- {
- $methodColorizer = new colorizer();
- }
-
$this
- ->setTitlePrompt($titlePrompt)
- ->setTitleColorizer($titleColorizer)
- ->setMethodPrompt($methodPrompt)
- ->setMethodColorizer($methodColorizer)
+ ->setTitlePrompt($titlePrompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setMethodPrompt($methodPrompt ?: new prompt())
+ ->setMethodColorizer($methodColorizer ?: new colorizer())
;
}
View
42 classes/report/fields/runner/outputs/cli.php
@@ -23,43 +23,13 @@ public function __construct(prompt $titlePrompt = null, colorizer $titleColorize
{
parent::__construct($locale);
- if ($titlePrompt === null)
- {
- $titlePrompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($methodPrompt === null)
- {
- $methodPrompt = new prompt();
- }
-
- if ($methodColorizer === null)
- {
- $methodColorizer = new colorizer();
- }
-
- if ($outputPrompt === null)
- {
- $outputPrompt = new prompt();
- }
-
- if ($outputColorizer === null)
- {
- $outputColorizer = new colorizer();
- }
-
$this
- ->setTitlePrompt($titlePrompt)
- ->setTitleColorizer($titleColorizer)
- ->setMethodPrompt($methodPrompt)
- ->setMethodColorizer($methodColorizer)
- ->setOutputPrompt($outputPrompt)
- ->setOutputColorizer($outputColorizer)
+ ->setTitlePrompt($titlePrompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setMethodPrompt($methodPrompt ?: new prompt())
+ ->setMethodColorizer($methodColorizer ?: new colorizer())
+ ->setOutputPrompt($outputPrompt ?: new prompt())
+ ->setOutputColorizer($outputColorizer ?: new colorizer())
;
}
View
21 classes/report/fields/runner/php/path/cli.php
@@ -20,25 +20,10 @@ public function __construct(prompt $prompt = null, colorizer $titleColorizer = n
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($pathColorizer === null)
- {
- $pathColorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setTitleColorizer($titleColorizer)
- ->setPathColorizer($pathColorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setPathColorizer($pathColorizer ?: new colorizer())
;
}
View
28 classes/report/fields/runner/php/version/cli.php
@@ -20,31 +20,11 @@ public function __construct(prompt $titlePrompt = null, colorizer $titleColorize
{
parent::__construct($locale);
- if ($titlePrompt === null)
- {
- $titlePrompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($versionPrompt === null)
- {
- $versionPrompt = new prompt();
- }
-
- if ($versionColorizer === null)
- {
- $versionColorizer = new colorizer();
- }
-
$this
- ->setTitlePrompt($titlePrompt)
- ->setTitleColorizer($titleColorizer)
- ->setVersionPrompt($versionPrompt)
- ->setVersionColorizer($versionColorizer)
+ ->setTitlePrompt($titlePrompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setVersionPrompt($versionPrompt ?: new prompt())
+ ->setVersionColorizer($versionColorizer ?: new colorizer())
;
}
View
22 classes/report/fields/runner/result/cli.php
@@ -20,26 +20,10 @@ public function __construct(prompt $prompt = null, colorizer $successColorizer =
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($successColorizer === null)
- {
- $successColorizer = new colorizer();
- }
-
-
- if ($failureColorizer === null)
- {
- $failureColorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setSuccessColorizer($successColorizer)
- ->setFailureColorizer($failureColorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setSuccessColorizer($successColorizer ?: new colorizer())
+ ->setFailureColorizer($failureColorizer ?: new colorizer())
;
}
View
35 classes/report/fields/runner/tests/coverage/cli.php
@@ -22,37 +22,12 @@ public function __construct(prompt $titlePrompt = null, prompt $classPrompt = nu
{
parent::__construct($locale);
- if ($titlePrompt === null)
- {
- $titlePrompt = new prompt();
- }
-
- if ($classPrompt === null)
- {
- $classPrompt = new prompt();
- }
-
- if ($methodPrompt === null)
- {
- $methodPrompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($coverageColorizer === null)
- {
- $coverageColorizer = new colorizer();
- }
-
$this
- ->setTitlePrompt($titlePrompt)
- ->setClassPrompt($classPrompt)
- ->setMethodPrompt($methodPrompt)
- ->setTitleColorizer($titleColorizer)
- ->setCoverageColorizer($coverageColorizer)
+ ->setTitlePrompt($titlePrompt ?: new prompt())
+ ->setClassPrompt($classPrompt ?: new prompt())
+ ->setMethodPrompt($methodPrompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setCoverageColorizer($coverageColorizer ?: new colorizer())
;
}
View
21 classes/report/fields/runner/tests/duration/cli.php
@@ -20,25 +20,10 @@ public function __construct(prompt $prompt = null, colorizer $titleColorizer = n
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($durationColorizer === null)
- {
- $durationColorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setTitleColorizer($titleColorizer)
- ->setDurationColorizer($durationColorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setDurationColorizer($durationColorizer ?: new colorizer())
;
}
View
21 classes/report/fields/runner/tests/memory/cli.php
@@ -20,25 +20,10 @@ public function __construct(prompt $prompt = null, colorizer $titleColorizer = n
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($memoryColorizer === null)
- {
- $memoryColorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setTitleColorizer($titleColorizer)
- ->setMemoryColorizer($memoryColorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setMemoryColorizer($memoryColorizer ?: new colorizer())
;
}
View
21 classes/report/fields/test/duration/cli.php
@@ -20,25 +20,10 @@ public function __construct(prompt $prompt = null, colorizer $titleColorizer = n
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($durationColorizer === null)
- {
- $durationColorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setTitleColorizer($titleColorizer)
- ->setDurationColorizer($durationColorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setDurationColorizer($durationColorizer ?: new colorizer())
;
}
View
21 classes/report/fields/test/memory/cli.php
@@ -20,25 +20,10 @@ public function __construct(prompt $prompt = null, colorizer $titleColorizer = n
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($titleColorizer === null)
- {
- $titleColorizer = new colorizer();
- }
-
- if ($memoryColorizer === null)
- {
- $memoryColorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setTitleColorizer($titleColorizer)
- ->setMemoryColorizer($memoryColorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setTitleColorizer($titleColorizer ?: new colorizer())
+ ->setMemoryColorizer($memoryColorizer ?: new colorizer())
;
}
View
14 classes/report/fields/test/run/cli.php
@@ -19,19 +19,9 @@ public function __construct(prompt $prompt = null, colorizer $colorizer = null,
{
parent::__construct($locale);
- if ($prompt === null)
- {
- $prompt = new prompt();
- }
-
- if ($colorizer === null)
- {
- $colorizer = new colorizer();
- }
-
$this
- ->setPrompt($prompt)
- ->setColorizer($colorizer)
+ ->setPrompt($prompt ?: new prompt())
+ ->setColorizer($colorizer ?: new colorizer())
;
}
View
70 classes/reports/asynchronous/vim.php
@@ -17,78 +17,90 @@ public function __construct(atoum\locale $locale = null, atoum\adapter $adapter
{
parent::__construct($locale, $adapter);
+ $firstLevelPrompt = new prompt('> ');
+ $secondLevelPrompt = new prompt('=> ');
+ $thirdLevelPrompt = new prompt('==> ');
+
$this
- ->addRunnerField(new runner\atoum\cli(new prompt('> '), new colorizer()), array(atoum\runner::runStart))
+ ->addRunnerField(new runner\atoum\cli($firstLevelPrompt, null), array(atoum\runner::runStart))
->addRunnerField(new runner\tests\duration\cli(
- new prompt('> ')
+ $firstLevelPrompt
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\tests\memory\cli(
- new prompt('> ')
+ $firstLevelPrompt
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\tests\coverage\cli(
- new prompt('> '),
- new prompt('=> '),
- new prompt('==> ')
+ $firstLevelPrompt,
+ $secondLevelPrompt,
+ $thirdLevelPrompt
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\duration\cli(
- new prompt('> ')
+ $firstLevelPrompt
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\result\cli(
- new prompt('> ')
+ $firstLevelPrompt
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\failures\cli(
- new prompt('> '),
- new colorizer(),
- new prompt('=> ', new colorizer()),
- new colorizer()
+ $firstLevelPrompt,
+ null,
+ $secondLevelPrompt,
+ null
),
array(atoum\runner::runStop)
)
->addRunnerField(
new runner\outputs\cli(
- new prompt('> '),
+ $firstLevelPrompt,
null,
- new prompt('=> ')
+ $secondLevelPrompt
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\errors\cli(
- new prompt('> '),
- new colorizer(),
- new prompt('=> '),
- new colorizer(),
- new prompt('==> '),
- new colorizer()
+ $firstLevelPrompt,
+ null,
+ $secondLevelPrompt,
+ null,
+ $thirdLevelPrompt,
+ null
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\exceptions\cli(
- new prompt('> '),
- new colorizer(),
- new prompt('=> '),
- new colorizer(),
- new prompt('==> ', new colorizer()),
- new colorizer()
+ $firstLevelPrompt,
+ null,
+ $secondLevelPrompt,
+ null,
+ $thirdLevelPrompt,
+ null
),
array(atoum\runner::runStop)
)
->addTestField(new test\run\cli(
- new prompt('> ')
+ $firstLevelPrompt
),
array(atoum\test::runStart)
)
- ->addTestField(new test\duration\cli(), array(atoum\test::runStop))
- ->addTestField(new test\memory\cli(), array(atoum\test::runStop))
+ ->addTestField(new test\duration\cli(
+ $firstLevelPrompt
+ ),
+ array(atoum\test::runStop)
+ )
+ ->addTestField(new test\memory\cli(
+ $firstLevelPrompt
+ ),
+ array(atoum\test::runStop)
+ )
;
}
View
60 classes/reports/realtime/cli.php
@@ -17,10 +17,10 @@ public function __construct()
{
parent::__construct();
- $topLevelPrompt = new prompt('> ');
- $topLevelColorizer = new colorizer('1;36');
+ $firstLevelPrompt = new prompt('> ');
+ $firstLevelColorizer = new colorizer('1;36');
- $secondLevelPrompt = new prompt('=> ', $topLevelColorizer);
+ $secondLevelPrompt = new prompt('=> ', $firstLevelColorizer);
$failureColorizer = new colorizer('0;31');
$failurePrompt = clone $secondLevelPrompt;
@@ -36,59 +36,59 @@ public function __construct()
$this
->addRunnerField(new runner\atoum\cli(
- $topLevelPrompt,
- $topLevelColorizer
+ $firstLevelPrompt,
+ $firstLevelColorizer
),
array(atoum\runner::runStart)
)
->addRunnerField(new runner\php\path\cli(
- $topLevelPrompt,
- $topLevelColorizer
+ $firstLevelPrompt,
+ $firstLevelColorizer
),
array(atoum\runner::runStart)
)
->addRunnerField(new runner\php\version\cli(
- $topLevelPrompt,
- $topLevelColorizer,
+ $firstLevelPrompt,
+ $firstLevelColorizer,
$secondLevelPrompt
),
array(atoum\runner::runStart)
)
->addRunnerField(new runner\tests\duration\cli(
- $topLevelPrompt,
- $topLevelColorizer
+ $firstLevelPrompt,
+ $firstLevelColorizer
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\tests\memory\cli(
- $topLevelPrompt,
- $topLevelColorizer
+ $firstLevelPrompt,
+ $firstLevelColorizer
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\tests\coverage\cli(
- $topLevelPrompt,
+ $firstLevelPrompt,
$secondLevelPrompt,
- new prompt('==> ', $topLevelColorizer),
- $topLevelColorizer
+ new prompt('==> ', $firstLevelColorizer),
+ $firstLevelColorizer
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\duration\cli(
- $topLevelPrompt,
- $topLevelColorizer
+ $firstLevelPrompt,
+ $firstLevelColorizer
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\result\cli(
- $topLevelPrompt,
+ $firstLevelPrompt,
new colorizer('0;37', '42'),
new colorizer('0;37', '41')
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\failures\cli(
- $topLevelPrompt,
+ $firstLevelPrompt,
$failureColorizer,
$failurePrompt
),
@@ -96,42 +96,42 @@ public function __construct()
)
->addRunnerField(
new runner\outputs\cli(
- $topLevelPrompt,
- $topLevelColorizer,
+ $firstLevelPrompt,
+ $firstLevelColorizer,
$secondLevelPrompt
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\errors\cli(
- $topLevelPrompt,
+ $firstLevelPrompt,
$errorColorizer,
$errorPrompt
),
array(atoum\runner::runStop)
)
->addRunnerField(new runner\exceptions\cli(
- $topLevelPrompt,
+ $firstLevelPrompt,
$exceptionColorizer,
$exceptionPrompt
),
array(atoum\runner::runStop)
)
->addTestField(new test\run\cli(
- $topLevelPrompt,
- $topLevelColorizer
+ $firstLevelPrompt,
+ $firstLevelColorizer
),
array(atoum\test::runStart)
)
->addTestField(new test\event\cli())
->addTestField(new test\duration\cli(
- $topLevelPrompt,
- $topLevelColorizer
+ $firstLevelPrompt,
+ $firstLevelColorizer
),
array(atoum\test::runStop)
)
->addTestField(new test\memory\cli(
- $topLevelPrompt,
- $topLevelColorizer
+ $firstLevelPrompt,
+ $firstLevelColorizer
),
array(atoum\test::runStop)
)
View
38 classes/scripts/runner.php
@@ -16,7 +16,7 @@ class runner extends atoum\script
protected $scoreFile = null;
protected $reportsEnabled = true;
- protected static $shutdownInstance = null;
+ protected static $autorunner = null;
public function __construct($name, atoum\locale $locale = null, atoum\adapter $adapter = null)
{
@@ -247,6 +247,18 @@ public function help(array $options = array())
return $this;
}
+ public function includeFile($path)
+ {
+ include_once($path);
+
+ if (in_array(realpath((string) $path), get_included_files(), true) === false)
+ {
+ throw new exceptions\logic\invalidArgument(sprintf($this->getLocale()->_('Unable to include \'%s\''), $path));
+ }
+
+ return $this;
+ }
+
public function runFile($path)
{
return $this->includeFile($path);
@@ -278,19 +290,19 @@ public function testIt()
return $this->runDirectory(atoum\directory . '/tests/units/classes');
}
- public static function getShutdownInstance()
+ public static function getAutorunner()
{
- return self::$shutdownInstance;
+ return self::$autorunner;
}
- public static function runAtShutdown($name)
+ public static function autorun($name)
{
- if (self::$shutdownInstance !== null)
+ if (self::$autorunner !== null)
{
- throw new exceptions\runtime('Unable to run \'' . $name . '\' at shutdown because \'' . self::$shutdownInstance->getName() . '\' will be run at shutdown');
+ throw new exceptions\runtime('Unable to autorun \'' . $name . '\' because \'' . self::$autorunner->getName() . '\' is already set as autorunner');
}
- $runnerScript = self::$shutdownInstance = new static($name);
+ $runnerScript = self::$autorunner = new static($name);
register_shutdown_function(function() use ($runnerScript) {
set_error_handler(function($error, $message, $file, $line) use ($runnerScript) {
@@ -322,18 +334,6 @@ public static function runAtShutdown($name)
return $runnerScript;
}
-
- protected function includeFile($path)
- {
- @include_once($path);
-
- if (in_array(realpath((string) $path), get_included_files(), true) === false)
- {
- throw new exceptions\logic\invalidArgument(sprintf($this->getLocale()->_('Unable to include \'%s\''), $path));
- }
-
- return $this;
- }
}
?>
View
2  ressources/configurations/runner/builder.php.dist
@@ -25,6 +25,6 @@ $builderReport
->addWriter($mailWriter)
;
-$runner->addReport($builderReport);
+atoum\scripts\runner::getAutorunner()->getRunner()->addReport($builderReport);
?>
View
2  ressources/configurations/runner/cli.php.dist
@@ -18,6 +18,6 @@ Generate a CLI report.
$cliReport = new atoum\reports\realtime\cli();
$cliReport->addWriter($stdOutWriter);
-$runner->addReport($cliReport);
+atoum\scripts\runner::getAutorunner()->getRunner()->addReport($cliReport);
?>
View
2  ressources/configurations/runner/coverage.php.dist
@@ -25,6 +25,6 @@ $cliReport
->addRunnerField($coverageField, array(atoum\runner::runStop))
;
-$runner->addReport($cliReport);
+atoum\scripts\runner::getAutorunner()->getRunner()->addReport($cliReport);
?>
View
2  ressources/configurations/runner/vim.php.dist
@@ -17,6 +17,6 @@ Generate a CLI report.
$vimReport = new atoum\reports\asynchronous\vim();
$vimReport->addWriter($stdOutWriter);
-$runner->addReport($vimReport);
+atoum\scripts\runner::getAutorunner()->getRunner()->addReport($vimReport);
?>
View
2  scripts/phar/resources/stub.php
@@ -10,7 +10,7 @@
require_once('phar://' . __FILE__ . '/classes/autoloader.php');
- phar\stub::runAtShutdown(__FILE__);
+ phar\stub::autorun(__FILE__);
}
__HALT_COMPILER();
View
2  scripts/runner.php
@@ -10,7 +10,7 @@
require_once(__DIR__ . '/../classes/autoloader.php');
- scripts\runner::runAtShutdown(__FILE__);
+ scripts\runner::autorun(__FILE__);
}
?>
View
80 tests/units/classes/report/fields/runner/coverage/html.php
@@ -6,7 +6,10 @@
\mageekguy\atoum,
\mageekguy\atoum\test,
\mageekguy\atoum\mock,
+ \mageekguy\atoum\locale,
\mageekguy\atoum\template,
+ \mageekguy\atoum\cli\prompt,
+ \mageekguy\atoum\cli\colorizer,
\mageekguy\atoum\report\fields\runner\coverage
;
@@ -18,39 +21,55 @@ public function testClass()
{
$this->assert
->testedClass->isSubclassOf('\mageekguy\atoum\report\fields\runner\coverage\cli')
- ->string(coverage\html::defaultPrompt)->isEqualTo('> ')
- ->string(coverage\html::defaultAlternatePrompt)->isEqualTo('=> ')
;
}
public function test__construct()
{
- $field = new coverage\html($projectName = uniqid(), $templatesDirectory = uniqid(), $destinationDirectory = uniqid());
+ $field = new coverage\html($projectName = uniqid(), $destinationDirectory = uniqid());
$this->assert
->string($field->getProjectName())->isEqualTo($projectName)
- ->string($field->getTemplatesDirectory())->isEqualTo($templatesDirectory)
->string($field->getDestinationDirectory())->isEqualTo($destinationDirectory)
- ->object($field->getTemplateParser())->isInstanceOf('\mageekguy\atoum\template\parser')
- ->object($field->getLocale())->isInstanceOf('\mageekguy\atoum\locale')
+ ->string($field->getTemplatesDirectory())->isEqualTo(atoum\directory . '/ressources/templates/coverage')
+ ->object($field->getPrompt())->isEqualTo(new prompt())
+ ->object($field->getTitleColorizer())->isEqualTo(new colorizer())
+ ->object($field->getCoverageColorizer())->isEqualTo(new colorizer())
+ ->object($field->getUrlPrompt())->isEqualTo(new prompt())
+ ->object($field->getUrlColorizer())->isEqualTo(new colorizer())
->object($field->getAdapter())->isInstanceOf('\mageekguy\atoum\adapter')
- ->string($field->getPrompt())->isEqualTo(coverage\html::defaultPrompt)
- ->string($field->getAlternatePrompt())->isEqualTo(coverage\html::defaultAlternatePrompt)
+ ->object($field->getLocale())->isEqualTo(new locale())
+ ->object($field->getTemplateParser())->isInstanceOf('\mageekguy\atoum\template\parser')
->variable($field->getCoverage())->isNull()
->array($field->getSrcDirectories())->isEmpty()
;
- $field = new coverage\html($projectName = uniqid(), $templatesDirectory = uniqid(), $destinationDirectory = uniqid(), $templateParser = new template\parser(), $adapter = new atoum\adapter(), $locale = new atoum\locale(), $prompt = uniqid(), $alternatePrompt = uniqid());
+ $field = new coverage\html(
+ $projectName = uniqid(),
+ $destinationDirectory = uniqid(),
+ $templatesDirectory = uniqid(),
+ $prompt = new prompt(),
+ $titleColorizer = new colorizer(),
+ $coverageColorizer = new colorizer(),
+ $urlPrompt = new prompt(),
+ $urlColorizer = new colorizer(),
+ $templateParser = new template\parser(),
+ $adapter = new atoum\adapter(),
+ $locale = new atoum\locale()
+ );
$this->assert
->string($field->getProjectName())->isEqualTo($projectName)
- ->string($field->getTemplatesDirectory())->isEqualTo($templatesDirectory)
->string($field->getDestinationDirectory())->isEqualTo($destinationDirectory)
- ->object($field->getTemplateParser())->isEqualTo($templateParser)
+ ->string($field->getTemplatesDirectory())->isEqualTo($templatesDirectory)
+ ->object($field->getPrompt())->isIdenticalTo($prompt)
+ ->object($field->getTitleColorizer())->isIdenticalTo($titleColorizer)
+ ->object($field->getCoverageColorizer())->isIdenticalTo($coverageColorizer)
+ ->object($field->getUrlPrompt())->isIdenticalTo($urlPrompt)
+ ->object($field->getUrlColorizer())->isIdenticalTo($urlColorizer)
->object($field->getAdapter())->isIdenticalTo($adapter)
->object($field->getLocale())->isIdenticalTo($locale)
- ->string($field->getPrompt())->isEqualTo($prompt)
- ->string($field->getAlternatePrompt())->isEqualTo($alternatePrompt)
+ ->object($field->getTemplateParser())->isIdenticalTo($templateParser)
->variable($field->getCoverage())->isNull()
->array($field->getSrcDirectories())->isEmpty()
;
@@ -66,15 +85,23 @@ public function testSetAdapter()
;
}
- public function testSetAlternatePrompt()
+ public function testSetUrlPrompt()
{
- $field = new coverage\html($projectName = uniqid(), $templatesDirectory = uniqid(), $destinationDirectory = uniqid());
+ $field = new coverage\html($projectName = uniqid(), $destinationDirectory = uniqid());
$this->assert
- ->object($field->setAlternatePrompt($alternatePrompt = uniqid()))->isIdenticalTo($field)
- ->string($field->getAlternatePrompt())->isIdenticalTo($alternatePrompt)
- ->object($field->setAlternatePrompt($alternatePrompt = rand(1, PHP_INT_MAX)))->isIdenticalTo($field)
- ->string($field->getAlternatePrompt())->isIdenticalTo((string) $alternatePrompt)
+ ->object($field->setUrlPrompt($urlPrompt = new prompt()))->isIdenticalTo($field)
+ ->object($field->getUrlPrompt())->isIdenticalTo($urlPrompt)
+ ;
+ }
+
+ public function testSetUrlColorizer()
+ {
+ $field = new coverage\html($projectName = uniqid(), $destinationDirectory = uniqid());
+
+ $this->assert
+ ->object($field->setUrlColorizer($urlColorizer = new colorizer()))->isIdenticalTo($field)
+ ->object($field->getUrlColorizer())->isIdenticalTo($urlColorizer)
;
}
@@ -126,7 +153,7 @@ public function testSetProjectName()
public function testGetDestinationDirectoryIterator()
{
- $field = new coverage\html(uniqid(), uniqid(), __DIR__);
+ $field = new coverage\html(uniqid(), __DIR__);
$this->assert
->object($recursiveIteratorIterator = $field->getDestinationDirectoryIterator())->isInstanceOf('\recursiveIteratorIterator')
@@ -189,7 +216,7 @@ public function testCleanDestinationDirectory()
->mock('\splFileInfo')
;
- $field = new mock\mageekguy\atoum\report\fields\runner\coverage\html(uniqid(), uniqid(), $destinationDirectoryPath = uniqid(), null, $adapter = new test\adapter());
+ $field = new mock\mageekguy\atoum\report\fields\runner\coverage\html(uniqid(), $destinationDirectoryPath = uniqid(), uniqid(), null, null, null, null, null, null, $adapter = new test\adapter());
$adapter->rmdir = function() {};
$adapter->unlink = function() {};
@@ -371,7 +398,7 @@ public function test__toString()
$field = new coverage\html(uniqid(), uniqid(), uniqid());
$this->assert
- ->castToString($field)->isEqualTo('> Code coverage: unknown.' . PHP_EOL)
+ ->castToString($field)->isEqualTo('Code coverage: unknown.' . PHP_EOL)
;
$this
@@ -535,7 +562,12 @@ public function test__toString()
$templateParser = new mock\mageekguy\atoum\template\parser();
- $field = new mock\mageekguy\atoum\report\fields\runner\coverage\html($projectName = uniqid(), $templatesDirectory = uniqid(), $destinationDirectory = uniqid(), $templateParser, $adapter = new test\adapter());
+ $field = new mock\mageekguy\atoum\report\fields\runner\coverage\html($projectName = uniqid(), $destinationDirectory = uniqid(), $templatesDirectory = uniqid());
+ $field
+ ->setTemplateParser($templateParser)
+ ->setAdapter($adapter = new test\adapter())
+ ;
+
$fieldController = $field->getMockController();
$fieldController->cleanDestinationDirectory = function() {};
$fieldController->getReflectionClass = $reflectedClass;
@@ -582,7 +614,7 @@ public function test__toString()
$this->assert
->object($field->getCoverage())->isIdenticalTo($coverage)
- ->castToString($field)->isIdenticalTo('> ' . sprintf($field->getLocale()->_('Code coverage: %3.2f%%.'), round($coverageValue * 100, 2)) . PHP_EOL . '=> Details of code coverage are available at ' . $rootUrl . '/.' . PHP_EOL)
+ ->castToString($field)->isIdenticalTo(sprintf($field->getLocale()->_('Code coverage: %3.2f%%.'), round($coverageValue * 100, 2)) . PHP_EOL . 'Details of code coverage are available at ' . $rootUrl . '/.' . PHP_EOL)
->mock($coverage)->call('count')
->mock($field)
->call('cleanDestinationDirectory')
Please sign in to comment.
Something went wrong with that request. Please try again.