本文整理汇总了PHP中PHPUnit_Framework_TestSuite::getGroups方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestSuite::getGroups方法的具体用法?PHP PHPUnit_Framework_TestSuite::getGroups怎么用?PHP PHPUnit_Framework_TestSuite::getGroups使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestSuite
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestSuite::getGroups方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: startTestSuite
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
$groups = $suite->getGroups();
if ($suite instanceof PHPUnit_Extensions_SeleniumTestSuite || in_array('selenium', $groups)) {
$this->runPhantom();
}
}
示例2: getGroups
/**
* Returns the test groups of the suite.
*
* @return array
*/
public function getGroups()
{
$groups = parent::getGroups();
if ($this->getName() && !class_exists($this->getName(), false)) {
$groups[] = $this->getName();
}
return $groups;
}
示例3: startTestSuite
/**
* Make sure the PHP built-in web server is running for tests with group
* 'webserver'
*/
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
{
// Only run on PHP >= 5.4 as PHP below that and HHVM don't have a
// built-in web server
if (defined('HHVM_VERSION')) {
return;
}
if (!in_array('webserver', $suite->getGroups()) || null !== $this->pid) {
return;
}
$this->pid = $pid = $this->startPhpWebServer();
register_shutdown_function(function () use($pid) {
exec('kill ' . $pid);
});
}
示例4: markTestsThatNeedOXID
/**
* Marks tests within suite that needs OXID (by annotation)
*
* @param \PHPUnit_Framework_TestSuite $suite
* @throws \RuntimeException
*/
protected function markTestsThatNeedOXID(\PHPUnit_Framework_TestSuite $suite)
{
if (false === in_array('needs-oxid', $suite->getGroups())) {
return;
}
$groupedTests = $suite->getGroupDetails();
foreach ($groupedTests['needs-oxid'] as $test) {
if ($test instanceof \PHPUnit_Framework_TestSuite) {
continue;
}
if (false === method_exists($test, 'setNeedsOXID')) {
throw new \RuntimeException(sprintf('Test "%s" must extend "SrUnit\\TestCase" - is derived from "%s".', get_class($test), get_parent_class($test)));
}
$test->setNeedsOXID(true);
}
}
示例5: run
/**
* Ugly hack to get around PHPUnit having a hard coded classname for the Runner. :(
*
* @param array $argv
* @param boolean $exit
*/
public function run(array $argv, $exit = true)
{
$this->handleArguments($argv);
$runner = $this->getRunner($this->arguments['loader']);
if (is_object($this->arguments['test']) && $this->arguments['test'] instanceof PHPUnit_Framework_Test) {
$suite = $this->arguments['test'];
} else {
$suite = $runner->getTest($this->arguments['test'], $this->arguments['testFile'], $this->arguments['syntaxCheck']);
}
if (count($suite) == 0) {
$skeleton = new PHPUnit_Util_Skeleton_Test($suite->getName(), $this->arguments['testFile']);
$result = $skeleton->generate(true);
if (!$result['incomplete']) {
eval(str_replace(array('<?php', '?>'), '', $result['code']));
$suite = new PHPUnit_Framework_TestSuite($this->arguments['test'] . 'Test');
}
}
if ($this->arguments['listGroups']) {
PHPUnit_TextUI_TestRunner::printVersionString();
print "Available test group(s):\n";
$groups = $suite->getGroups();
sort($groups);
foreach ($groups as $group) {
print " - {$group}\n";
}
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
}
unset($this->arguments['test']);
unset($this->arguments['testFile']);
try {
$result = $runner->doRun($suite, $this->arguments);
} catch (PHPUnit_Framework_Exception $e) {
print $e->getMessage() . "\n";
}
if ($exit) {
if (isset($result) && $result->wasSuccessful()) {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} else {
if (!isset($result) || $result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
} else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
}
}
}
示例6: run
/**
* @param array $argv
* @param boolean $exit
*/
public function run(array $argv, $exit = TRUE)
{
$this->handleArguments($argv);
$runner = new PHPUnit_TextUI_TestRunner($this->arguments['loader']);
if (is_object($this->arguments['test']) && $this->arguments['test'] instanceof PHPUnit_Framework_Test) {
$suite = $this->arguments['test'];
} else {
$suite = $runner->getTest($this->arguments['test'], $this->arguments['testFile'], $this->arguments['syntaxCheck']);
}
if ($suite->testAt(0) instanceof PHPUnit_Framework_Warning && strpos($suite->testAt(0)->getMessage(), 'No tests found in class') !== FALSE) {
$message = $suite->testAt(0)->getMessage();
$start = strpos($message, '"') + 1;
$end = strpos($message, '"', $start);
$className = substr($message, $start, $end - $start);
require_once PATH_TO_ROOT . '/test/PHPUnit/Util/Skeleton/Test.php';
$skeleton = new PHPUnit_Util_Skeleton_Test($className, $this->arguments['testFile']);
$result = $skeleton->generate(TRUE);
if (!$result['incomplete']) {
eval(str_replace(array('<?php', '?>'), '', $result['code']));
$suite = new PHPUnit_Framework_TestSuite($this->arguments['test'] . 'Test');
}
}
if ($this->arguments['listGroups']) {
PHPUnit_TextUI_TestRunner::printVersionString();
print "Available test group(s):\n";
$groups = $suite->getGroups();
sort($groups);
foreach ($groups as $group) {
print " - {$group}\n";
}
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
}
unset($this->arguments['test']);
unset($this->arguments['testFile']);
try {
$result = $runner->doRun($suite, $this->arguments);
} catch (PHPUnit_Framework_Exception $e) {
print $e->getMessage() . "\n";
}
if ($exit) {
if (isset($result) && $result->wasSuccessful()) {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} else {
if (!isset($result) || $result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
} else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
}
}
}
示例7: run
/**
* @param array $argv
* @param boolean $exit
*/
public function run(array $argv, $exit = TRUE)
{
$this->handleArguments($argv);
// *** BEGIN ezp custom code BEGIN ***
if( isset($this->arguments['list-tests']) )
{
$this->listTests( $this->suite );
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
}
// *** END ezp custom code END***
$runner = new PHPUnit_TextUI_TestRunner($this->arguments['loader']);
// *** BEGIN ezp custom code BEGIN ***
// **Following code is removed compared to the original implementation
/*if (is_object($this->arguments['test']) &&
$this->arguments['test'] instanceof PHPUnit_Framework_Test) {
$suite = $this->arguments['test'];
} else {
$suite = $runner->getTest(
$this->arguments['test'],
$this->arguments['testFile'],
$this->arguments['syntaxCheck']
);
}*/
// **And this line is added
$suite = $this->suite;
// *** END ezp custom code END ***
if (count($suite) == 0) {
$skeleton = new PHPUnit_Util_Skeleton_Test(
$suite->getName(),
$this->arguments['testFile']
);
$result = $skeleton->generate(TRUE);
if (!$result['incomplete']) {
eval(str_replace(array('<?php', '?>'), '', $result['code']));
$suite = new PHPUnit_Framework_TestSuite(
$this->arguments['test'] . 'Test'
);
}
}
if ($this->arguments['listGroups']) {
PHPUnit_TextUI_TestRunner::printVersionString();
print "Available test group(s):\n";
$groups = $suite->getGroups();
sort($groups);
foreach ($groups as $group) {
print " - $group\n";
}
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
}
unset($this->arguments['test']);
unset($this->arguments['testFile']);
try {
$result = $runner->doRun($suite, $this->arguments);
}
catch (PHPUnit_Framework_Exception $e) {
print $e->getMessage() . "\n";
}
if ($exit) {
if (isset($result) && $result->wasSuccessful()) {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
}
else if (!isset($result) || $result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
}
else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
}
}
示例8: main
/**
*/
public static function main($exit = TRUE)
{
$arguments = self::handleArguments();
$runner = new PHPUnit_TextUI_TestRunner();
if (is_object($arguments['test']) && $arguments['test'] instanceof PHPUnit_Framework_Test) {
$suite = $arguments['test'];
} else {
$suite = $runner->getTest($arguments['test'], $arguments['testFile'], $arguments['syntaxCheck']);
}
if ($suite->testAt(0) instanceof PHPUnit_Framework_Warning && strpos($suite->testAt(0)->getMessage(), 'No tests found in class') !== FALSE) {
require_once 'PHPUnit/Util/Skeleton/Test.php';
if (isset($arguments['bootstrap'])) {
require_once $arguments['bootstrap'];
}
$skeleton = new PHPUnit_Util_Skeleton_Test($arguments['test'], $arguments['testFile']);
$result = $skeleton->generate(TRUE);
if (!$result['incomplete']) {
eval(str_replace(array('<?php', '?>'), '', $result['code']));
$suite = new PHPUnit_Framework_TestSuite($arguments['test'] . 'Test');
}
}
if ($arguments['listGroups']) {
PHPUnit_TextUI_TestRunner::printVersionString();
print "Available test group(s):\n";
foreach ($suite->getGroups() as $group) {
print " - {$group}\n";
}
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
}
try {
$result = $runner->doRun($suite, $arguments);
} catch (Exception $e) {
throw new RuntimeException('Could not create and run test suite: ' . $e->getMessage());
}
if ($exit) {
if ($result->wasSuccessful()) {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} else {
if ($result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
} else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
}
}
}
示例9: _fillTests
/**
* Adds fixture tests to the suite
*
* @param Magento_Test_TestSuite_ModuleGroups $suite
* @return Magento_Test_Profiler_ModuleGroupsTest
*/
protected function _fillTests($suite)
{
$fileIterator = File_Iterator_Factory::getFileIterator(array(__DIR__ . '/_files/ModuleGroups'), '.php');
// Manually make unique array of filenames, because we may get duplicate entries there
$filenames = array();
foreach ($fileIterator as $filename) {
$filenames[] = (string) $filename;
}
$filenames = array_unique($filenames);
// Compose test suite
foreach ($filenames as $filename) {
include_once $filename;
$pathinfo = pathinfo($filename);
$className = $pathinfo['filename'];
$subSuite = new PHPUnit_Framework_TestSuite($className);
$groups = $subSuite->getGroups();
$obj = new $className();
$suite->addTest($obj, $groups);
}
return $this;
}
示例10: startTestSuite
/**
* A test suite started.
*
* @param PHPUnit_Framework_TestSuite $suite Test suite
*
* @return void
*/
public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
{
if ($this->suites == 0) {
$this->data['startTime'] = time();
}
$this->suiteRuns[$this->suites] = array('name' => $suite->getName(), 'groups' => $suite->getGroups());
$this->suites++;
}
示例11: execute
public function execute($config_group = 'default')
{
ini_set('memory_limit', '512M');
$this->_get_phpunit_options($config_group);
require_once Kohana::find_file('vendor', 'PHPUnit/Util/Filter');
require_once Kohana::find_file('vendor', 'PHPUnit/Framework/TestSuite');
require_once Kohana::find_file('vendor', 'PHPUnit/TextUI/TestRunner');
$this->_whitelist();
$this->_blacklist();
// We want all warnings so PHPUnit can take care of them.
error_reporting(E_ALL | E_STRICT);
// Hand control of errors and exceptions to PHPUnit
restore_exception_handler();
restore_error_handler();
// Turn off the output biffer.
ob_end_flush();
//define('PHPUnit_MAIN_METHOD', 'PHPUnit_TextUI_Command::main');
$this->_get_test_suite();
$arguments = $this->_phpunit_options;
$runner = new PHPUnit_TextUI_TestRunner();
if (is_object($arguments['test']) and $arguments['test'] instanceof PHPUnit_Framework_Test) {
$suite = $arguments['test'];
} else {
$suite = $runner->getTest($arguments['test'], $arguments['testFile'], $arguments['syntaxCheck']);
}
if ($suite->testAt(0) instanceof PHPUnit_Framework_Warning and strpos($suite->testAt(0)->getMessage(), 'No tests found in class') !== FALSE) {
$message = $suite->testAt(0)->getMessage();
$start = strpos($message, '"') + 1;
$end = strpos($message, '"', $start);
$className = substr($message, $start, $end - $start);
require Kohana::find_file('vendor', 'PHPUnit/Util/Skeleton/Test');
$skeleton = new PHPUnit_Util_Skeleton_Test($className, $arguments['testFile']);
$result = $skeleton->generate(TRUE);
if (!$result['incomplete']) {
eval(str_replace(array('<?php', '?>'), '', $result['code']));
$suite = new PHPUnit_Framework_TestSuite($arguments['test'] . 'Test');
}
}
if ($arguments['listGroups']) {
PHPUnit_TextUI_TestRunner::printVersionString();
print "Available test group(s):\n";
$groups = $suite->getGroups();
sort($groups);
foreach ($groups as $group) {
print " - {$group}\n";
}
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
}
try {
$result = $runner->doRun($suite, $arguments);
} catch (Exception $e) {
throw new RuntimeException('Could not create and run test suite: ' . $e->getMessage());
}
if ($result->wasSuccessful()) {
exit(PHPUnit_TextUI_TestRunner::SUCCESS_EXIT);
} else {
if ($result->errorCount() > 0) {
exit(PHPUnit_TextUI_TestRunner::EXCEPTION_EXIT);
} else {
exit(PHPUnit_TextUI_TestRunner::FAILURE_EXIT);
}
}
}
示例12: addSuite
private function addSuite(\PHPUnit_Framework_TestSuite $suite)
{
$this->wholeData['suites'][$suite->getName()] = ['name' => $suite->getName(), 'groups' => $suite->getGroups(), 'scenarios' => []];
$this->scenarioId = 0;
$this->scenario =& $this->wholeData['suites'][$suite->getName()]['scenarios'];
}