Skip to content

Commit

Permalink
add a way to create editions of atoum
Browse files Browse the repository at this point in the history
  • Loading branch information
agallou committed Jun 19, 2016
1 parent c2d7902 commit cd3f6cc
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
17 changes: 17 additions & 0 deletions classes/runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,23 @@ public function addExtension(extension $extension, extension\configuration $conf
return $this;
}

public function getExtension($classname)
{
$extensions = array();
foreach ($this->getExtensions() as $extension) {
if (get_class($extension) != $classname) {
continue;
}
$extensions[] = $extension;
}

if (1 != count($extensions)) {
throw new \Exception(sprintf("Extension '%s' Not found", $classname));
}

return array_shift($extensions);
}

public static function isIgnored(test $test, array $namespaces, array $tags)
{
$isIgnored = $test->isIgnored();
Expand Down
20 changes: 20 additions & 0 deletions classes/scripts/runner.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class runner extends atoum\script\configurable

protected static $autorunner = true;
protected static $runnerFile = null;
protected static $configurationCallables = array();

public function __construct($name, atoum\adapter $adapter = null, atoum\scripts\runner\looper $looper = null)
{
Expand Down Expand Up @@ -244,6 +245,16 @@ public function useConfigFile($path)
return $this->includeConfigFile($path, function($path) use ($script, $runner) { include_once($path); });
}

public function useConfigCallable(callable $callback)
{
$script = call_user_func($this->configuratorFactory, $this);
$runner = $this->runner;

$callback($script, $runner);

return $this;
}

public function testIt()
{
$this->runner
Expand Down Expand Up @@ -644,6 +655,10 @@ public static function enableAutorun($name)

static::$autorunner = new static($name);

foreach (static::$configurationCallables as $callable) {
static::$autorunner->useConfigCallable($callable);
}

return static::$autorunner;
}

Expand All @@ -652,6 +667,11 @@ public static function disableAutorun()
static::$autorunner = false;
}

public static function addConfigurationCallable(callable $callable)
{
static::$configurationCallables[] = $callable;
}

protected function setArgumentHandlers()
{
parent::setArgumentHandlers()
Expand Down

0 comments on commit cd3f6cc

Please sign in to comment.