Best Atoum code snippet using runner.resetTestMethods
runner.php
Source:runner.php
...253 {254 $this->methods[$class][] = $method;255 return $this;256 }257 public function resetTestMethods()258 {259 $this->methods = [];260 return $this;261 }262 public function addDefaultReport()263 {264 $report = call_user_func($this->defaultReportFactory, $this);265 $this->addReport($report);266 return $report;267 }268 public function addReport(atoum\report $report)269 {270 $this->runner->addReport($report);271 return $this;272 }273 public function setReport(atoum\report $report)274 {275 $this->runner->setReport($report);276 return $this;277 }278 public function getReports()279 {280 return $this->runner->getReports();281 }282 public function setPhpPath($phpPath)283 {284 $this->runner->setPhpPath($phpPath);285 return $this;286 }287 public function setDefaultReportTitle($reportTitle)288 {289 $this->runner->setDefaultReportTitle($reportTitle);290 return $this;291 }292 public function setMaxChildrenNumber($childrenNumber)293 {294 $this->runner->setMaxChildrenNumber($childrenNumber);295 return $this;296 }297 public function disableCodeCoverage()298 {299 $this->runner->disableCodeCoverage();300 return $this;301 }302 public function enableBranchesAndPathsCoverage()303 {304 $this->runner->enableBranchesAndPathsCoverage();305 return $this;306 }307 public function excludeNamespacesFromCoverage(array $namespaces)308 {309 $coverage = $this->runner->getCoverage();310 foreach ($namespaces as $namespace) {311 $coverage->excludeNamespace($namespace);312 }313 return $this;314 }315 public function resetExcludedNamespacesFromCoverage()316 {317 $this->runner->getCoverage()->resetExcludedNamespaces();318 return $this;319 }320 public function excludeDirectoriesFromCoverage(array $directories)321 {322 $coverage = $this->runner->getCoverage();323 foreach ($directories as $directory) {324 $coverage->excludeDirectory($directory);325 }326 return $this;327 }328 public function resetExcludedDirectoriesFromCoverage()329 {330 $this->runner->getCoverage()->resetExcludedDirectories();331 return $this;332 }333 public function excludeClassesFromCoverage(array $classes)334 {335 $coverage = $this->runner->getCoverage();336 foreach ($classes as $class) {337 $coverage->excludeClass($class);338 }339 return $this;340 }341 public function resetExcludedClassesFromCoverage()342 {343 $this->runner->getCoverage()->resetExcludedClasses();344 return $this;345 }346 public function excludeMethodsFromCoverage(array $methods)347 {348 $coverage = $this->runner->getCoverage();349 foreach ($methods as $method) {350 $coverage->excludeMethod($method);351 }352 return $this;353 }354 public function resetExcludedMethodsFromCoverage()355 {356 $this->runner->getCoverage()->resetExcludedMethods();357 return $this;358 }359 public function addTest($testPath)360 {361 $this->runner->addTest($testPath);362 return $this;363 }364 public function addTests(array $testPaths)365 {366 foreach ($testPaths as $testPath) {367 $this->addTest($testPath);368 }369 return $this;370 }371 public function addTestsFromDirectory($directory)372 {373 $this->runner->addTestsFromDirectory($directory);374 return $this;375 }376 public function addTestsFromDirectories(array $directories)377 {378 foreach ($directories as $directory) {379 $this->addTestsFromDirectory($directory);380 }381 return $this;382 }383 public function addTestsFromPattern($pattern)384 {385 $this->runner->addTestsFromPattern($pattern);386 return $this;387 }388 public function addTestsFromPatterns(array $patterns)389 {390 foreach ($patterns as $pattern) {391 $this->addTestsFromPattern($pattern);392 }393 return $this;394 }395 public function acceptTestFileExtensions(array $testFileExtensions)396 {397 $this->runner->acceptTestFileExtensions($testFileExtensions);398 return $this;399 }400 public function setBootstrapFile($bootstrapFile)401 {402 $this->runner->setBootstrapFile($bootstrapFile);403 return $this;404 }405 public function setAutoloaderFile($autoloaderFile)406 {407 $this->runner->setAutoloaderFile($autoloaderFile);408 return $this;409 }410 public function enableDebugMode()411 {412 $this->runner->enableDebugMode();413 return $this;414 }415 public function setXdebugConfig($xdebugConfig)416 {417 $this->runner->setXdebugConfig($xdebugConfig);418 return $this;419 }420 public function doNotfailIfVoidMethods()421 {422 $this->runner->doNotfailIfVoidMethods();423 return $this;424 }425 public function failIfVoidMethods()426 {427 $this->runner->failIfVoidMethods();428 return $this;429 }430 public function shouldFailIfVoidMethods()431 {432 return $this->runner->shouldFailIfVoidMethods();433 }434 public function doNotfailIfSkippedMethods()435 {436 $this->runner->doNotfailIfSkippedMethods();437 return $this;438 }439 public function failIfSkippedMethods()440 {441 $this->runner->failIfSkippedMethods();442 return $this;443 }444 public function shouldFailIfSkippedMethods()445 {446 return $this->runner->shouldFailIfSkippedMethods();447 }448 public function init($directory = null)449 {450 $resourceDirectory = static::getResourcesDirectory();451 $currentDirectory = $this->getDirectory();452 if ($directory !== null) {453 $currentDirectory = rtrim($directory, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;454 }455 $defaultConfigFile = $currentDirectory . static::defaultConfigFile;456 if ($this->adapter->file_exists($defaultConfigFile) === false || $this->prompt($this->locale->_('Default configuration file \'' . static::defaultConfigFile . '\' already exists in ' . $currentDirectory . ', type \'Y\' to overwrite it...')) === 'Y') {457 $this458 ->copy($resourceDirectory . '/configurations/runner/atoum.php.dist', $defaultConfigFile)459 ->writeInfo($this->locale->_('Default configuration file \'' . static::defaultConfigFile . '\' was successfully created in ' . $currentDirectory))460 ;461 }462 $bootstrapFile = $currentDirectory . static::defaultBootstrapFile;463 if ($this->adapter->file_exists($bootstrapFile) == false || $this->prompt($this->locale->_('Default bootstrap file \'' . static::defaultBootstrapFile . '\' already exists in ' . $currentDirectory . ', type \'Y\' to overwrite it...')) === 'Y') {464 $this465 ->copy($resourceDirectory . '/configurations/runner/bootstrap.php.dist', $bootstrapFile)466 ->writeInfo($this->locale->_('Default bootstrap file \'' . static::defaultBootstrapFile . '\' was successfully created in ' . $currentDirectory))467 ;468 }469 return $this->stopRun();470 }471 public function setDefaultBootstrapFiles($startDirectory = null)472 {473 foreach (self::getSubDirectoryPath($startDirectory ?: $this->getDirectory()) as $directory) {474 $defaultBootstrapFile = $directory . static::defaultBootstrapFile;475 if ($this->adapter->is_file($defaultBootstrapFile) === true) {476 $this->setBootstrapFile($defaultBootstrapFile);477 break;478 }479 }480 return $this;481 }482 public function setDefaultAutoloaderFiles($startDirectory = null)483 {484 foreach (self::getSubDirectoryPath($startDirectory ?: $this->getDirectory()) as $directory) {485 $defaultAutoloaderFile = $directory . static::defaultAutoloaderFile;486 if ($this->adapter->is_file($defaultAutoloaderFile) === true) {487 $this->setAutoloaderFile($defaultAutoloaderFile);488 return $this;489 }490 }491 foreach (self::getSubDirectoryPath($startDirectory ?: $this->getDirectory()) as $directory) {492 $composerAutoloaderFile = $directory . static::defaultComposerAutoloaderFile;493 if ($this->adapter->is_file($composerAutoloaderFile) === true) {494 $this->setAutoloaderFile($composerAutoloaderFile);495 break;496 }497 }498 return $this;499 }500 public static function autorunMustBeEnabled()501 {502 return (static::$autorunner === true);503 }504 public static function enableAutorun($name)505 {506 static $autorunIsRegistered = false;507 if (static::$autorunner instanceof static) {508 throw new exceptions\runtime('Unable to autorun \'' . $name . '\' because \'' . static::$autorunner->getName() . '\' is already set as autorunner');509 }510 if ($autorunIsRegistered === false) {511 $autorunner = & static::$autorunner;512 $calledClass = get_called_class();513 register_shutdown_function(514 function () use (& $autorunner, $calledClass) {515 if ($autorunner instanceof $calledClass) {516 set_error_handler(function ($error, $message, $file, $line) use ($autorunner) {517 $errorReporting = error_reporting();518 if ($errorReporting & $error) {519 $autorunner->writeError($message . ' in ' . $file . ' at line ' . $line, $error);520 exit(3);521 }522 });523 try {524 $score = $autorunner->run()->getRunner()->getScore();525 $isSuccess = $score->getFailNumber() <= 0 && $score->getErrorNumber() <= 0 && $score->getExceptionNumber() <= 0 && $score->getUncompletedMethodNumber() <= 0;526 if ($autorunner->shouldFailIfVoidMethods() && $score->getVoidMethodNumber() > 0) {527 $isSuccess = false;528 }529 if ($autorunner->shouldFailIfSkippedMethods() && $score->getSkippedMethodNumber() > 0) {530 $isSuccess = false;531 }532 exit($isSuccess ? 0 : 1);533 } catch (\exception $exception) {534 $autorunner->writeError($exception->getMessage());535 exit(2);536 }537 }538 }539 );540 $autorunIsRegistered = true;541 }542 static::$autorunner = new static($name);543 foreach (static::$configurationCallables as $callable) {544 try {545 static::$autorunner->useConfigurationCallable($callable);546 } catch (\exception $exception) {547 static::$autorunner->writeError($exception->getMessage());548 static::$autorunner = null;549 exit($exception->getCode());550 }551 }552 return static::$autorunner;553 }554 public static function disableAutorun()555 {556 static::$autorunner = false;557 }558 public static function addConfigurationCallable(callable $callable)559 {560 static::$configurationCallables[] = $callable;561 }562 protected function setArgumentHandlers()563 {564 parent::setArgumentHandlers()565 ->addArgumentHandler(566 function ($script, $argument, $values) {567 if (count($values) !== 0) {568 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));569 }570 $script->version();571 },572 ['-v', '--version'],573 null,574 $this->locale->_('Display version')575 )576 ->addArgumentHandler(577 function ($script, $argument, $values) {578 if (count($values) !== 0) {579 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));580 }581 $script->resetVerbosityLevel();582 $verbosityLevel = substr_count($argument, '+');583 while ($verbosityLevel--) {584 $script->increaseVerbosityLevel();585 }586 },587 ['+verbose', '++verbose'],588 null,589 $this->locale->_('Enable verbose mode')590 )591 ->addArgumentHandler(592 function ($script, $argument, $values) {593 if (count($values) === 0) {594 $values = [getcwd()];595 }596 $script->init(current($values));597 },598 ['--init'],599 '<path/to/directory>',600 $this->locale->_('Create configuration and bootstrap files in <path/to/directory> (Optional, default: %s)', $this->getDirectory())601 )602 ->addArgumentHandler(603 function ($script, $argument, $path) {604 if (count($path) != 1) {605 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));606 }607 $script->setPhpPath(reset($path));608 },609 ['-p', '--php'],610 '<path/to/php/binary>',611 $this->locale->_('Path to PHP binary which must be used to run tests')612 )613 ->addArgumentHandler(614 function ($script, $argument, $defaultReportTitle) {615 if (count($defaultReportTitle) != 1) {616 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));617 }618 $script->setDefaultReportTitle(reset($defaultReportTitle));619 },620 ['-drt', '--default-report-title'],621 '<string>',622 $this->locale->_('Define default report title with <string>')623 )624 ->addArgumentHandler(625 function ($script, $argument, $file) {626 if (count($file) != 1) {627 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));628 }629 $script->setScoreFile(reset($file));630 },631 ['-sf', '--score-file'],632 '<file>',633 $this->locale->_('Save score in file <file>')634 )635 ->addArgumentHandler(636 function ($script, $argument, $maxChildrenNumber) {637 if (count($maxChildrenNumber) != 1) {638 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));639 }640 $script->setMaxChildrenNumber(reset($maxChildrenNumber));641 },642 ['-mcn', '--max-children-number'],643 '<integer>',644 $this->locale->_('Maximum number of sub-processes which will be run simultaneously')645 )646 ->addArgumentHandler(647 function ($script, $argument, $empty) {648 if ($empty) {649 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));650 }651 $script->disableCodeCoverage();652 },653 ['-ncc', '--no-code-coverage'],654 null,655 $this->locale->_('Disable code coverage')656 )657 ->addArgumentHandler(658 function ($script, $argument, $directories) {659 if (count($directories) <= 0) {660 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));661 }662 $script663 ->resetExcludedDirectoriesFromCoverage()664 ->excludeDirectoriesFromCoverage($directories)665 ;666 },667 ['-nccid', '--no-code-coverage-in-directories'],668 '<directory>...',669 $this->locale->_('Disable code coverage in directories <directory>')670 )671 ->addArgumentHandler(672 function ($script, $argument, $namespaces) {673 if (count($namespaces) <= 0) {674 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));675 }676 $script677 ->resetExcludedNamespacesFromCoverage()678 ->excludeNamespacesFromCoverage($namespaces)679 ;680 },681 ['-nccfns', '--no-code-coverage-for-namespaces'],682 '<namespace>...',683 $this->locale->_('Disable code coverage for namespaces <namespace>')684 )685 ->addArgumentHandler(686 function ($script, $argument, $classes) {687 if (count($classes) <= 0) {688 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));689 }690 $script691 ->resetExcludedClassesFromCoverage()692 ->excludeClassesFromCoverage($classes)693 ;694 },695 ['-nccfc', '--no-code-coverage-for-classes'],696 '<class>...',697 $this->locale->_('Disable code coverage for classes <class>')698 )699 ->addArgumentHandler(700 function ($script, $argument, $classes) {701 if (count($classes) <= 0) {702 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));703 }704 $script705 ->resetExcludedMethodsFromCoverage()706 ->excludeMethodsFromCoverage($classes)707 ;708 },709 ['-nccfm', '--no-code-coverage-for-methods'],710 '<method>...',711 $this->locale->_('Disable code coverage for methods <method>')712 )713 ->addArgumentHandler(714 function ($script, $argument, $empty) {715 if ($empty) {716 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));717 }718 $script->enableBranchesAndPathsCoverage();719 },720 ['-ebpc', '--enable-branch-and-path-coverage'],721 null,722 $this->locale->_('Enable branch and path coverage')723 )724 ->addArgumentHandler(725 function ($script, $argument, $files) {726 if (count($files) <= 0) {727 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));728 }729 $script->addTests($files);730 },731 ['-f', '--files'],732 '<file>...',733 $this->locale->_('Execute all unit test files <file>')734 )735 ->addArgumentHandler(736 function ($script, $argument, $directories) {737 if (count($directories) <= 0) {738 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));739 }740 $script->addTestsFromDirectories($directories);741 },742 ['-d', '--directories'],743 '<directory>...',744 $this->locale->_('Execute unit test files in all <directory>')745 )746 ->addArgumentHandler(747 function ($script, $argument, $extensions) {748 if (count($extensions) <= 0) {749 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));750 }751 $script->acceptTestFileExtensions($extensions);752 },753 ['-tfe', '--test-file-extensions'],754 '<extension>...',755 $this->locale->_('Execute unit test files with one of extensions <extension>')756 )757 ->addArgumentHandler(758 function ($script, $argument, $patterns) {759 if (count($patterns) <= 0) {760 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));761 }762 $script->addTestsFromPatterns($patterns);763 },764 ['-g', '--glob'],765 '<pattern>...',766 $this->locale->_('Execute unit test files which match <pattern>')767 )768 ->addArgumentHandler(769 function ($script, $argument, $tags) {770 if (count($tags) <= 0) {771 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));772 }773 $script->testTags($tags);774 },775 ['-t', '--tags'],776 '<tag>...',777 $this->locale->_('Execute only unit test with tags <tag>')778 )779 ->addArgumentHandler(780 function ($script, $argument, $methods) {781 if (count($methods) <= 0) {782 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));783 }784 $script->resetTestMethods();785 foreach ($methods as $method) {786 $method = explode('::', $method);787 if (count($method) != 2) {788 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more information'), $argument, $script->getName()));789 }790 $script->testMethod($method[0], $method[1]);791 }792 },793 ['-m', '--methods'],794 '<class::method>...',795 $this->locale->_('Execute all <class::method>, * may be used as wildcard for class name or method name')796 )797 ->addArgumentHandler(798 function ($script, $argument, $namespaces) {...
resetTestMethods
Using AI Code Generation
1require_once 'PHPUnit/TextUI/TestRunner.php';2PHPUnit_TextUI_TestRunner::resetTestMethods();3require_once 'PHPUnit/TextUI/TestRunner.php';4PHPUnit_TextUI_TestRunner::resetTestMethods();5require_once 'PHPUnit/TextUI/TestRunner.php';6PHPUnit_TextUI_TestRunner::resetTestMethods();7require_once 'PHPUnit/TextUI/TestRunner.php';8PHPUnit_TextUI_TestRunner::resetTestMethods();9require_once 'PHPUnit/TextUI/TestRunner.php';10PHPUnit_TextUI_TestRunner::resetTestMethods();11require_once 'PHPUnit/TextUI/TestRunner.php';12PHPUnit_TextUI_TestRunner::resetTestMethods();13require_once 'PHPUnit/TextUI/TestRunner.php';14PHPUnit_TextUI_TestRunner::resetTestMethods();15require_once 'PHPUnit/TextUI/TestRunner.php';16PHPUnit_TextUI_TestRunner::resetTestMethods();17require_once 'PHPUnit/TextUI/TestRunner.php';18PHPUnit_TextUI_TestRunner::resetTestMethods();19require_once 'PHPUnit/TextUI/TestRunner.php';20PHPUnit_TextUI_TestRunner::resetTestMethods();21require_once 'PHPUnit/TextUI/TestRunner.php';22PHPUnit_TextUI_TestRunner::resetTestMethods();23require_once 'PHPUnit/TextUI/TestRunner.php';24PHPUnit_TextUI_TestRunner::resetTestMethods();25require_once 'PHPUnit/TextUI/TestRunner.php';
resetTestMethods
Using AI Code Generation
1$runner = new Runner();2$runner->resetTestMethods();3$runner = new Runner();4$runner->resetTestMethods();5Runner::resetTestMethods();6Runner::resetTestMethods();
resetTestMethods
Using AI Code Generation
1require_once 'simpletest/autorun.php';2class SampleTest extends UnitTestCase {3 function testOne() {4 $this->assertTrue(true);5 }6 function testTwo() {7 $this->assertTrue(true);8 }9}10class TestOfResetTestMethods extends UnitTestCase {11 function testResetTestMethods() {12 $test = new SampleTest();13 $test->resetTestMethods();14 $this->assertEqual($test->getTestCaseCount(), 0);15 }16}17require_once 'simpletest/autorun.php';18class SampleTest extends UnitTestCase {19 function testOne() {20 $this->assertTrue(true);21 }22 function testTwo() {23 $this->assertTrue(true);24 }25}26class TestOfAddTestMethods extends UnitTestCase {27 function testAddTestMethods() {28 $test = new SampleTest();29 $test->addTestMethods(array('testOne'));30 $this->assertEqual($test->getTestCaseCount(), 1);31 }32}33OK (1 test, 1 assertion)34require_once 'simpletest/autorun.php';35class SampleTest extends UnitTestCase {36 function testOne() {
resetTestMethods
Using AI Code Generation
1include_once 'PHPUnit/TextUI/TestRunner.php';2PHPUnit_TextUI_TestRunner::resetTestMethods();3PHPUnit_TextUI_TestRunner::run($suite);4PHPUnit_TextUI_TestRunner::run($suite);5PHPUnit_TextUI_TestRunner::run($suite);6PHPUnit_TextUI_TestRunner::run($suite);7PHPUnit_TextUI_TestRunner::run($suite);8PHPUnit_TextUI_TestRunner::run($suite);9PHPUnit_TextUI_TestRunner::run($suite);10PHPUnit_TextUI_TestRunner::run($suite);11PHPUnit_TextUI_TestRunner::run($suite);12PHPUnit_TextUI_TestRunner::run($suite);13PHPUnit_TextUI_TestRunner::run($suite);14PHPUnit_TextUI_TestRunner::run($suite);15PHPUnit_TextUI_TestRunner::run($suite);16PHPUnit_TextUI_TestRunner::run($suite);17PHPUnit_TextUI_TestRunner::run($suite);18PHPUnit_TextUI_TestRunner::run($suite);19PHPUnit_TextUI_TestRunner::run($suite);20PHPUnit_TextUI_TestRunner::run($
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with resetTestMethods on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!