public function __construct(atoum\configurator $configurator = null)
 {
     if ($configurator) {
         $parser = $configurator->getScript()->getArgumentsParser();
         $handler = function ($script, $argument, $values) {
             $script->getRunner()->addTestsFromDirectory(dirname(__DIR__) . '/tests/units/classes');
         };
         $parser->addHandler($handler, array('--test-ext'))->addHandler($handler, array('--test-it'));
     }
 }
Exemple #2
0
 public function test__call()
 {
     $this->if($runner = new \mock\mageekguy\atoum\runner())->and($runner->getMockController()->setBootstrapFile = function () {
     })->and($script = new \mock\mageekguy\atoum\scripts\runner(uniqid()))->and($this->calling($script)->addDefaultReport = $report = new \mock\mageekguy\atoum\report())->and($script->setRunner($runner))->and($configurator = new atoum\configurator($script))->then->object($configurator->scoreFile($scoreFile = uniqid()))->isIdenticalTo($configurator)->mock($script)->call('setScoreFile')->withArguments($scoreFile)->once()->object($configurator->bf($bootstrapFile = uniqid()))->isIdenticalTo($configurator)->mock($runner)->call('setBootstrapFile')->withArguments($bootstrapFile)->once()->object($configurator->bootstrapFile($bootstrapFile = uniqid()))->isIdenticalTo($configurator)->mock($runner)->call('setBootstrapFile')->withArguments($bootstrapFile)->once()->object($configurator->setScoreFile($scoreFile = uniqid()))->isIdenticalTo($configurator)->mock($script)->call('setScoreFile')->withArguments($scoreFile)->once()->object($configurator->addDefaultReport())->isIdenticalTo($report)->mock($script)->call('addDefaultReport')->once()->object($configurator->noCodeCoverageForNamespaces($namespaces = array('foo', 'bar')))->isIdenticalTo($configurator)->mock($script)->call('excludeNamespacesFromCoverage')->withArguments($namespaces)->once()->object($configurator->noCodeCoverageForNamespaces('foo', 'bar'))->isIdenticalTo($configurator)->mock($script)->call('excludeNamespacesFromCoverage')->withArguments($namespaces)->twice()->exception(function () use($configurator, &$method) {
         $configurator->{$method = uniqid()}();
     })->isInstanceOf('mageekguy\\atoum\\exceptions\\runtime\\unexpectedValue')->hasMessage('Method \'' . $method . '\' is unavailable');
 }
Exemple #3
0
 public function __construct(atoum\configurator $configurator = null)
 {
     if ($configurator) {
         $configurator->getScript()->setDefaultReportFactory(function ($script) {
             $report = new reports\realtime\cli();
             $report->addWriter($script->getOutputWriter());
             return $report;
         });
         $parser = $configurator->getScript()->getArgumentsParser();
         $handler = function ($script, $argument, $values) {
             $script->getRunner()->addTestsFromDirectory(dirname(__DIR__) . '/specs/units/classes');
         };
         $parser->addHandler($handler, array('--test-ext'))->addHandler($handler, array('--test-it'));
     }
 }
 /**
  * @param atoum\configurator $configurator
  */
 public function __construct(atoum\configurator $configurator = null)
 {
     $this->configuration = $configuration = new configuration();
     if ($configurator) {
         $script = $configurator->getScript();
         $testHandler = function ($script, $argument, $values) {
             $script->getRunner()->addTestsFromDirectory(dirname(__DIR__) . '/tests/units/classes');
         };
         $script->addArgumentHandler($testHandler, array('--test-ext'))->addArgumentHandler($testHandler, array('--test-it'));
         $autoLoopHandler = function (\mageekguy\atoum\scripts\runner $script, $argument, $values) use($configuration) {
             $script->enableLoopMode();
             $watcherStrategy = new scripts\runner\loopers\watcher($script);
             $watcherStrategy->setConfiguration($configuration);
             $script->setLooper($watcherStrategy);
         };
         $script->addArgumentHandler($autoLoopHandler, array('--autoloop'), null, $script->getLocale()->_('Automaticly relaunch tests on file change (implies --loop)'));
     }
 }
Exemple #5
0
 /**
  * @param atoum\configurator $configurator
  */
 public function __construct(atoum\configurator $configurator = null)
 {
     if ($configurator) {
         $script = $configurator->getScript();
         $extension = $this;
         $handler = function (atoum\scripts\runner $script, $argument, $values) use($extension) {
             if (sizeof($values) != 1) {
                 throw new invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
             }
             $value = array_shift($values);
             if (0 === strlen(trim($value))) {
                 throw new invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
             }
             $extension->setRule($value);
         };
         $testHandler = function ($script, $argument, $values) {
             $script->getRunner()->addTestsFromDirectory(dirname(__DIR__) . '/tests/units/classes');
         };
         $script->addArgumentHandler($testHandler, array('--test-ext'))->addArgumentHandler($testHandler, array('--test-it'))->addArgumentHandler($handler, array('--filter'), null, $script->getLocale()->_('Filters tests to execute. For example \'not("featureA" in tags) and namespace = "foo\\bar"\''));
     }
 }