本文整理汇总了PHP中TestSuite::run方法的典型用法代码示例。如果您正苦于以下问题:PHP TestSuite::run方法的具体用法?PHP TestSuite::run怎么用?PHP TestSuite::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestSuite
的用法示例。
在下文中一共展示了TestSuite::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: report
/**
* Genereates a nice report of the test.
*
* It instantiate a SimpleTest TestSuite and launches a Reporter.
* This method is typically called by a TestRunner.
*
* @return void
* @see KortTestRunner
* @see KortCliReporter
* @see KortHTMLReporter
*/
public function report()
{
$test = new \TestSuite($this->getLabel());
$test->add($this);
if (\TextReporter::inCli()) {
exit($test->run(new KortCliReporter()) ? 0 : 1);
}
$test->run(new KortHTMLReporter());
}
示例2: call_simpletest
public static function call_simpletest($task, $type = 'text', $dirs = array())
{
// remove E_STRICT because simpletest is not E_STRICT compatible
$old_error_reporting = error_reporting();
$new_error_reporting = $old_error_reporting;
if ($new_error_reporting & E_STRICT) {
$new_error_reporting = $new_error_reporting ^ E_STRICT;
}
include_once 'simpletest/unit_tester.php';
include_once 'simpletest/web_tester.php';
if (!class_exists('TestSuite')) {
throw new pakeException('You must install SimpleTest to use this task.');
}
require_once 'simpletest/reporter.php';
require_once 'simpletest/mock_objects.php';
set_include_path('test' . PATH_SEPARATOR . 'lib' . PATH_SEPARATOR . get_include_path());
$base_test_dir = 'test';
$test_dirs = array();
// run tests only in these subdirectories
if ($dirs) {
foreach ($dirs as $dir) {
$test_dirs[] = $base_test_dir . DIRECTORY_SEPARATOR . $dir;
}
} else {
$test_dirs[] = $base_test_dir;
}
$test = new TestSuite('Test suite in (' . implode(', ', $test_dirs) . ')');
$files = pakeFinder::type('file')->name('*Test.php')->in($test_dirs);
if (count($files) > 0) {
foreach ($files as $file) {
$test->addFile($file);
}
ob_start();
if ($type == 'html') {
$result = $test->run(new HtmlReporter());
} else {
if ($type == 'xml') {
$result = $test->run(new XmlReporter());
} else {
$result = $test->run(new TextReporter());
}
}
$content = ob_get_contents();
ob_end_clean();
if ($task->is_verbose()) {
echo $content;
}
} else {
throw new pakeException('No test to run.');
}
error_reporting($old_error_reporting);
}
示例3: run
/**
* Extend run() method to recognize cli mode.
*
* @param SimpleReporter Reporter for HTML mode
* @param SimpleReporter Reporter for CLI mode
* @access public
*/
function run(&$htmlReporter, &$cliReporter)
{
if (EvoTextReporter::inCli()) {
exit(parent::run($cliReporter) ? 0 : 1);
}
parent::run($htmlReporter);
}
示例4: runAllTests
function runAllTests()
{
$test = new TestSuite();
$test->addTestFile($this->webTestDir . 'wtest_uploadform.php');
$test->addTestFile($this->webTestDir . 'wtest_loginform.php');
$test->run(new HtmlReporter());
}
示例5: run
function run(&$reporter)
{
global $UNITTEST;
$UNITTEST->running = true;
$return = parent::run($reporter);
unset($UNITTEST->running);
return $return;
}
示例6: runTests
function runTests()
{
if (php_sapi_name() === "cli") {
$reporter = new TextReporter();
} else {
parent::run(new HTMLReporter());
}
parent::run($reporter);
}
示例7: glob
function __construct()
{
parent::TestSuite("All Generic Tephlon Tests");
$tFiles = glob("*Test.php");
foreach ($tFiles as $f) {
echo "adding {$f}";
parent::addFile($f);
parent::run(new TextReporter());
}
}
示例8: test
/**
* Runs the indicated test case in isolation with the
* URI: /simpletests/test/path/to/filename
*
* For example, to run test_user.php, indicate the path relative to the "tests" directory.
* http://hostname/test/model/test_user.php
*/
function test()
{
$nodes = Router::$segments;
unset($nodes[0]);
unset($nodes[1]);
$path = implode('/', $nodes);
$test = new TestSuite("Test " . $path);
$test->addTestFile(APPPATH . "tests/" . $path);
$test->run(new HtmlReporter());
}
示例9: run
/**
* To execute callback if specified
*
* @param \PHPUnit_Framework_TestResult $result
* @return \PHPUnit_Framework_TestResult
*/
public function run(\PHPUnit_Framework_TestResult $result = null)
{
if ($this->callback) {
$processManager = ProcessManager::factory();
if ($processManager->isParallelModeSupported()) {
$processManager->applyAppState($this->callback, $this->callbackArguments);
} else {
call_user_func_array($this->callback, $this->callbackArguments);
}
}
return parent::run($result);
}
示例10: call_simpletest
public static function call_simpletest(pakeTask $task, $type = 'text', $dirs = array())
{
if (!class_exists('TestSuite')) {
throw new pakeException('You must install SimpleTest to use this task.');
}
SimpleTest::ignore('UnitTestCase');
$base_test_dir = 'test';
$test_dirs = array();
// run tests only in these subdirectories
if ($dirs) {
foreach ($dirs as $dir) {
$test_dirs[] = $base_test_dir . DIRECTORY_SEPARATOR . $dir;
}
} else {
$test_dirs[] = $base_test_dir;
}
$files = pakeFinder::type('file')->name('*Test.php')->in($test_dirs);
if (count($files) == 0) {
throw new pakeException('No test to run.');
}
$test = new TestSuite('Test suite in (' . implode(', ', $test_dirs) . ')');
foreach ($files as $file) {
$test->addFile($file);
}
ob_start();
if ($type == 'html') {
$result = $test->run(new HtmlReporter());
} else {
if ($type == 'xml') {
$result = $test->run(new XmlReporter());
} else {
$result = $test->run(new TextReporter());
}
}
$content = ob_get_contents();
ob_end_clean();
if ($task->is_verbose()) {
echo $content;
}
}
示例11: testContentOfRecorderWithOnePassAndOneFailure
public function testContentOfRecorderWithOnePassAndOneFailure()
{
$test = new TestSuite();
$test->addFile(dirname(__FILE__) . '/support/recorder_sample.php');
$recorder = new Recorder(new SimpleReporter());
$test->run($recorder);
$this->assertEqual(count($recorder->results), 2);
$this->assertIsA($recorder->results[0], 'SimpleResultOfPass');
$this->assertEqual('testTrueIsTrue', array_pop($recorder->results[0]->breadcrumb));
$this->assertPattern('/ at \\[.*\\Wrecorder_sample\\.php line 9\\]/', $recorder->results[0]->message);
$this->assertIsA($recorder->results[1], 'SimpleResultOfFail');
$this->assertEqual('testFalseIsTrue', array_pop($recorder->results[1]->breadcrumb));
$this->assertPattern("/Expected false, got \\[Boolean: true\\] at \\[.*\\Wrecorder_sample\\.php line 14\\]/", $recorder->results[1]->message);
}
示例12: runAllTests
function runAllTests()
{
$test = new TestSuite();
/*//$test->addTestFile(dirname(__FILE__).'/testcrud.php');
$test->addTestFile(dirname(__FILE__).'/testdatabase.php');
$test->addTestFile(dirname(__FILE__).'/testcrudasmodel.php');
//$test->addTestFile(dirname(__FILE__).'/testusersignup.php'); obselete - users store themselves
$test->addTestFile(dirname(__FILE__).'/testupload.php');
$test->addTestFile(dirname(__FILE__).'/testscript.php');
$test->addTestFile(dirname(__FILE__).'/testmarkjson.php');
$test->addTestFile(dirname(__FILE__).'/testpayment.php');
$test->addTestFile(dirname(__FILE__).'/testpagegroup.php');*/
$test->addTestFile(dirname(__FILE__) . '/testscript.php');
$test->run(new HtmlReporter());
}
示例13: testPass
function testPass()
{
$listener = new MockSimpleSocket();
$fullpath = realpath(dirname(__FILE__) . '/support/test1.php');
$testpath = EclipseReporter::escapeVal($fullpath);
$expected = "{status:\"pass\",message:\"pass1 at [{$testpath} line 4]\",group:\"{$testpath}\",case:\"test1\",method:\"test_pass\"}";
//this should work...but it doesn't so the next line and the last line are the hacks
//$listener->expectOnce('write',array($expected));
$listener->setReturnValue('write', -1);
$pathparts = pathinfo($fullpath);
$filename = $pathparts['basename'];
$test = new TestSuite($filename);
$test->addTestFile($fullpath);
$test->run(new EclipseReporter($listener));
$this->assertEqual($expected, $listener->output);
}
示例14: Form_Create
protected function Form_Create()
{
$filesToSkip = array("QUnitTestCaseBase.php", "QTestForm.tpl.php");
$arrFiles = QFolder::listFilesInFolder(__QCUBED_CORE__ . '/tests/qcubed-unit/');
$arrTests = array();
foreach ($arrFiles as $filename) {
if (!in_array($filename, $filesToSkip)) {
require_once __QCUBED_CORE__ . '/tests/qcubed-unit/' . $filename;
$arrTests[] = str_replace(".php", "", $filename);
}
}
$suite = new TestSuite('QCubed ' . QCUBED_VERSION_NUMBER_ONLY . ' Unit Tests - SimpleTest ' . SimpleTest::getVersion());
foreach ($arrTests as $className) {
$suite->add(new $className($this));
}
$suite->run(new QHtmlReporter());
}
示例15: run
function run($reporter)
{
$only = require_get("only", false);
// we just load all PHP files within this directory
if ($handle = opendir('.')) {
echo "<ul style=\"padding: 10px; list-style: none;\">";
echo "<li style=\"display: inline-block; margin-right: 5px;\"><a href=\"" . url_for('tests/') . "\"><b>All tests</b></a></li>\n";
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && substr(strtolower($entry), -4) == ".php" && strtolower($entry) != 'index.php') {
echo "<li style=\"display: inline-block; margin-right: 5px;\"><a href=\"" . url_for('tests/', array('only' => $entry)) . "\">" . htmlspecialchars($entry) . "</a></li>\n";
}
}
echo "</ul>";
closedir($handle);
}
parent::run($reporter);
}