/**
  * 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);
     }
 }
 /**
  * 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());
     /////////////
 }
Exemplo n.º 3
0
 /**
  * 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);
 }
Exemplo n.º 4
0
<?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());
Exemplo n.º 5
0
    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();
Exemplo n.º 6
0
<?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());
Exemplo n.º 7
0
<?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());
Exemplo n.º 8
0
 /**
  * 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;
 }
 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);
 }
<?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');
    }
}/**/