public static function suite() { $suite = new PHPUnit_Framework_TestSuite('Structures_Graph Tests'); $dir = new GlobIterator(dirname(__FILE__) . '/*Test.php'); $suite->addTestFiles($dir); return $suite; }
public static function suite() { $suite = new PHPUnit_Framework_TestSuite('Net_WebFinger tests'); /** Add testsuites, if there is. */ $suite->addTestFiles(glob(__DIR__ . '/Net/WebFinger{,/,/*/}*Test.php', GLOB_BRACE)); return $suite; }
/** * Adds all class test suites into the master suite * * @return PHPUnit_Framework_TestSuite a master test suite * containing all class test suites * @uses PHPUnit_Framework_TestSuite */ public static function suite() { $suite = new PHPUnit_Framework_TestSuite('PhpDocumentor Full Suite of Unit Tests'); $dir = new GlobIterator(dirname(__FILE__) . '/*Test.php'); $suite->addTestFiles($dir); return $suite; }
public static function suite() { $suite = new PHPUnit_Framework_TestSuite('XML_XRD tests'); /** Add testsuites, if there is. */ $suite->addTestFiles(glob(__DIR__ . '/XML/XRD{,/*/}*Test.php', GLOB_BRACE)); return $suite; }
static function suite() { $dir = dirname(__FILE__); $suite = new PHPUnit_Framework_TestSuite('chatAll'); $suite->addTestFiles(array("{$dir}/mysqltest.php", "{$dir}/ControllerBaseTest.php", "{$dir}/TemplateTest.php")); return $suite; }
/** * Test suite for System_Launcher * * @return Full test suite */ public static function suite() { $suite = new PHPUnit_Framework_TestSuite('System_Launcher tests'); /** Add testsuites, if there are any */ $suite->addTestFiles(glob(__DIR__ . '/System_LauncherTest.php', GLOB_BRACE)); return $suite; }
public static function suite() { $suite = new PHPUnit_Framework_TestSuite('HTML_QuickForm2_Captcha tests'); /** Add testsuites, if there is. */ $suite->addTestFiles(glob(__DIR__ . '/HTML/QuickForm2/Element/{,/*/}*Test.php', GLOB_BRACE)); return $suite; }
/** * {@inheritdoc} */ public function run(array $argv, $exit = true) { // Customizing // Reset the arguments to the default arguments $this->arguments = self::$defaultArguments; $this->handleArguments($argv); $this->runner->setLoader($this->arguments['loader']); $suite = new \PHPUnit_Framework_TestSuite(); $testFiles = array(); foreach ($this->arguments['test'] as $testFodler) { $testFiles = array_merge($testFiles, self::collectTests($testFodler)); } asort($testFiles); $suite->addTestFiles($testFiles); unset($this->arguments['test']); unset($this->arguments['testFile']); try { $result = $this->runner->doRun($suite, $this->arguments); } catch (\PHPUnit_Framework_Exception $e) { print $e->getMessage() . "\n"; } $ret = \PHPUnit_TextUI_TestRunner::FAILURE_EXIT; if (isset($result) && $result->wasSuccessful()) { $ret = \PHPUnit_TextUI_TestRunner::SUCCESS_EXIT; } elseif (!isset($result) || $result->errorCount() > 0) { $ret = \PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT; } if ($exit) { exit($ret); } else { return $ret; } }
public static function suite() { $collector = new PHPUnit_Runner_IncludePathTestCollector(array(dirname(__FILE__))); $suite = new PHPUnit_Framework_TestSuite('Application'); $suite->addTestFiles($collector->collectTests()); return $suite; }
public static function suite() { $suite = new PHPUnit_Framework_TestSuite('MDB2 Unit Tests'); $dir = new GlobIterator(__DIR__ . '/Standard/*Test.php'); $suite->addTestFiles($dir); return $suite; }
/** * Create test suite * * @param string $name Suite name * @param array|string $paths Paths * @param array|string $suffixes Suffixes * @param array|string $prefixes Prefixes * @param array $exclude Exclude * * @return AppendIterator */ protected static function _createSuite($name, $paths, $suffixes = '_test.php', $prefixes = '', $exclude = array()) { $factory = new File_Iterator_Factory(); $iterator = $factory->getFileIterator($paths, $suffixes, $prefixes, $exclude); $suite = new PHPUnit_Framework_TestSuite($name); $suite->addTestFiles($iterator); return $suite; }
public static function suite() { $suite = new \PHPUnit_Framework_TestSuite(); $files = glob(__DIR__ . '/*/*/*Test.php'); if (!is_array($files)) { return $suite; } $suite->addTestFiles($files); return $suite; }
public static function suite() { $types = array('common', 'auth', 'io', 'model', 'providers', 'service', 'storage', 'logger'); $suite = new PHPUnit_Framework_TestSuite(); $suite->setName('OfflineTests'); $path = realpath(dirname(__FILE__)); foreach ($types as $type) { $suite->addTestFiles(glob("{$path}/{$type}/*Test.php")); } return $suite; }
/** * Returns the Test corresponding to the given suite. * This is a template method, subclasses override * the runFailed() and clearStatus() methods. * * @param string $suiteClassName * @param string $suiteClassFile * @param mixed $suffixes * @return PHPUnit_Framework_Test */ public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '') { if (is_dir($suiteClassName) && !is_file($suiteClassName . '.php') && empty($suiteClassFile)) { $facade = new File_Iterator_Facade(); $files = $facade->getFilesAsArray($suiteClassName, $suffixes); $suite = new PHPUnit_Framework_TestSuite($suiteClassName); $suite->addTestFiles($files); return $suite; } $testClass = $this->loadSuiteClass($suiteClassName, $suiteClassFile); }
public static function suite() { global $configuration, $plugin_configuration; $suite = new PHPUnit_Framework_TestSuite('sfImageTransformExtraPlugin'); // loading plugin configurations $configuration = ProjectConfiguration::getActive(); $pluginConfig = $configuration->getPluginConfiguration('sfImageTransformExtraPlugin'); // instantiate a fake symfony unit test task to retrieve all connected tests for this plugin $task = new sfTestUnitTask($configuration->getEventDispatcher(), new sfFormatter()); $event = new sfEvent($task, 'task.test.filter_test_files', array('arguments' => array('name' => array()), 'options' => array())); $files = $pluginConfig->filterTestFiles($event, array()); $suite->addTestFiles($files); return $suite; }
public function run(rex_test_locator $locator, $colors = false) { $suite = new PHPUnit_Framework_TestSuite(); // disable backup of globals, since we have some rex_sql objectes referenced from variables in global space. // PDOStatements are not allowed to be serialized $suite->setBackupGlobals(false); $suite->addTestFiles($locator->getIterator()); rex_error_handler::unregister(); $runner = new PHPUnit_TextUI_TestRunner(); $backtrace = debug_backtrace(false); array_unshift($backtrace, ['file' => __FILE__, 'line' => __LINE__ + 3]); $runner->setPrinter(new rex_tests_result_printer($backtrace, $colors)); $result = $runner->doRun($suite); rex_error_handler::register(); return $result; }
/** * Returns the Test corresponding to the given suite. * This is a template method, subclasses override * the runFailed() and clearStatus() methods. * * @param string $suiteClassName * @param string $suiteClassFile * @param mixed $suffixes * * @return PHPUnit_Framework_Test */ public function getTest($suiteClassName, $suiteClassFile = '', $suffixes = '') { if (is_dir($suiteClassName) && !is_file($suiteClassName . '.php') && empty($suiteClassFile)) { $facade = new File_Iterator_Facade(); $files = $facade->getFilesAsArray($suiteClassName, $suffixes); $suite = new PHPUnit_Framework_TestSuite($suiteClassName); $suite->addTestFiles($files); return $suite; } try { $testClass = $this->loadSuiteClass($suiteClassName, $suiteClassFile); } catch (PHPUnit_Framework_Exception $e) { $this->runFailed($e->getMessage()); return; } try { $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); if (!$suiteMethod->isStatic()) { $this->runFailed('suite() method must be static.'); return; } try { $test = $suiteMethod->invoke(null, $testClass->getName()); } catch (ReflectionException $e) { $this->runFailed(sprintf("Failed to invoke suite() method.\n%s", $e->getMessage())); return; } } catch (ReflectionException $e) { try { $test = new PHPUnit_Framework_TestSuite($testClass); } catch (PHPUnit_Framework_Exception $e) { $test = new PHPUnit_Framework_TestSuite(); $test->setName($suiteClassName); } } $this->clearStatus(); return $test; }
/** * @param DOMElement $testSuiteNode * @param boolean $syntaxCheck * @return PHPUnit_Framework_TestSuite * @since Method available since Release 3.4.0 */ protected function getTestSuite(DOMElement $testSuiteNode, $syntaxCheck) { if ($testSuiteNode->hasAttribute('name')) { $suite = new PHPUnit_Framework_TestSuite( (string)$testSuiteNode->getAttribute('name') ); } else { $suite = new PHPUnit_Framework_TestSuite; } foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) { $directory = (string)$directoryNode->nodeValue; if (empty($directory)) { continue; } if ($directoryNode->hasAttribute('prefix')) { $prefix = (string)$directoryNode->getAttribute('prefix'); } else { $prefix = ''; } if ($directoryNode->hasAttribute('suffix')) { $suffix = (string)$directoryNode->getAttribute('suffix'); } else { $suffix = 'Test.php'; } $testCollector = new PHPUnit_Runner_IncludePathTestCollector( array($this->toAbsolutePath($directory)), $suffix, $prefix ); $suite->addTestFiles($testCollector->collectTests(), $syntaxCheck); } foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) { $file = (string)$fileNode->nodeValue; if (empty($file)) { continue; } $suite->addTestFile($file, $syntaxCheck); } return $suite; }
private function getTestSuite() { $suite = new \PHPUnit_Framework_TestSuite('All tests'); // Note: This code won't work unless the backup globals option is disabled // see: http://www.phpunit.de/ticket/899 $suite->setBackupGlobals(false); if ($this->files instanceof \PHPUnit_Framework_Test) { $suite->addTest($this->files); } else { $suite->addTestFiles($this->files); } return $suite; }
public static function suite() { $suite = new PHPUnit_Framework_TestSuite('Date_HumanDiff tests'); $suite->addTestFiles(array(__DIR__ . '/Date/HumanDiffTest.php', __DIR__ . '/Date/HumanDiff/LocaleArrayTest.php')); return $suite; }
/** * Returns the test suite configuration. * * @return PHPUnit_Framework_TestSuite * @since Method available since Release 3.2.1 */ public function getTestSuiteConfiguration() { $testSuiteNode = $this->xpath->query('testsuite'); if ($testSuiteNode->length > 0) { $testSuiteNode = $testSuiteNode->item(0); if ($testSuiteNode->hasAttribute('name')) { $suite = new PHPUnit_Framework_TestSuite((string) $testSuiteNode->getAttribute('name')); } else { $suite = new PHPUnit_Framework_TestSuite(); } foreach ($this->xpath->query('testsuite/directory') as $directoryNode) { if ($directoryNode->hasAttribute('suffix')) { $suffix = (string) $directoryNode->getAttribute('suffix'); } else { $suffix = 'Test.php'; } $testCollector = new PHPUnit_Runner_IncludePathTestCollector(array((string) $directoryNode->nodeValue), $suffix); $suite->addTestFiles($testCollector->collectTests()); } foreach ($this->xpath->query('testsuite/file') as $fileNode) { $suite->addTestFile((string) $fileNode->nodeValue); } return $suite; } }
/** * Suite * * @return PHPUnit_Framework_TestSuite */ public static function suite() { $suite = new PHPUnit_Framework_TestSuite('Zym Framework - Incubator'); $suite->addTestFiles(glob(dirname(__FILE__) . '/*Suite.php')); return $suite; }
/** Initialize the PHPUnit test runner and run tests. * * @param string[] $options * * @return void */ private function _doRunTests(array $options) { if (empty($options['plugin'])) { $basedir = null; } else { try { /* @var $config sfPluginConfiguration */ /** @noinspection PhpUndefinedMethodInspection */ $config = $this->configuration->getPluginConfiguration($options['plugin']); } catch (InvalidArgumentException $e) { throw new sfException(sprintf('Plugin "%s" does not exist or is not enabled.', $options['plugin'])); } $basedir = implode(DIRECTORY_SEPARATOR, array($config->getRootDir(), 'test', '')); unset($options['plugin']); } if ($files = $this->_findTestFiles($this->_type, (array) $this->_paths, $basedir)) { /** @noinspection PhpIncludeInspection */ require_once 'PHPUnit' . DIRECTORY_SEPARATOR . 'TextUI' . DIRECTORY_SEPARATOR . 'TestRunner.php'; $Runner = new PHPUnit_TextUI_TestRunner(); $Suite = new PHPUnit_Framework_TestSuite(ucfirst($this->name) . ' Tests'); $Suite->addTestFiles($files); /* Inject the command application controller so that it is accessible to * test cases. */ Test_Case::setController($this->commandApplication); /* Ignition... */ try { $Runner->doRun($Suite, $options); } catch (PHPUnit_Framework_Exception $e) { $this->logSection('phpunit', $e->getMessage()); } } else { $this->logSection('phpunit', 'No tests found.'); } }
/** * @param DOMElement $testSuiteNode * @return PHPUnit_Framework_TestSuite * @since Method available since Release 3.4.0 */ protected function getTestSuite(DOMElement $testSuiteNode, $testSuiteFilter = null) { if ($testSuiteNode->hasAttribute('name')) { $suite = new PHPUnit_Framework_TestSuite((string) $testSuiteNode->getAttribute('name')); } else { $suite = new PHPUnit_Framework_TestSuite(); } $exclude = array(); foreach ($testSuiteNode->getElementsByTagName('exclude') as $excludeNode) { $exclude[] = $this->toAbsolutePath((string) $excludeNode->nodeValue); } $fileIteratorFacade = new File_Iterator_Facade(); foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) { if ($testSuiteFilter && $directoryNode->parentNode->getAttribute('name') != $testSuiteFilter) { continue; } $directory = (string) $directoryNode->nodeValue; if (empty($directory)) { continue; } if ($directoryNode->hasAttribute('phpVersion')) { $phpVersion = (string) $directoryNode->getAttribute('phpVersion'); } else { $phpVersion = PHP_VERSION; } if ($directoryNode->hasAttribute('phpVersionOperator')) { $phpVersionOperator = (string) $directoryNode->getAttribute('phpVersionOperator'); } else { $phpVersionOperator = '>='; } if (!version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) { continue; } if ($directoryNode->hasAttribute('prefix')) { $prefix = (string) $directoryNode->getAttribute('prefix'); } else { $prefix = ''; } if ($directoryNode->hasAttribute('suffix')) { $suffix = (string) $directoryNode->getAttribute('suffix'); } else { $suffix = 'Test.php'; } $files = $fileIteratorFacade->getFilesAsArray($this->toAbsolutePath($directory), $suffix, $prefix, $exclude); $suite->addTestFiles($files); } foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) { if ($testSuiteFilter && $fileNode->parentNode->getAttribute('name') != $testSuiteFilter) { continue; } $file = (string) $fileNode->nodeValue; if (empty($file)) { continue; } // Get the absolute path to the file $file = $fileIteratorFacade->getFilesAsArray($this->toAbsolutePath($file)); if (!isset($file[0])) { continue; } $file = $file[0]; if ($fileNode->hasAttribute('phpVersion')) { $phpVersion = (string) $fileNode->getAttribute('phpVersion'); } else { $phpVersion = PHP_VERSION; } if ($fileNode->hasAttribute('phpVersionOperator')) { $phpVersionOperator = (string) $fileNode->getAttribute('phpVersionOperator'); } else { $phpVersionOperator = '>='; } if (!version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) { continue; } $suite->addTestFile($file); } return $suite; }
/** * @param DOMElement $testSuiteNode * @return PHPUnit_Framework_TestSuite * @since Method available since Release 3.4.0 */ protected function getTestSuite(DOMElement $testSuiteNode) { if ($testSuiteNode->hasAttribute('name')) { $suite = new PHPUnit_Framework_TestSuite((string) $testSuiteNode->getAttribute('name')); } else { $suite = new PHPUnit_Framework_TestSuite(); } foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) { $directory = (string) $directoryNode->nodeValue; if (empty($directory)) { continue; } if ($directoryNode->hasAttribute('prefix')) { $prefix = (string) $directoryNode->getAttribute('prefix'); } else { $prefix = ''; } if ($directoryNode->hasAttribute('suffix')) { $suffix = (string) $directoryNode->getAttribute('suffix'); } else { $suffix = 'Test.php'; } $suite->addTestFiles(File_Iterator_Factory::getFilesAsArray($this->toAbsolutePath($directory), $suffix, $prefix, array())); } foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) { $file = (string) $fileNode->nodeValue; if (empty($file)) { continue; } $suite->addTestFile($file); } return $suite; }
/** * Returns the Test corresponding to the given suite. * This is a template method, subclasses override * the runFailed() and clearStatus() methods. * * @param string $suiteClassName * @param string $suiteClassFile * @param boolean $syntaxCheck * @return PHPUnit_Framework_Test */ public function getTest($suiteClassName, $suiteClassFile = '', $syntaxCheck = FALSE) { if (is_dir($suiteClassName) && !is_file($suiteClassName . '.php') && empty($suiteClassFile)) { $testCollector = new PHPUnit_Runner_IncludePathTestCollector(array($suiteClassName)); $suite = new PHPUnit_Framework_TestSuite($suiteClassName); $suite->addTestFiles($testCollector->collectTests(), $syntaxCheck); return $suite; } try { $testClass = $this->loadSuiteClass($suiteClassName, $suiteClassFile, $syntaxCheck); } catch (Exception $e) { $this->runFailed($e->getMessage()); return NULL; } try { $suiteMethod = $testClass->getMethod(self::SUITE_METHODNAME); if (!$suiteMethod->isStatic()) { $this->runFailed('suite() method must be static.'); return NULL; } try { $test = $suiteMethod->invoke(NULL, $testClass->getName()); } catch (ReflectionException $e) { $this->runFailed(sprintf("Failed to invoke suite() method.\n%s", $e->getMessage())); return NULL; } } catch (ReflectionException $e) { try { $test = new PHPUnit_Framework_TestSuite($testClass); } catch (InvalidArgumentException $e) { $test = new PHPUnit_Framework_TestSuite(); $test->setName($suiteClassName); } } $this->clearStatus(); return $test; }
/** * @param DOMElement $testSuiteNode * @return PHPUnit_Framework_TestSuite * @since Method available since Release 3.4.0 */ protected function getTestSuite(DOMElement $testSuiteNode) { if ($testSuiteNode->hasAttribute('name')) { $suite = new PHPUnit_Framework_TestSuite((string) $testSuiteNode->getAttribute('name')); } else { $suite = new PHPUnit_Framework_TestSuite(); } foreach ($testSuiteNode->getElementsByTagName('directory') as $directoryNode) { $directory = (string) $directoryNode->nodeValue; if (empty($directory)) { continue; } if ($directoryNode->hasAttribute('phpVersion')) { $phpVersion = (string) $directoryNode->getAttribute('phpVersion'); } else { $phpVersion = PHP_VERSION; } if ($directoryNode->hasAttribute('phpVersionOperator')) { $phpVersionOperator = (string) $directoryNode->getAttribute('phpVersionOperator'); } else { $phpVersionOperator = '>='; } if (!version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) { continue; } if ($directoryNode->hasAttribute('prefix')) { $prefix = (string) $directoryNode->getAttribute('prefix'); } else { $prefix = ''; } if ($directoryNode->hasAttribute('suffix')) { $suffix = (string) $directoryNode->getAttribute('suffix'); } else { $suffix = 'Test.php'; } $facade = new File_Iterator_Facade(); $files = $facade->getFilesAsArray($this->toAbsolutePath($directory), $suffix, $prefix, array()); $suite->addTestFiles($files); } foreach ($testSuiteNode->getElementsByTagName('file') as $fileNode) { $file = (string) $fileNode->nodeValue; if (empty($file)) { continue; } if ($fileNode->hasAttribute('phpVersion')) { $phpVersion = (string) $fileNode->getAttribute('phpVersion'); } else { $phpVersion = PHP_VERSION; } if ($fileNode->hasAttribute('phpVersionOperator')) { $phpVersionOperator = (string) $fileNode->getAttribute('phpVersionOperator'); } else { $phpVersionOperator = '>='; } if (!version_compare(PHP_VERSION, $phpVersion, $phpVersionOperator)) { continue; } $suite->addTestFile($file); } return $suite; }