How to use getClassesOf method of runner class

Best Atoum code snippet using runner.getClassesOf

runner.php

Source:runner.php Github

copy

Full Screen

...144 {145 $methods = $oldFailMethods;146 }147 }148 $this->saveScore($newScore = $this->runner->run($this->namespaces, $this->tags, self::getClassesOf($methods), $methods));149 if ($oldFailMethods)150 {151 if (sizeof(self::getFailMethods($newScore)) <= 0)152 {153 $testMethods = $this->runner->getTestMethods($this->namespaces, $this->tags, $this->methods);154 if (sizeof($testMethods) > 1 || sizeof(current($testMethods)) > 1)155 {156 $this->saveScore($this->runner->run($this->namespaces, $this->tags, self::getClassesOf($this->methods), $this->methods));157 }158 }159 }160 }161 }162 }163 catch (atoum\exception $exception)164 {165 $this->writeError($exception->getMessage());166 exit(2);167 }168 return $this;169 }170 public function version()171 {172 $this173 ->writeMessage(sprintf($this->locale->_('atoum version %s by %s (%s)'), atoum\version, atoum\author, atoum\directory) . PHP_EOL)174 ;175 $this->runTests = false;176 return $this;177 }178 public function help()179 {180 $this->runTests = false;181 return parent::help();182 }183 public function useConfigFile($path)184 {185 $script = call_user_func($this->configuratorFactory, $this);186 $runner = $this->runner;187 try188 {189 $this->includer->includePath($path, function($path) use ($script, $runner) { include_once($path); });190 }191 catch (atoum\includer\exception $exception)192 {193 throw new atoum\includer\exception(sprintf($this->getLocale()->_('Unable to find configuration file \'%s\''), $path));194 }195 return $this;196 }197 public function useDefaultConfigFiles($startDirectory = null)198 {199 if ($startDirectory === null)200 {201 $startDirectory = $this->adapter->getcwd();202 }203 foreach (self::getSubDirectoryPath($startDirectory) as $directory)204 {205 try206 {207 $this->useConfigFile($directory . self::defaultConfigFile);208 }209 catch (atoum\includer\exception $exception) {}210 }211 return $this;212 }213 public function testIt()214 {215 $this->runner->addTestsFromDirectory(atoum\directory . '/tests/units/classes');216 return $this;217 }218 public function enableLoopMode()219 {220 if ($this->loop !== null)221 {222 $this->loop = true;223 }224 return $this;225 }226 public function disableLoopMode()227 {228 $this->loop = null;229 return $this;230 }231 public function testNamespaces(array $namespaces)232 {233 foreach ($namespaces as $namespace)234 {235 $this->namespaces[] = trim($namespace, '\\');236 }237 return $this;238 }239 public function getTestedNamespaces()240 {241 return $this->namespaces;242 }243 public function testTags(array $tags)244 {245 $this->tags = $tags;246 return $this;247 }248 public function testMethod($class, $method)249 {250 $this->methods[$class][] = $method;251 return $this;252 }253 public function addDefaultReport()254 {255 $report = call_user_func($this->defaultReportFactory, $this);256 $this->addReport($report);257 return $report;258 }259 public function addReport(atoum\report $report)260 {261 $this->runner->addReport($report);262 return $this;263 }264 public function getReports()265 {266 return $this->runner->getReports();267 }268 public static function autorunMustBeEnabled()269 {270 return (static::$autorunner === true);271 }272 public static function enableAutorun($name)273 {274 static $autorunIsRegistered = false;275 if ($autorunIsRegistered === false)276 {277 $autorunner = & static::$autorunner;278 $calledClass = get_called_class();279 register_shutdown_function(function() use (& $autorunner, $calledClass) {280 if ($autorunner instanceof $calledClass)281 {282 $score = $autorunner->run()->getRunner()->getScore();283 exit($score->getFailNumber() <= 0 && $score->getErrorNumber() <= 0 && $score->getExceptionNumber() <= 0 ? 0 : 1);284 }285 }286 );287 $autorunIsRegistered = true;288 }289 if (static::$autorunner instanceof static)290 {291 throw new exceptions\runtime('Unable to autorun \'' . $name . '\' because \'' . static::$autorunner->getName() . '\' is already set as autorunner');292 }293 static::$autorunner = new static($name);294 return static::$autorunner;295 }296 public static function disableAutorun()297 {298 static::$autorunner = false;299 }300 public static function getSubDirectoryPath($directory, $directorySeparator = null)301 {302 $directorySeparator = $directorySeparator ?: DIRECTORY_SEPARATOR;303 $paths = array();304 if ($directory != '')305 {306 if ($directory == $directorySeparator)307 {308 $paths[] = $directory;309 }310 else311 {312 $directory = rtrim($directory, $directorySeparator);313 $path = '';314 foreach (explode($directorySeparator, $directory) as $subDirectory)315 {316 $path .= $subDirectory . $directorySeparator;317 $paths[] = $path;318 }319 }320 }321 return $paths;322 }323 protected function setArgumentHandlers()324 {325 parent::setArgumentHandlers()326 ->addArgumentHandler(327 function($script, $argument, $values) {328 if (sizeof($values) !== 0)329 {330 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));331 }332 $script->help();333 },334 array('-h', '--help'),335 null,336 $this->locale->_('Display this help')337 )338 ->addArgumentHandler(339 function($script, $argument, $values) {340 if (sizeof($values) !== 0)341 {342 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));343 }344 $script->version();345 },346 array('-v', '--version'),347 null,348 $this->locale->_('Display version')349 )350 ->addArgumentHandler(351 function($script, $argument, $path) {352 if (sizeof($path) != 1)353 {354 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));355 }356 $script->getRunner()->setPhpPath(current($path));357 },358 array('-p', '--php'),359 '<path/to/php/binary>',360 $this->locale->_('Path to PHP binary which must be used to run tests')361 )362 ->addArgumentHandler(363 function($script, $argument, $defaultReportTitle) {364 if (sizeof($defaultReportTitle) != 1)365 {366 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));367 }368 $script->getRunner()->setDefaultReportTitle(current($defaultReportTitle));369 },370 array('-drt', '--default-report-title'),371 '<string>',372 $this->locale->_('Define default report title with <string>')373 )374 ->addArgumentHandler(375 function($script, $argument, $files) {376 if (sizeof($files) <= 0)377 {378 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));379 }380 foreach ($files as $path)381 {382 try383 {384 $script->useConfigFile($path);385 }386 catch (includer\exception $exception)387 {388 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Configuration file \'%s\' does not exist'), $path));389 }390 }391 },392 array('-c', '--configurations'),393 '<file>...',394 $this->locale->_('Use all configuration files <file>'),395 1396 )397 ->addArgumentHandler(398 function($script, $argument, $file) {399 if (sizeof($file) <= 0)400 {401 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));402 }403 $script->setScoreFile(current($file));404 },405 array('-sf', '--score-file'),406 '<file>',407 $this->locale->_('Save score in file <file>')408 )409 ->addArgumentHandler(410 function($script, $argument, $maxChildrenNumber) {411 if (sizeof($maxChildrenNumber) != 1)412 {413 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));414 }415 $script->getRunner()->setMaxChildrenNumber(current($maxChildrenNumber));416 },417 array('-mcn', '--max-children-number'),418 '<integer>',419 $this->locale->_('Maximum number of sub-processus which will be run simultaneously')420 )421 ->addArgumentHandler(422 function($script, $argument, $empty) {423 if ($empty)424 {425 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));426 }427 $script->getRunner()->disableCodeCoverage();428 },429 array('-ncc', '--no-code-coverage'),430 null,431 $this->locale->_('Disable code coverage')432 )433 ->addArgumentHandler(434 function($script, $argument, $directories) {435 if (sizeof($directories) <= 0)436 {437 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));438 }439 foreach ($directories as $directory)440 {441 $script->getRunner()->getCoverage()->excludeDirectory($directory);442 }443 },444 array('-nccid', '--no-code-coverage-in-directories'),445 '<directory>...',446 $this->locale->_('Disable code coverage in directories <directory>')447 )448 ->addArgumentHandler(449 function($script, $argument, $namespaces) {450 if (sizeof($namespaces) <= 0)451 {452 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));453 }454 foreach ($namespaces as $namespace)455 {456 $script->getRunner()->getCoverage()->excludeNamespace($namespace);457 }458 },459 array('-nccfns', '--no-code-coverage-for-namespaces'),460 '<namespace>...',461 $this->locale->_('Disable code coverage for namespaces <namespace>')462 )463 ->addArgumentHandler(464 function($script, $argument, $classes) {465 if (sizeof($classes) <= 0)466 {467 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));468 }469 foreach ($classes as $class)470 {471 $script->getRunner()->getCoverage()->excludeClass($class);472 }473 },474 array('-nccfc', '--no-code-coverage-for-classes'),475 '<class>...',476 $this->locale->_('Disable code coverage for classes <class>')477 )478 ->addArgumentHandler(479 function($script, $argument, $files) {480 if (sizeof($files) <= 0)481 {482 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));483 }484 $runner = $script->getRunner();485 foreach ($files as $path)486 {487 $runner->addTest($path);488 }489 },490 array('-f', '--files'),491 '<file>...',492 $this->locale->_('Execute all unit test files <file>')493 )494 ->addArgumentHandler(495 function($script, $argument, $directories) {496 if (sizeof($directories) <= 0)497 {498 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));499 }500 $runner = $script->getRunner();501 foreach ($directories as $directory)502 {503 $runner->addTestsFromDirectory($directory);504 }505 },506 array('-d', '--directories'),507 '<directory>...',508 $this->locale->_('Execute unit test files in all <directory>')509 )510 ->addArgumentHandler(511 function($script, $argument, $extensions) {512 if (sizeof($extensions) <= 0)513 {514 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));515 }516 $script->getRunner()->getTestDirectoryIterator()->acceptExtensions($extensions);517 },518 array('-tfe', '--test-file-extensions'),519 '<extension>...',520 $this->locale->_('Execute unit test files with one of extensions <extension>')521 )522 ->addArgumentHandler(523 function($script, $argument, $patterns) {524 if (sizeof($patterns) <= 0)525 {526 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));527 }528 $runner = $script->getRunner();529 foreach ($patterns as $pattern)530 {531 $runner->addTestsFromPattern($pattern);532 }533 },534 array('-g', '--glob'),535 '<pattern>...',536 $this->locale->_('Execute unit test files which match <pattern>')537 )538 ->addArgumentHandler(539 function($script, $argument, $tags) {540 if (sizeof($tags) <= 0)541 {542 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));543 }544 $script->testTags($tags);545 },546 array('-t', '--tags'),547 '<tag>...',548 $this->locale->_('Execute only unit test with tags <tag>')549 )550 ->addArgumentHandler(551 function($script, $argument, $methods) {552 if (sizeof($methods) <= 0)553 {554 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));555 }556 foreach ($methods as $method)557 {558 $method = explode('::', $method);559 if (sizeof($method) != 2)560 {561 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));562 }563 $script->testMethod($method[0], $method[1]);564 }565 },566 array('-m', '--methods'),567 '<class::method>...',568 $this->locale->_('Execute all <class::method>, * may be used as wildcard for class name or method name')569 )570 ->addArgumentHandler(571 function($script, $argument, $namespaces) {572 if (sizeof($namespaces) <= 0)573 {574 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));575 }576 $script->testNamespaces($namespaces);577 },578 array('-ns', '--namespaces'),579 '<namespace>...',580 $this->locale->_('Execute all classes in all namespaces <namespace>')581 )582 ->addArgumentHandler(583 function($script, $argument, $values) {584 if ($values)585 {586 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));587 }588 $script->enableLoopMode();589 },590 array('-l', '--loop'),591 null,592 $this->locale->_('Execute tests in an infinite loop')593 )594 ->addArgumentHandler(595 function($script, $argument, $values) {596 if (sizeof($values) !== 0)597 {598 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));599 }600 $script->disableLoopMode();601 },602 array('--disable-loop-mode'),603 null,604 null,605 3606 )607 ->addArgumentHandler(608 function($script, $argument, $values) {609 if (sizeof($values) !== 0)610 {611 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));612 }613 $script->testIt();614 },615 array('--test-it'),616 null,617 $this->locale->_('Execute atoum unit tests')618 )619 ->addArgumentHandler(620 function($script, $argument, $values) {621 if (sizeof($values) !== 0)622 {623 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));624 }625 $runner = $script->getRunner();626 foreach ($script->getTestAllDirectories() as $directory)627 {628 $runner->addTestsFromDirectory($directory);629 }630 },631 array('--test-all'),632 null,633 $this->locale->_('Execute unit tests in directories defined via $script->addTestAllDirectory(\'path/to/directory\') in a configuration file')634 )635 ->addArgumentHandler(636 function($script, $argument, $values) {637 if ($values)638 {639 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));640 }641 \mageekguy\atoum\cli::forceTerminal();642 },643 array('-ft', '--force-terminal'),644 null,645 $this->locale->_('Force output as in terminal')646 )647 ->addArgumentHandler(648 function($script, $argument, $values) {649 if (sizeof($values) != 1)650 {651 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));652 }653 $script->getRunner()->setBootstrapFile($values[0]);654 },655 array('-bf', '--bootstrap-file'),656 '<file>',657 $this->locale->_('Include <file> before executing each test method'),658 2659 )660 ->addArgumentHandler(661 function($script, $argument, $values) {662 if (sizeof($values) != 0)663 {664 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));665 }666 $report = new atoum\reports\realtime\cli\light();667 $report->addWriter($script->getOutputWriter());668 $script->getRunner()->addReport($report);669 },670 array('-ulr', '--use-light-report'),671 null,672 $this->locale->_('Use "light" CLI report')673 )674 ->addArgumentHandler(675 function($script, $argument, $values) {676 if (sizeof($values) != 0)677 {678 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));679 }680 $script->getRunner()->enableDebugMode();681 },682 array('--debug'),683 null,684 $this->locale->_('Enable debug mode')685 )686 ;687 return $this;688 }689 protected function runAgain()690 {691 return ($this->prompt($this->locale->_('Press <Enter> to reexecute, press any other key and <Enter> to stop...')) == '');692 }693 protected function loop()694 {695 $arguments = ' --disable-loop-mode';696 $cli = call_user_func($this->cliFactory);697 if ($cli->isTerminal() === true)698 {699 $arguments .= ' --force-terminal';700 }701 $addScoreFile = false;702 foreach ($this->getArgumentsParser()->getValues() as $argument => $values)703 {704 switch ($argument)705 {706 case '-l':707 case '--loop':708 case '--disable-loop-mode':709 break;710 case '-sf':711 case '--score-file':712 $addScoreFile = true;713 break;714 default:715 $arguments .= ' ' . $argument;716 foreach ($values as $value)717 {718 $arguments .= ' ' . escapeshellarg($value);719 }720 }721 }722 if ($this->scoreFile === null)723 {724 $this->scoreFile = sys_get_temp_dir() . '/atoum.score';725 @unlink($this->scoreFile);726 $addScoreFile = true;727 }728 if ($addScoreFile === true)729 {730 $arguments .= ' --score-file ' . escapeshellarg($this->scoreFile);731 }732 $command = escapeshellarg($this->runner->getPhpPath()) . ' ' . escapeshellarg($_SERVER['argv'][0]) . $arguments;733 while ($this->runTests === true)734 {735 passthru($command);736 if ($this->loop === false || $this->runAgain() === false)737 {738 $this->runTests = false;739 }740 }741 return $this;742 }743 protected function saveScore(atoum\score $score)744 {745 if ($this->scoreFile !== null && $this->adapter->file_put_contents($this->scoreFile, serialize($score), \LOCK_EX) === false)746 {747 throw new exceptions\runtime('Unable to save score in \'' . $this->scoreFile . '\'');748 }749 return $this;750 }751 protected static function getClassesOf($methods)752 {753 return sizeof($methods) <= 0 || isset($methods['*']) === true ? array() : array_keys($methods);754 }755 private static function getFailMethods(atoum\score $score)756 {757 return self::mergeMethods(self::mergeMethods(self::mergeMethods($score->getMethodsWithFail(), $score->getMethodsWithError()), $score->getMethodsWithException()), $score->getMethodsNotCompleted());758 }759 private static function mergeMethods(array $methods, array $newMethods)760 {761 foreach ($newMethods as $class => $classMethods)762 {763 if (isset($methods[$class]) === false)764 {765 $methods[$class] = $classMethods;...

Full Screen

Full Screen

getClassesOf

Using AI Code Generation

copy

Full Screen

1require_once 'runner.php';2$runner = new Runner();3$classes = $runner->getClassesOf('1.php');4print_r($classes);5require_once 'runner.php';6$runner = new Runner();7$classes = $runner->getClassesOf('2.php');8print_r($classes);9require_once 'runner.php';10$runner = new Runner();11$classes = $runner->getClassesOf('3.php');12print_r($classes);13require_once 'runner.php';14$runner = new Runner();15$classes = $runner->getClassesOf('4.php');16print_r($classes);17require_once 'runner.php';18$runner = new Runner();19$classes = $runner->getClassesOf('5.php');20print_r($classes);21require_once 'runner.php';22$runner = new Runner();23$classes = $runner->getClassesOf('6.php');24print_r($classes);25require_once 'runner.php';26$runner = new Runner();27$classes = $runner->getClassesOf('7.php');28print_r($classes);29require_once 'runner.php';30$runner = new Runner();31$classes = $runner->getClassesOf('8.php');32print_r($classes);33require_once 'runner.php';34$runner = new Runner();35$classes = $runner->getClassesOf('9.php');36print_r($classes);37require_once 'runner.php';38$runner = new Runner();39$classes = $runner->getClassesOf('10.php');40print_r($classes);41require_once 'runner.php';

Full Screen

Full Screen

getClassesOf

Using AI Code Generation

copy

Full Screen

1$runner = new Runner();2$classes = $runner->getClassesOf('1.php');3$runner = new Runner();4$classes = $runner->getClassesOf('2.php');5$runner = new Runner();6$classes = $runner->getClassesOf('3.php');7$runner = new Runner();8$classes = $runner->getClassesOf('4.php');9$runner = new Runner();10$classes = $runner->getClassesOf('5.php');11$runner = new Runner();12$classes = $runner->getClassesOf('6.php');13$runner = new Runner();14$classes = $runner->getClassesOf('7.php');15$runner = new Runner();16$classes = $runner->getClassesOf('8.php');17$runner = new Runner();18$classes = $runner->getClassesOf('9.php');

Full Screen

Full Screen

getClassesOf

Using AI Code Generation

copy

Full Screen

1include_once "classes/Runner.php";2$runner = new Runner();3$classes = $runner->getClassesOf("classes");4foreach($classes as $class){5 echo $class . "<br>";6}7include_once "classes/Runner.php";8$runner = new Runner();9$classes = $runner->getClassesOf("classes");10foreach($classes as $class){11 echo $class . "<br>";12}13include_once "classes/Runner.php";14$runner = new Runner();15$classes = $runner->getClassesOf("classes");16foreach($classes as $class){17 echo $class . "<br>";18}19include_once "classes/Runner.php";20$runner = new Runner();21$classes = $runner->getClassesOf("classes");22foreach($classes as $class){23 echo $class . "<br>";24}25include_once "classes/Runner.php";26$runner = new Runner();27$classes = $runner->getClassesOf("classes");28foreach($classes as $class){29 echo $class . "<br>";30}31include_once "classes/Runner.php";32$runner = new Runner();33$classes = $runner->getClassesOf("classes");34foreach($classes as $class){35 echo $class . "<br>";36}37include_once "classes/Runner.php";38$runner = new Runner();

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Atoum automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used method in runner

Trigger getClassesOf code on LambdaTest Cloud Grid

Execute automation tests with getClassesOf on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.

Test now for Free

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful