Skip to content

Instantly share code, notes, and snippets.

@jubianchi
Forked from anonymous/.atoum.php
Created December 11, 2012 22:33
Show Gist options
  • Save jubianchi/4262957 to your computer and use it in GitHub Desktop.
Save jubianchi/4262957 to your computer and use it in GitHub Desktop.
<?php
use \mageekguy\atoum;
function colorized() {
$color = -1;
if(false !== ($term = getenv('TERM'))) {
if(preg_match('/\d+/', $term, $matches) > 0) {
$color = $matches[0];
}
}
if($color < 0) {
$color = system('tput colors');
}
return ($color >= 256);
}
define('COVERAGE_TITLE', 'atoum');
define('COVERAGE_DIRECTORY', __DIR__ . '/coverage');
define('COVERAGE_WEB_PATH', 'file://' . COVERAGE_DIRECTORY);
define('COLORIZED', colorized());
if(false === is_dir(COVERAGE_DIRECTORY))
{
mkdir(COVERAGE_DIRECTORY, 0777, true);
}
$stdOutWriter = new atoum\writers\std\out();
$cliReport = new atoum\reports\realtime\cli();
$cliReport->addWriter($stdOutWriter);
$coverageField = new atoum\report\fields\runner\coverage\html(COVERAGE_TITLE, COVERAGE_DIRECTORY);
$coverageField->setRootUrl(COVERAGE_WEB_PATH);
$cliReport->addField($coverageField, array(atoum\runner::runStop));
if(COLORIZED)
{
$cliReport->addField(new atoum\report\fields\runner\atoum\logo());
$cliReport->addField(new atoum\report\fields\runner\result\logo());
}
$runner->addReport($cliReport);
$runner->setBootstrapFile(__DIR__ . '/tests/bootstrap.php');
$script->addTestAllDirectory(__DIR__ . '/tests');
<?php
require_once __DIR__ . '/../vendor/autoload.php';
require_once __DIR__ . '/../vendor/atoum/atoum/scripts/runner.php';
<?php
namespace tests\units\jubianchi\PhpSwitch\Console\Command;
use mageekguy\atoum;
require_once __DIR__ . '/../bootstrap.php';
class Foobar extends atoum\test
{
}
@jubianchi
Copy link
Author

$ bin/atoum --test-all --loop
$ bin/atoum -d tests/units --loop
$ bin/atoum -f tests/units/Foobar.php --loop
$ php tests/units/Foobar.php --loop

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment