本文整理汇总了PHP中TestSuite::addTestCase方法的典型用法代码示例。如果您正苦于以下问题:PHP TestSuite::addTestCase方法的具体用法?PHP TestSuite::addTestCase怎么用?PHP TestSuite::addTestCase使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestSuite
的用法示例。
在下文中一共展示了TestSuite::addTestCase方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addTestCase
/**
* Add testcases to the provided TestSuite from the XML node
*
* @param TestSuite $testSuite
* @param \SimpleXMLElement $xml
*/
public function addTestCase(TestSuite $testSuite, \SimpleXMLElement $xml)
{
foreach ($xml->xpath('./testcase') as $element) {
$testcase = new TestCase((string) $element['name'], (int) $element['assertions'], (double) $element['time'], (string) $element['class'], (string) $element['file'], (int) $element['line']);
if ($element->error) {
$testcase->setError(new TestError((string) $element->error[0]->attributes()->type, (string) $element->error[0]));
}
if ($element->failure) {
$testcase->setFailure(new TestFailure((string) $element->failure[0]->attributes()->type, (string) $element->failure[0]));
}
$testSuite->addTestCase($testcase);
}
}
示例2: runAction
/**
* Runs all the unit tests we can find
*/
public function runAction()
{
/** FIXME: just a quick draft, copied from another file
and not expected to work. */
$view = Zend_Registry::getInstance()->view;
$registry = Zend_Registry::getInstance();
$path = realpath($registry->configuration->unittest->dir);
//$template = 'list/testcases.tpl';
/// copied from test_all.php in simpletest folder
$suite = new TestSuite('All tests');
/// TODO for all tests matching TestOf.+/.class/.php in folder {
// $suite->addTestCase( new Class in file );
$suite->addTestCase(new TestOfSimpleTest());
/// }
//$suite->addTestCase(new TestOfRequestHandle());
$suite->run(new HtmlReporter());
/////////////
}
示例3: runGroupTest
/**
* Runs a specific group test file
*
* @param string $groupTestName
* @param string $reporter
* @return void
* @access public
*/
function runGroupTest($groupTestName, &$reporter)
{
$manager = new TestManager();
$filePath = $manager->_getTestsPath('groups') . DS . strtolower($groupTestName) . $manager->_groupExtension;
if (!file_exists($filePath)) {
trigger_error("Group test {$groupTestName} cannot be found at {$filePath}", E_USER_ERROR);
}
require_once $filePath;
$test = new TestSuite($groupTestName . ' group test');
foreach ($manager->_getGroupTestClassNames($filePath) as $groupTest) {
$testCase = new $groupTest();
$test->addTestCase($testCase);
if (isset($testCase->label)) {
$test->_label = $testCase->label;
}
}
return $test->run($reporter);
}
示例4: run
<?php
include_once './core.testing.TestSuite.class.php';
include_once './core.testing.TestCase.class.php';
class CustomTestCase extends TestCase
{
public function run()
{
$this->test1();
$this->test2();
}
public function test1()
{
$this->assert(false, 'Testing de false');
}
public function test2()
{
throw new Exception("esto es una excepcion");
}
}
$suite = new TestSuite();
$tc = new CustomTestCase($suite);
$suite->addTestCase($tc);
$suite->run();
print_r($suite->getReports());
示例5: skip
function skip()
{
$this->skipIf(false);
$this->skipUnless(true);
}
function testFail()
{
$this->fail('We should see this message');
}
function testPass()
{
$this->pass('We should see this message');
}
}
$test = new TestSuite('Visual test with 50 passes, 50 fails and 7 exceptions');
$test->addTestCase(new PassingUnitTestCaseOutput());
$test->addTestCase(new FailingUnitTestCaseOutput());
$test->addTestCase(new VisualTestOfErrors());
$test->addTestCase(new TestOfMockObjectsOutput());
$test->addTestCase(new TestOfPastBugs());
$test->addTestCase(new TestOfVisualShell());
$test->addTestCase(new TestOfSkippingNoMatterWhat());
$test->addTestCase(new TestOfSkippingOrElse());
$test->addTestCase(new TestOfSkippingTwiceOver());
$test->addTestCase(new TestThatShouldNotBeSkipped());
if (isset($_GET['xml']) || in_array('xml', isset($argv) ? $argv : array())) {
$reporter = new XmlReporter();
} elseif (TextReporter::inCli()) {
$reporter = new TextReporter();
} else {
$reporter = new PassesAsWellReporter();
示例6: dirname
<?php
// $Id: detached_test.php 1505 2007-04-30 23:39:59Z lastcraft $
require_once '../detached.php';
require_once '../reporter.php';
// The following URL will depend on your own installation.
$command = 'php ' . dirname(__FILE__) . '/visual_test.php xml';
$test = new TestSuite('Remote tests');
$test->addTestCase(new DetachedTestCase($command));
if (SimpleReporter::inCli()) {
exit($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
示例7: elseif
<?php
// $Id: remote_test.php 1505 2007-04-30 23:39:59Z lastcraft $
require_once '../remote.php';
require_once '../reporter.php';
// The following URL will depend on your own installation.
if (isset($_SERVER['SCRIPT_URI'])) {
$base_uri = $_SERVER['SCRIPT_URI'];
} elseif (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['PHP_SELF'])) {
$base_uri = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
}
$test_url = str_replace('remote_test.php', 'visual_test.php', $base_uri);
$test = new TestSuite('Remote tests');
$test->addTestCase(new RemoteTestCase($test_url . '?xml=yes', $test_url . '?xml=yes&dry=yes'));
if (SimpleReporter::inCli()) {
exit($test->run(new TextReporter()) ? 0 : 1);
}
$test->run(new HtmlReporter());
示例8: loadTests
/**
* Genera una TestSuite con los TestCase definidos para esta aplicacion.
*/
public function loadTests()
{
$dir = dir($this->path . '/tests');
$testCases = array();
// Recorre directorio de la aplicacion
while (false !== ($test = $dir->read())) {
//echo $test.'<br/>';
// Se queda solo con los nombres de los directorios
if (is_file($this->path . '/tests/' . $test) && String::endsWith($test, 'class.php')) {
$testCases[] = $test;
}
}
// Crea instancias de las clases testcase
$suite = new TestSuite();
foreach ($testCases as $testCaseFile) {
$fi = FileNames::getFilenameInfo($testCaseFile);
$clazz = $fi['name'];
//print_r($fi);
YuppLoader::load($fi['package'], $clazz);
$suite->addTestCase(new $clazz($suite));
}
return $suite;
}
示例9: addTestFile
function addTestFile($file, $internalcall = false)
{
if ($this->showsearch) {
if ($internalcall) {
echo '<li><b>' . basename($file) . '</b></li>';
} else {
echo '<p>Adding test file: ' . realpath($file) . '</p>';
}
// Make sure that syntax errors show up suring the search, otherwise you often
// get blank screens because evil people turn down error_reporting elsewhere.
error_reporting(E_ALL);
}
if (!is_file($file)) {
parent::addTestCase(new BadTest($file, 'Not a file or does not exist'));
}
parent::addTestFile($file);
}
示例10: TestSuite
<?php
require_once 'bootstrap.php';
//require_once('../../autoload.php');
//require_once('../../application/bootstrap.php');
//require('../../library/app/wtf2.class.php');
// todo: print the result, don't use a zend viewer, keep this simple!
//Zend_Loader::registerAutoload('Tester');
$suite = new TestSuite('All tests');
/// @todo add all files in this dir that starts with 'TestOf'
$suite->addTestCase(new TestOfSimpleTest());
//$suite->addTestCase(new TestOfRequestHandle());
$suite->run(new HtmlReporter());
/**/
/*class AllTests extends TestSuite {
function AllTests(){
$this->TestSuite('All tests');
$this->addFile('test_simpletest.php');
$this->addFile('test_foo.php');
}
}/**/