本文整理汇总了PHP中PHPUnit_Framework_TestSuite::run方法的典型用法代码示例。如果您正苦于以下问题:PHP PHPUnit_Framework_TestSuite::run方法的具体用法?PHP PHPUnit_Framework_TestSuite::run怎么用?PHP PHPUnit_Framework_TestSuite::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PHPUnit_Framework_TestSuite
的用法示例。
在下文中一共展示了PHPUnit_Framework_TestSuite::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: WebLauncher
/**
* Launches a test module for web inspection of results
* @param string $module
* @return boolean
*/
function WebLauncher($module)
{
jf::$ErrorHandler->UnsetErrorHandler();
$this->LoadFramework();
self::$TestSuite = new \PHPUnit_Framework_TestSuite();
self::$TestFiles[] = $this->ModuleFile($module);
self::$TestSuite->addTestFile(self::$TestFiles[0]);
$result = new \PHPUnit_Framework_TestResult();
$listener = new TestListener();
$result->addListener($listener);
$Profiler = new Profiler();
if (function_exists("xdebug_start_code_coverage")) {
xdebug_start_code_coverage();
}
self::$TestSuite->run($result);
if (function_exists("xdebug_start_code_coverage")) {
$Coverage = xdebug_get_code_coverage();
} else {
$Coverage = null;
}
$Profiler->Stop();
$listener->Finish();
$this->OutputResult($result, $Profiler, $Coverage);
return true;
}
示例2: testAccessTestsAreSkippedWhenNoAclIsGiven
public function testAccessTestsAreSkippedWhenNoAclIsGiven()
{
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('AccessNavigationTestWithNoAcl');
$suite->run($result = new PHPUnit_Framework_TestResult());
$this->assertEquals(1, $result->skippedCount());
}
示例3: run
/**
* Runs the tests and collects their result in a TestResult.
*
* @param PHPUnit_Framework_TestResult $result A test result.
* @param mixed $filter The filter passed to each test.
*
* @return PHPUnit_Framework_TestResult
*/
public function run(PHPUnit_Framework_TestResult $result = null, $filter = false)
{
spl_autoload_register(array('PHP_CodeSniffer', 'autoload'));
$result = parent::run($result, $filter);
spl_autoload_unregister(array('PHP_CodeSniffer', 'autoload'));
return $result;
}
示例4: testAclIsTested
public function testAclIsTested()
{
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('FooAclTest');
$suite->run($result = new PHPUnit_Framework_TestResult());
$this->assertTrue($result->wasSuccessful(), 'Test should be run successfully');
$this->assertEquals(2, $result->count());
}
示例5: testUnitTestLoadFixtures
public function testUnitTestLoadFixtures()
{
$db = Doctrine_Manager::connection();
$db->exec('DROP TABLE IF EXISTS `foo`; CREATE TABLE `foo` (`a` VARCHAR, `b` VARCHAR);');
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('NotEmptyDoctrineDbTest');
$suite->run($result = new PHPUnit_Framework_TestResult());
$this->assertEquals(1, $result->count());
$this->assertTestsAreSuccessful($result);
}
示例6: run
/**
* Runs the test suite using the result specified in the constructor
*
* @param array $groups Optional array of groups to test
* @param bool $collect_cc Optional, Should code coverage be collected?
* @return Kohana_PHPUnit Instance of $this
*/
public function run(array $groups = array(), $collect_cc = FALSE)
{
if ($collect_cc and !extension_loaded('xdebug')) {
throw new Kohana_Exception('Code coverage cannot be collected because the xdebug extension is not loaded');
}
$this->result->collectCodeCoverageInformation((bool) $collect_cc);
// Run the tests.
$this->suite->run($this->result, FALSE, $groups);
return $this;
}
示例7: testUnitTestLoadFixtures
public function testUnitTestLoadFixtures()
{
Zend_Db_Table_Abstract::setDefaultAdapter($db = new Zend_Db_Adapter_Pdo_Sqlite(array('dbname' => ":memory:")));
$db->getConnection()->exec('DROP TABLE IF EXISTS `foo`; CREATE TABLE `foo` (`a` VARCHAR, `b` VARCHAR);');
$suite = new PHPUnit_Framework_TestSuite();
$suite->addTestSuite('NotEmptyZendDbTest');
$suite->run($result = new PHPUnit_Framework_TestResult());
$this->assertEquals(1, $result->count());
$this->assertTestsAreSuccessful($result);
}
示例8: run_tests
protected function run_tests($tests, &$listener)
{
$suite = new PHPUnit_Framework_TestSuite('default');
foreach ($tests as $case) {
$suite->addTestSuite($case);
}
#return PHPUnit::run($suite);
$result = new PHPUnit_Framework_TestResult();
$result->addListener($listener);
return $suite->run($result);
}
示例9: run
/**
* {@inheritDoc}
*/
public function run(PHPUnit_Framework_TestResult $result = null, $filter = false, array $groups = array(), array $excludeGroups = array(), $processIsolation = false)
{
parent::run($result, $filter, $groups, $excludeGroups, $processIsolation);
$args = func_get_args();
$factory = new File_Iterator_Factory();
$iterator = $factory->getFileIterator($this->directories, $this->suffix, $this->prefix, $this->exclude_directories);
foreach ($iterator as $item) {
$this->createAndPerform($item->getRealPath(), 'run', $args);
}
foreach ($this->files as $file) {
$this->createAndPerform($this->root_directory . '/' . $file, 'run', $args);
}
}
示例10: main
function main()
{
function cleanup()
{
global $wpdb;
// we need to ensure that we switch off this database
$wpdb->select(null);
// drop our test database
// XXX: why cant we use $wpdb->query ?
mysql_query(sprintf('DROP DATABASE `%s`', DISQUS_TEST_DATABASE)) or die(mysql_error());
}
global $wpdb;
// $this->query(sprintf('DROP DATABASE IF EXISTS `%s`', DISQUS_TEST_DATABASE));
// check existance of test db
$exists = $wpdb->get_var($wpdb->prepare('SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = \'%s\'', DISQUS_TEST_DATABASE));
if (!empty($exists)) {
printf("Test database '%s' already exists. Continuing will drop this database and all data!\nContinue? [y/n]\n", $exists);
$handle = fopen("php://stdin", "r");
$line = strtolower(trim(fgets($handle)));
if ($line != 'yes' && $line != 'y') {
echo "ABORTING!\n";
exit;
}
}
// setup database
$wpdb->query(sprintf('CREATE DATABASE `%s`', DISQUS_TEST_DATABASE));
$wpdb->select(DISQUS_TEST_DATABASE);
// $fp = fopen('initial.sql', 'r');
// $buffer = '';
// while (($line = fgets($fp)) !== false) {
// $buffer .= trim($line);
// if (strpos($line, ';')) {
// if (!empty($buffer)) {
// $this->query($buffer);
// }
// $buffer = '';
// }
// }
//
try {
$suite = new PHPUnit_Framework_TestSuite('DisqusPluginTest');
$result = $suite->run();
require_once 'PHPUnit/TextUI/ResultPrinter.php';
$printer = new PHPUnit_TextUI_ResultPrinter();
$printer->printResult($result);
cleanup();
} catch (Exception $ex) {
cleanup();
throw $ex;
}
}
示例11: run
/**
* Main function - runs the tests and outputs HTML code
*
* @return void
* @author Robert Lemke <robert@typo3.org>
* @author Karsten Dambekalns <karsten@typo3.org>
* @internal Preliminary solution - there surely will be nicer ways to implement a test runner
*/
public function run()
{
$this->renderPageHeader();
$this->renderTestForm();
if (!empty($this->packageKey)) {
$testcaseFileNamesAndPaths = $this->getTestcaseFilenames();
if (count($testcaseFileNamesAndPaths) > 0) {
$this->renderInfoAndProgressbar();
$this->requireTestCaseFiles($testcaseFileNamesAndPaths);
$testListener = new \F3\Testing\TestListener();
$testListener->baseUri = $this->request->getBaseUri();
$testResult = new \PHPUnit_Framework_TestResult();
$testResult->addListener($testListener);
$testResult->collectCodeCoverageInformation($this->collectCodeCoverage);
$startTime = microtime(TRUE);
foreach (get_declared_classes() as $className) {
if (substr($className, -4, 4) == 'Test') {
$class = new \ReflectionClass($className);
if ($class->isSubclassOf('PHPUnit_Framework_TestCase') && substr($className, 0, 8) !== 'PHPUnit_') {
$testSuite = new \PHPUnit_Framework_TestSuite($class);
$testSuite->run($testResult);
}
}
}
$endTime = microtime(TRUE);
// Display test statistics:
if ($testResult->wasSuccessful()) {
echo '<script type="text/javascript">document.getElementById("progress-bar").style.backgroundColor = "green";document.getElementById("progress-bar").style.backgroundImage = "none";</script>
<h1 class="success">SUCCESS</h1>
' . $testResult->count() . ' tests, ' . $testResult->failureCount() . ' failures, ' . $testResult->errorCount() . ' errors.
</h1>';
} else {
echo '
<script>document.getElementById("progress-bar").style.backgroundColor = "red";document.getElementById("progress-bar").style.backgroundImage = "none";</script>
<h1 class="failure">FAILURE</h1>
' . $testResult->count() . ' tests, ' . $testResult->failureCount() . ' failures, ' . $testResult->errorCount() . ' errors.
';
}
echo '<p>Peak memory usage was: ~' . floor(memory_get_peak_usage() / 1024 / 1024) . ' MByte.<br />';
echo 'Test run took ' . round($endTime - $startTime, 4) . ' seconds.</p>';
if ($this->collectCodeCoverage === TRUE) {
\F3\FLOW3\Utility\Files::emptyDirectoryRecursively($this->coverageOutputPath);
\PHPUnit_Util_Report::render($testResult, $this->coverageOutputPath);
echo '<a href="_Resources/CodeCoverageReport/index.html">See code coverage report...</a>';
}
} else {
echo '<p>No testcase found. Did you specify the intended pattern?</p>';
}
}
$this->renderPageFooter();
}
示例12: run
/**
* Runs the tests and collects their result in a TestResult.
*
* @param PHPUnit_Framework_TestResult $result A test result.
* @param mixed $filter The filter passed to each test.
*
* @return PHPUnit_Framework_TestResult
*/
public function run(PHPUnit_Framework_TestResult $result = null, $filter = false)
{
$GLOBALS['PHP_CODESNIFFER_SNIFF_CODES'] = array();
$GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES'] = array();
spl_autoload_register(array('PHP_CodeSniffer', 'autoload'));
$result = parent::run($result, $filter);
spl_autoload_unregister(array('PHP_CodeSniffer', 'autoload'));
$codes = count($GLOBALS['PHP_CODESNIFFER_SNIFF_CODES']);
$fixes = count($GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES']);
$percent = round($fixes / $codes * 100, 2);
echo PHP_EOL . PHP_EOL;
echo "Tests generated {$codes} unique error codes; {$fixes} were fixable ({$percent}%)";
return $result;
}
示例13: run
/**
* Runs the tests and collects their result in a TestResult.
*
* @param PHPUnit_Framework_TestResult $result
* @param mixed $filter
* @param array $groups
* @param array $excludeGroups
* @param boolean $processIsolation
* @return PHPUnit_Framework_TestResult
* @throws InvalidArgumentException
*/
public function run(PHPUnit_Framework_TestResult $result = NULL, $filter = FALSE, array $groups = array(), array $excludeGroups = array(), $processIsolation = FALSE)
{
// Get the code coverage filter from the suite's result object
$coverage = $result->getCodeCoverage();
if ($coverage) {
$coverage_filter = $coverage->filter();
// Apply the white and blacklisting
foreach ($this->_filter_calls as $method => $args) {
foreach ($args as $arg) {
$coverage_filter->{$method}($arg);
}
}
}
return parent::run($result, $filter, $groups, $excludeGroups, $processIsolation);
}
示例14: _run_tests
private function _run_tests($classes, $classname = '')
{
$suite = new PHPUnit_Framework_TestSuite();
// Turn off BackUpGlobal until https://github.com/sebastianbergmann/phpunit/issues/451 is fixed
$suite->setBackupGlobals(false);
foreach ($classes as $testcase) {
if (!$classname or strtolower($testcase) === strtolower($classname)) {
$suite->addTestSuite($testcase);
}
}
$result = new PHPUnit_Framework_TestResult();
require_once 'PHPUnit/TextUI/ResultPrinter.php';
$this->printer = new WPUnitCommandResultsPrinter();
$result->addListener($this->printer);
return array($suite->run($result), $this->printer);
}
示例15: run
public function run($name = null)
{
$tests = array();
if (!isset($name)) {
$tests = $this->testCases;
} elseif (is_array($name)) {
// run specified tests
} elseif (is_string($name)) {
// run test
$tests[] = $name;
}
foreach ($tests as $name => $mixed) {
if (is_numeric($name)) {
$name = $mixed;
}
$name = strtolower($name);
$path = $this->testCases[$name];
require_once $path;
}
$testClasses = array();
foreach (get_declared_classes() as $class) {
if (stristr($class, 'Test') !== false && strpos($class, 'PHPUnit_') === false) {
$testClasses[] = $class;
}
}
$suite = new PHPUnit_Framework_TestSuite();
foreach ($testClasses as $class) {
if ($this->suite) {
if (strcasecmp($this->suite, $class) == 0) {
$suite->addTestSuite($class);
}
} else {
$suite->addTestSuite($class);
}
}
$result = new PHPUnit_Framework_TestResult();
require_once 'PHPUnit/Util/Log/JSON.php';
$result->addListener(new PHPUnit_Util_Log_JSON());
$this->suite = $suite;
ob_start();
$suite->run($result);
$results = ob_get_contents();
ob_end_clean();
return $results;
}