Example #1
0
 protected function setArgumentHandlers()
 {
     parent::setArgumentHandlers()->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->help();
     }, array('-h', '--help'), null, $this->locale->_('Display this help'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->version();
     }, array('-v', '--version'), null, $this->locale->_('Display version'))->addArgumentHandler(function ($script, $argument, $path) {
         if (sizeof($path) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->getRunner()->setPhpPath(current($path));
     }, array('-p', '--php'), '<path/to/php/binary>', $this->locale->_('Path to PHP binary which must be used to run tests'))->addArgumentHandler(function ($script, $argument, $defaultReportTitle) {
         if (sizeof($defaultReportTitle) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->getRunner()->setDefaultReportTitle(current($defaultReportTitle));
     }, array('-drt', '--default-report-title'), '<string>', $this->locale->_('Define default report title with <string>'))->addArgumentHandler(function ($script, $argument, $files) {
         if (sizeof($files) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         foreach ($files as $path) {
             try {
                 $script->useConfigFile($path);
             } catch (includer\exception $exception) {
                 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Configuration file \'%s\' does not exist'), $path));
             }
         }
     }, array('-c', '--configurations'), '<file>...', $this->locale->_('Use all configuration files <file>'), 1)->addArgumentHandler(function ($script, $argument, $file) {
         if (sizeof($file) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setScoreFile(current($file));
     }, array('-sf', '--score-file'), '<file>', $this->locale->_('Save score in file <file>'))->addArgumentHandler(function ($script, $argument, $maxChildrenNumber) {
         if (sizeof($maxChildrenNumber) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->getRunner()->setMaxChildrenNumber(current($maxChildrenNumber));
     }, array('-mcn', '--max-children-number'), '<integer>', $this->locale->_('Maximum number of sub-processus which will be run simultaneously'))->addArgumentHandler(function ($script, $argument, $empty) {
         if ($empty) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->getRunner()->disableCodeCoverage();
     }, array('-ncc', '--no-code-coverage'), null, $this->locale->_('Disable code coverage'))->addArgumentHandler(function ($script, $argument, $directories) {
         if (sizeof($directories) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         foreach ($directories as $directory) {
             $script->getRunner()->getCoverage()->excludeDirectory($directory);
         }
     }, array('-nccid', '--no-code-coverage-in-directories'), '<directory>...', $this->locale->_('Disable code coverage in directories <directory>'))->addArgumentHandler(function ($script, $argument, $namespaces) {
         if (sizeof($namespaces) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         foreach ($namespaces as $namespace) {
             $script->getRunner()->getCoverage()->excludeNamespace($namespace);
         }
     }, array('-nccfns', '--no-code-coverage-for-namespaces'), '<namespace>...', $this->locale->_('Disable code coverage for namespaces <namespace>'))->addArgumentHandler(function ($script, $argument, $classes) {
         if (sizeof($classes) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         foreach ($classes as $class) {
             $script->getRunner()->getCoverage()->excludeClass($class);
         }
     }, array('-nccfc', '--no-code-coverage-for-classes'), '<class>...', $this->locale->_('Disable code coverage for classes <class>'))->addArgumentHandler(function ($script, $argument, $files) {
         if (sizeof($files) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $runner = $script->getRunner();
         foreach ($files as $path) {
             $runner->addTest($path);
         }
     }, array('-f', '--files'), '<file>...', $this->locale->_('Execute all unit test files <file>'))->addArgumentHandler(function ($script, $argument, $directories) {
         if (sizeof($directories) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $runner = $script->getRunner();
         foreach ($directories as $directory) {
             $runner->addTestsFromDirectory($directory);
         }
     }, array('-d', '--directories'), '<directory>...', $this->locale->_('Execute unit test files in all <directory>'))->addArgumentHandler(function ($script, $argument, $extensions) {
         if (sizeof($extensions) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->getRunner()->getTestDirectoryIterator()->acceptExtensions($extensions);
     }, array('-tfe', '--test-file-extensions'), '<extension>...', $this->locale->_('Execute unit test files with one of extensions <extension>'))->addArgumentHandler(function ($script, $argument, $patterns) {
         if (sizeof($patterns) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $runner = $script->getRunner();
         foreach ($patterns as $pattern) {
             $runner->addTestsFromPattern($pattern);
         }
     }, array('-g', '--glob'), '<pattern>...', $this->locale->_('Execute unit test files which match <pattern>'))->addArgumentHandler(function ($script, $argument, $tags) {
         if (sizeof($tags) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->testTags($tags);
     }, array('-t', '--tags'), '<tag>...', $this->locale->_('Execute only unit test with tags <tag>'))->addArgumentHandler(function ($script, $argument, $methods) {
         if (sizeof($methods) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         foreach ($methods as $method) {
             $method = explode('::', $method);
             if (sizeof($method) != 2) {
                 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
             }
             $script->testMethod($method[0], $method[1]);
         }
     }, array('-m', '--methods'), '<class::method>...', $this->locale->_('Execute all <class::method>, * may be used as wildcard for class name or method name'))->addArgumentHandler(function ($script, $argument, $namespaces) {
         if (sizeof($namespaces) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->testNamespaces($namespaces);
     }, array('-ns', '--namespaces'), '<namespace>...', $this->locale->_('Execute all classes in all namespaces <namespace>'))->addArgumentHandler(function ($script, $argument, $values) {
         if ($values) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->enableLoopMode();
     }, array('-l', '--loop'), null, $this->locale->_('Execute tests in an infinite loop'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->disableLoopMode();
     }, array('--disable-loop-mode'), null, null, 3)->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->testIt();
     }, array('--test-it'), null, $this->locale->_('Execute atoum unit tests'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $runner = $script->getRunner();
         foreach ($script->getTestAllDirectories() as $directory) {
             $runner->addTestsFromDirectory($directory);
         }
     }, array('--test-all'), null, $this->locale->_('Execute unit tests in directories defined via $script->addTestAllDirectory(\'path/to/directory\') in a configuration file'))->addArgumentHandler(function ($script, $argument, $values) {
         if ($values) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         \mageekguy\atoum\cli::forceTerminal();
     }, array('-ft', '--force-terminal'), null, $this->locale->_('Force output as in terminal'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->getRunner()->setBootstrapFile($values[0]);
     }, array('-bf', '--bootstrap-file'), '<file>', $this->locale->_('Include <file> before executing each test method'), 2)->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $report = new atoum\reports\realtime\cli\light();
         $report->addWriter($script->getOutputWriter());
         $script->getRunner()->addReport($report);
     }, array('-ulr', '--use-light-report'), null, $this->locale->_('Use "light" CLI report'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->getRunner()->enableDebugMode();
     }, array('--debug'), null, $this->locale->_('Enable debug mode'));
     return $this;
 }
Example #2
0
 protected function setArgumentHandlers()
 {
     parent::setArgumentHandlers()->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->version();
     }, array('-v', '--version'), null, $this->locale->_('Display version'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->resetVerbosityLevel();
         $verbosityLevel = substr_count($argument, '+');
         while ($verbosityLevel--) {
             $script->increaseVerbosityLevel();
         }
     }, array('+verbose', '++verbose'), null, $this->locale->_('Enable verbose mode'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) === 0) {
             $values = array(getcwd());
         }
         $script->init(current($values));
     }, array('--init'), '<path/to/directory>', $this->locale->_('Create configuration and bootstrap files in <path/to/directory> (Optional, default: %s)', $this->getDirectory()))->addArgumentHandler(function ($script, $argument, $path) {
         if (sizeof($path) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setPhpPath(reset($path));
     }, array('-p', '--php'), '<path/to/php/binary>', $this->locale->_('Path to PHP binary which must be used to run tests'))->addArgumentHandler(function ($script, $argument, $defaultReportTitle) {
         if (sizeof($defaultReportTitle) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setDefaultReportTitle(reset($defaultReportTitle));
     }, array('-drt', '--default-report-title'), '<string>', $this->locale->_('Define default report title with <string>'))->addArgumentHandler(function ($script, $argument, $file) {
         if (sizeof($file) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setScoreFile(reset($file));
     }, array('-sf', '--score-file'), '<file>', $this->locale->_('Save score in file <file>'))->addArgumentHandler(function ($script, $argument, $maxChildrenNumber) {
         if (sizeof($maxChildrenNumber) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setMaxChildrenNumber(reset($maxChildrenNumber));
     }, array('-mcn', '--max-children-number'), '<integer>', $this->locale->_('Maximum number of sub-processus which will be run simultaneously'))->addArgumentHandler(function ($script, $argument, $empty) {
         if ($empty) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->disableCodeCoverage();
     }, array('-ncc', '--no-code-coverage'), null, $this->locale->_('Disable code coverage'))->addArgumentHandler(function ($script, $argument, $directories) {
         if (sizeof($directories) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->excludeDirectoriesFromCoverage($directories);
     }, array('-nccid', '--no-code-coverage-in-directories'), '<directory>...', $this->locale->_('Disable code coverage in directories <directory>'))->addArgumentHandler(function ($script, $argument, $namespaces) {
         if (sizeof($namespaces) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->excludeNamespacesFromCoverage($namespaces);
     }, array('-nccfns', '--no-code-coverage-for-namespaces'), '<namespace>...', $this->locale->_('Disable code coverage for namespaces <namespace>'))->addArgumentHandler(function ($script, $argument, $classes) {
         if (sizeof($classes) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->excludeClassesFromCoverage($classes);
     }, array('-nccfc', '--no-code-coverage-for-classes'), '<class>...', $this->locale->_('Disable code coverage for classes <class>'))->addArgumentHandler(function ($script, $argument, $classes) {
         if (sizeof($classes) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->excludeMethodsFromCoverage($classes);
     }, array('-nccfm', '--no-code-coverage-for-methods'), '<method>...', $this->locale->_('Disable code coverage for methods <method>'))->addArgumentHandler(function ($script, $argument, $empty) {
         if ($empty) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->enableBranchesAndPathsCoverage();
     }, array('-ebpc', '--enable-branch-and-path-coverage'), null, $this->locale->_('Enable branch and path coverage'))->addArgumentHandler(function ($script, $argument, $files) {
         if (sizeof($files) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->addTests($files);
     }, array('-f', '--files'), '<file>...', $this->locale->_('Execute all unit test files <file>'))->addArgumentHandler(function ($script, $argument, $directories) {
         if (sizeof($directories) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->addTestsFromDirectories($directories);
     }, array('-d', '--directories'), '<directory>...', $this->locale->_('Execute unit test files in all <directory>'))->addArgumentHandler(function ($script, $argument, $extensions) {
         if (sizeof($extensions) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->acceptTestFileExtensions($extensions);
     }, array('-tfe', '--test-file-extensions'), '<extension>...', $this->locale->_('Execute unit test files with one of extensions <extension>'))->addArgumentHandler(function ($script, $argument, $patterns) {
         if (sizeof($patterns) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->addTestsFromPatterns($patterns);
     }, array('-g', '--glob'), '<pattern>...', $this->locale->_('Execute unit test files which match <pattern>'))->addArgumentHandler(function ($script, $argument, $tags) {
         if (sizeof($tags) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->testTags($tags);
     }, array('-t', '--tags'), '<tag>...', $this->locale->_('Execute only unit test with tags <tag>'))->addArgumentHandler(function ($script, $argument, $methods) {
         if (sizeof($methods) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         foreach ($methods as $method) {
             $method = explode('::', $method);
             if (sizeof($method) != 2) {
                 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
             }
             $script->testMethod($method[0], $method[1]);
         }
     }, array('-m', '--methods'), '<class::method>...', $this->locale->_('Execute all <class::method>, * may be used as wildcard for class name or method name'))->addArgumentHandler(function ($script, $argument, $namespaces) {
         if (sizeof($namespaces) <= 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->testNamespaces($namespaces);
     }, array('-ns', '--namespaces'), '<namespace>...', $this->locale->_('Execute all classes in all namespaces <namespace>'))->addArgumentHandler(function ($script, $argument, $values) {
         if ($values) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->enableLoopMode();
     }, array('-l', '--loop'), null, $this->locale->_('Execute tests in an infinite loop'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->disableLoopMode();
     }, array('--disable-loop-mode'), null, null, 3)->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) !== 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->testIt();
     }, array('--test-it'), null, $this->locale->_('Execute atoum unit tests'))->addArgumentHandler(function ($script, $argument, $values) {
         $script->writeError('--test-all argument is deprecated, please do $runner->addTestsFromDirectory(\'path/to/default/tests/directory\') in a configuration file and use atoum without any argument instead');
     }, array('--test-all'), null, $this->locale->_('DEPRECATED, please do $runner->addTestsFromDirectory(\'path/to/default/tests/directory\') in a configuration file and use atoum without any argument instead'))->addArgumentHandler(function ($script, $argument, $values) {
         if ($values) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         \mageekguy\atoum\cli::forceTerminal();
     }, array('-ft', '--force-terminal'), null, $this->locale->_('Force output as in terminal'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setBootstrapFile($values[0]);
     }, array('-bf', '--bootstrap-file'), '<file>', $this->locale->_('Include <file> before executing each test method'), 2)->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $lightReport = new atoum\reports\realtime\cli\light();
         $lightReport->addWriter($script->getOutputWriter());
         $script->setReport($lightReport);
     }, array('-ulr', '--use-light-report'), null, $this->locale->_('Use "light" CLI report'), PHP_INT_MAX)->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $tapReport = new atoum\reports\realtime\tap();
         $tapReport->addWriter($script->getOutputWriter());
         $script->setReport($tapReport);
     }, array('-utr', '--use-tap-report'), null, $this->locale->_('Use TAP report'), PHP_INT_MAX)->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 0) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->enableDebugMode();
     }, array('--debug'), null, $this->locale->_('Enable debug mode'))->addArgumentHandler(function ($script, $argument, $values) {
         if (sizeof($values) != 1) {
             throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));
         }
         $script->setXdebugConfig($values[0]);
     }, array('-xc', '--xdebug-config'), null, $this->locale->_('Set XDEBUG_CONFIG variable'))->addArgumentHandler(function ($script, $argument, $values) {
         $script->failIfVoidMethods();
     }, array('-fivm', '--fail-if-void-methods'), null, $this->locale->_('Make the test suite fail if there is at least one void test method'))->addArgumentHandler(function ($script, $argument, $values) {
         $script->failIfSkippedMethods();
     }, array('-fism', '--fail-if-skipped-methods'), null, $this->locale->_('Make the test suite fail if there is at least one skipped test method'));
     $this->setDefaultArgumentHandler(function ($script, $argument) {
         try {
             $script->getRunner()->addTest($argument);
         } catch (\exception $exception) {
             return false;
         }
         return true;
     });
     return $this;
 }
Example #3
0
 public function test__construct()
 {
     $this->define($eventField = new fields\runner\event\cli())->define($resultField = new fields\runner\result\cli())->define($resultField->setSuccessColorizer(new colorizer('0;37', '42'))->setFailureColorizer(new colorizer('0;37', '41')))->define($failuresField = new fields\runner\failures\cli())->define($failuresField->setTitlePrompt(new prompt('> '))->setTitleColorizer(new colorizer('1;36'))->setMethodPrompt(new prompt('=> ', new colorizer('1;36'))))->define($outputsField = new fields\runner\outputs\cli())->define($outputsField->setTitlePrompt(new prompt('> '))->setTitleColorizer(new colorizer('1;36'))->setMethodPrompt(new prompt('=> ', new colorizer('1;36'))))->define($errorsField = new fields\runner\errors\cli())->define($errorsField->setTitlePrompt(new prompt('> '))->setTitleColorizer(new colorizer('0;33'))->setMethodPrompt(new prompt('=> ', new colorizer('0;33')))->setErrorPrompt(new prompt('==> ', new colorizer('0;33'))))->define($exceptionsField = new fields\runner\exceptions\cli())->define($exceptionsField->setTitlePrompt(new prompt('> '))->setTitleColorizer(new colorizer('0;35'))->setMethodPrompt(new prompt('=> ', new colorizer('0;35')))->setExceptionPrompt(new prompt('==> ', new colorizer('0;35'))))->define($uncompletedTestField = new fields\runner\tests\uncompleted\cli())->define($uncompletedTestField->setTitlePrompt(new prompt('> '))->setTitleColorizer(new colorizer('0;37'))->setMethodPrompt(new prompt('=> ', new colorizer('0;37')))->setOutputPrompt(new prompt('==> ', new colorizer('0;37'))))->define($voidTestField = new fields\runner\tests\void\cli())->define($voidTestField->setTitlePrompt(new prompt('> '))->setTitleColorizer(new colorizer('0;34'))->setMethodPrompt(new prompt('=> ', new colorizer('0;34'))))->define($skippedTestField = new fields\runner\tests\skipped\cli())->and($skippedTestField->setTitlePrompt(new prompt('> '))->setTitleColorizer(new colorizer('0;90'))->setMethodPrompt(new prompt('=> ', new colorizer('0;90'))))->if($report = new testedClass())->then->object($report->getLocale())->isEqualTo(new atoum\locale())->object($report->getAdapter())->isEqualTo(new atoum\adapter())->array($report->getFields())->isEqualTo(array($eventField, $resultField, $failuresField, $outputsField, $errorsField, $exceptionsField, $uncompletedTestField, $voidTestField, $skippedTestField));
 }