/** * Load the tests that are defined in the named modules. * * If you have Tests/Foo.php which defines a test class called * Tests_Foo, the call would look like: * * loadTests('Tests/', array('Foo')) * * @param string $test_dir The root of the test hierarchy. Must end * with a / * * @param array $test_names The names of the modules in which the * tests are defined. This should not include the root of the test * hierarchy. */ function loadTests($test_dir, $test_names) { global $_tests; $suites = array(); foreach ($test_names as $filename) { $filename = $test_dir . $filename . '.php'; $class_name = str_replace('/', '_', $filename); $class_name = basename($class_name, '.php'); if (!global_require_once($filename)) { continue; } $test = new $class_name($class_name); if (is_a($test, 'PHPUnit_TestCase')) { $s = new PHPUnit_TestSuite(); $s->setName($class_name); $s->addTestSuite($class_name); $test = $s; $tc_array_name = $class_name . '_other'; if (array_key_exists($tc_array_name, $GLOBALS) && is_array($GLOBALS[$tc_array_name])) { foreach ($GLOBALS[$tc_array_name] as $tc) { $test->addTestSuite(get_class($tc)); } } } $suites[] = $test; } return $suites; }
function makeSuite($class_name) { $test = new $class_name($class_name); if (is_a($test, 'PHPUnit_TestCase')) { $s = new PHPUnit_TestSuite(); $s->setName($class_name); $s->addTestSuite($class_name); $test = $s; } $tc_array_name = $class_name . '_other'; if (array_key_exists($tc_array_name, $GLOBALS) && is_array($GLOBALS[$tc_array_name])) { foreach ($GLOBALS[$tc_array_name] as $tc) { $test->addTestSuite(get_class($tc)); } } return $test; }
$message2->delete(); $message->fetch(); $threadCount2 = $message->getNumMessagesInThread(); if ($threadCount != ($threadCount2 + 1)) { $this->fail("Thread stats not updated correctly."); } } } // class PhorumMessage_test class PhorumForum_test extends PHPUnit_TestCase { } $suite = new PHPUnit_TestSuite("PhorumUser_Test"); $suite->addTestSuite("PhorumMessage_Test"); $result = PHPUnit::run($suite); echo $result->toHtml(); //$message = new Phorum_message(1); //camp_dump($message); ?>
} function tearDown() { } /** * Try to work with this ill-formed feed. If the tidy extension is not installed, * it expects parsing to fail. If tidy is installed and parsing fails, the test * fails. If tidy is installed and it parses, then the test passes. */ function test_Tidy() { $sample_dir = XML_Feed_Parser_TestCase::getSampleDir(); $file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . "illformed_atom10.xml"); try { $feed = new XML_Feed_Parser($file, false, true, true); } catch (XML_Feed_Parser_Exception $e) { if (extension_loaded('tidy')) { $this->assertTrue(false); } else { $this->assertTrue(true); } return; } $entry = $feed->getEntryByOffset(0); $this->assertEquals($entry->author, 'Example author'); } } $suite = new PHPUnit_TestSuite(); $suite->addTestSuite("XML_Feed_Parser_Tidy_TestCase"); $result = PHPUnit::run($suite, "123"); echo $result->toString();
} function test_entryAuthorEquivalence() { $value = "Simon St.Laurent (mailto:simonstl@simonstl.com)"; $this->assertEquals($value, $this->entry->author); } function test_entryPublisher() { $value = "The O'Reilly Network"; $this->assertEquals($value, $this->entry->publisher); } function test_entryCategory() { $value = "XML"; $this->assertEquals($value, $this->entry->category); } function test_entryIdEquivalence() { $value = "http://c.moreover.com/click/here.pl?r123"; $this->assertEquals($value, $this->entry->id); } function test_feedTextInput() { $value = array('title' => null, 'description' => null, 'name' => null, 'link' => "http://meerkat.oreillynet.com"); $this->assertEquals($value, $this->feed->textinput); } } $suite = new PHPUnit_TestSuite(); $suite->addTestSuite("XML_Feed_Parser_RSS1_valueValidity_TestCase"); $result = PHPUnit::run($suite, "123"); echo $result->toString();
function test_Contributor2() { $value = 'Joe Gregorio'; $this->assertEquals($this->entry->contributor(1), $value); } function test_Content() { $value = '<p><i>[Update: The Atom draft is finished.]</i></p>'; $content = trim(preg_replace('/\\t/', ' ', $this->entry->content)); $content = preg_replace('/(\\s\\s)+/', ' ', $content); $this->assertEquals($value, $content); } function test_Link() { $value = 'http://example.org/2005/04/02/atom'; $this->assertEquals($this->entry->link, $value); } function test_Enclosure() { $value = array('url' => 'http://example.org/audio/ph34r_my_podcast.mp3', 'type' => 'audio/mpeg', 'length' => '1337'); $this->assertEquals($this->entry->enclosure, $value); } function test_entryXPath() { $this->assertEquals('http://example.org/2005/04/02/atom', $this->entry->link(0, 'href', array('rel' => 'alternate'))); } } $suite = new PHPUnit_TestSuite(); $suite->addTestSuite('XML_Feed_Parser_AtomEntryOnly_TestCase'); $result = PHPUnit::run($suite, '123'); echo $result->toString();
function __construct($name) { $this->PHPUnit_TestCase($name); $sample_dir = XML_Feed_Parser_TestCase::getSampleDir(); $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'technorati.feed'); $this->feed = new XML_Feed_Parser($this->file); $this->entry = $this->feed->getEntryByOffset(0); } } class XML_Feed_Parser_AccessTypes8_TestCase extends XML_Feed_Parser_AccessTypes1_TestCase { function __construct($name) { $this->PHPUnit_TestCase($name); $sample_dir = XML_Feed_Parser_TestCase::getSampleDir(); $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'grwifi-atom.xml'); $this->feed = new XML_Feed_Parser($this->file); $this->entry = $this->feed->getEntryByOffset(0); } } $suite = new PHPUnit_TestSuite(); $suite->addTestSuite('XML_Feed_Parser_AccessTypes1_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AccessTypes2_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AccessTypes3_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AccessTypes4_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AccessTypes5_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AccessTypes6_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AccessTypes7_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AccessTypes8_TestCase'); $result = PHPUnit::run($suite, '123'); echo $result->toString();
class pfcContainerTestcase_Mysql extends pfcContainerTestcase { // constructor of the test suite function pfcContainerTestcase_Mysql($name) { $this->type = "Mysql"; $this->pfcContainerTestcase($name); } // called before the test functions will be executed // this function is defined in PHPUnit_TestCase and overwritten // here function setUp() { pfcContainerTestcase::setUp(); } // called after the test functions are executed // this function is defined in PHPUnit_TestCase and overwritten // here function tearDown() { pfcContainerTestcase::tearDown(); } } // on desactive le timeout car se script peut mettre bcp de temps a s'executer ini_set('max_execution_time', 0); $suite = new PHPUnit_TestSuite(); $suite->addTestSuite("pfcContainerTestcase_Mysql"); $result =& PHPUnit::run($suite); echo "<pre>"; print_r($result->toString()); echo "</pre>";
fail</strong>. Exactly those with <code>pass</code> in their name should succeed. </p> <p> For each test we display both the test result -- <span class="Pass">ok</span>, <span class="Failure">FAIL</span>, or <span class="Error">ERROR</span> -- and also a meta-result -- <span class="Expected">as expected</span>, <span class="Unexpected">UNEXPECTED</span>, or <span class="Unknown">unknown</span> -- that indicates whether the expected test result occurred. Although many test results will be 'FAIL' here, all meta-results should be 'as expected', except for a few 'unknown' meta-results (because of errors) when running in PHP3. </p> <h2>Tests</h2> <?php $testcases = array('HTML_Progress_TestCase_addListener', 'HTML_Progress_TestCase_DM_new', 'HTML_Progress_TestCase_DM_setIncrement', 'HTML_Progress_TestCase_DM_setMaximum', 'HTML_Progress_TestCase_DM_setMinimum', 'HTML_Progress_TestCase_DM_setValue', 'HTML_Progress_TestCase_getDM', 'HTML_Progress_TestCase_getString', 'HTML_Progress_TestCase_getUI', 'HTML_Progress_TestCase_removeListener', 'HTML_Progress_TestCase_setAnimSpeed', 'HTML_Progress_TestCase_setBorderPainted', 'HTML_Progress_TestCase_setDM', 'HTML_Progress_TestCase_setIndeterminate', 'HTML_Progress_TestCase_setModel', 'HTML_Progress_TestCase_setString', 'HTML_Progress_TestCase_setStringPainted', 'HTML_Progress_TestCase_setUI', 'HTML_Progress_TestCase_UI_getBorderAttributes', 'HTML_Progress_TestCase_UI_getCellAttributes', 'HTML_Progress_TestCase_UI_getProgressAttributes', 'HTML_Progress_TestCase_UI_getStringAttributes', 'HTML_Progress_TestCase_UI_new', 'HTML_Progress_TestCase_UI_setCellAttributes', 'HTML_Progress_TestCase_UI_setCellCoordinates', 'HTML_Progress_TestCase_UI_setCellCount', 'HTML_Progress_TestCase_UI_setFillWay', 'HTML_Progress_TestCase_UI_setOrientation', 'HTML_Progress_TestCase_UI_setScript'); $suite = new PHPUnit_TestSuite(); foreach ($testcases as $testcase) { include_once $testcase . '.php'; $suite->addTestSuite($testcase); } $listener = new HTML_TestListener(); $result = TestUnit::run($suite, $listener); $result->removeListener($listener); $result->report(); ?> </body> </html>
function test_missingElement() { $file = '<?xml version="1.0" encoding="utf-8"?> <rss version="2.0"> <channel> <title>sample blog</title> <link>http://www.example.com/</link> <description>sample rss2 feed</description> <language>en</language> <copyright>Copyright 2006</copyright> <lastBuildDate>Tue, 25 Jul 2006 11:53:38 -0500</lastBuildDate> <generator>http://www.sixapart.com/movabletype/?v=3.31</generator> <docs>http://blogs.law.harvard.edu/tech/rss</docs> <item> <title>A sample entry</title> <description>Sample content</description> <link>http://www.example.com/archives/2006/07</link> <guid>http://www.example.com/archives/2006/07</guid> <category>Examples</category> <pubDate>Tue, 25 Jul 2006 11:53:38 -0500</pubDate> </item> </channel></rss>'; $feed = new XML_Feed_Parser($file, false, true); $entry = $feed->getEntryByOffset(0); $this->assertFalse($entry->enclosure()); } } $suite = new PHPUnit_TestSuite(); $suite->addTestSuite("XML_Feed_Parser_ThrowErrors_TestCase"); $result = PHPUnit::run($suite, "123"); echo $result->toString();
// $Id: gui.php,v 1.2 2003/03/20 19:34:20 pukomuko Exp $ // naujas branch'as niu o mes einam toliau? define('RELPATH', '../'); include '../site.header.php'; // Set the name of your testsuite class $testName = "flexiUpdate3 tests"; // Set the path of your testsuite file $testFile = "test_tpl.php"; require_once "PHPUnit/PHPUnit.php"; require_once 'dbtest.php'; require_once 'xmlinitests.php'; require_once 'sessiontest.php'; // run test $suite = new PHPUnit_TestSuite(); $suite->addTestSuite('dbtest'); $suite->addTestSuite('xmliniTest'); $suite->addTestSuite('sessionTest'); $result = PHPUnit::run($suite); // do some calculations $per = 100 / $result->runCount(); $notOkWidth = $per * $result->errorCount() + $per * $result->failureCount(); $okWidth = 100 - $notOkWidth; ?> <html> <head> <title>unitTests - flexiUpdate 3.0 pre0</title> </head> <body style="font-family:Verdana;"><center> <h2><?php
<?php $path = dirname(__FILE__) . '/../../../library/pear'; set_include_path(get_include_path() . PATH_SEPARATOR . $path); $WHITE_SCREEN_OF_DEATH = false; require_once dirname(__FILE__) . '/../../configs/conf.php'; require_once 'DB.php'; require_once 'PHPUnit.php'; require_once 'StoredFileTests.php'; require_once 'SchedulerTests.php'; //require_once 'SchedulerExportTests.php'; require_once 'PlaylistTests.php'; //$suite = new PHPUnit_TestSuite("PlayListTests"); //$suite = new PHPUnit_TestSuite("SchedulerTests"); $suite = new PHPUnit_TestSuite("StoredFileTest"); $suite->addTestSuite("PlaylistTests"); $suite->addTestSuite("SchedulerTests"); //$suite->addTestSuite("SchedulerExportTests"); $result = PHPUnit::run($suite); echo $result->toString();
$sample_dir = XML_Feed_Parser_TestCase::getSampleDir(); $feed = new XML_Feed_Parser(file_get_contents($this->sample_dir . "/grwifi-atom.xml")); $entries = array(); foreach ($feed as $entry) { array_push($entries, $entry); } $this->assertNotSame($entries[0], $entries[1]); } function test_RSS1() { $feed = new XML_Feed_Parser(file_get_contents($this->sample_dir . "/delicious.feed")); $entries = array(); foreach ($feed as $entry) { array_push($entries, $entry); } $this->assertNotSame($entries[0], $entries[1]); } function test_RSS2() { $feed = new XML_Feed_Parser(file_get_contents($this->sample_dir . "/rss2sample.xml")); $entries = array(); foreach ($feed as $entry) { array_push($entries, $entry); } $this->assertNotSame($entries[0], $entries[1]); } } $suite = new PHPUnit_TestSuite(); $suite->addTestSuite("XML_Feed_Parser_Iteration_TestCase"); $result = PHPUnit::run($suite, "123"); echo $result->toString();
function __construct($name) { $this->PHPUnit_TestCase($name); $sample_dir = XML_Feed_Parser_TestCase::getSampleDir(); $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'technorati.feed'); $this->parser = new XML_Feed_Parser($this->file); $this->entry = $this->parser->getEntryByOffset(0); } } class XML_Feed_Parser_AtomCompat8_TestCase extends XML_Feed_Parser_AtomCompat1_TestCase { function __construct($name) { $this->PHPUnit_TestCase($name); $sample_dir = XML_Feed_Parser_TestCase::getSampleDir(); $this->file = file_get_contents($sample_dir . DIRECTORY_SEPARATOR . 'grwifi-atom.xml'); $this->parser = new XML_Feed_Parser($this->file); $this->entry = $this->parser->getEntryByOffset(0); } } $suite = new PHPUnit_TestSuite(); $suite->addTestSuite('XML_Feed_Parser_AtomCompat1_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AtomCompat2_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AtomCompat3_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AtomCompat4_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AtomCompat5_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AtomCompat6_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AtomCompat7_TestCase'); $suite->addTestSuite('XML_Feed_Parser_AtomCompat8_TestCase'); $result = PHPUnit::run($suite, '123'); echo $result->toString();
$prefix = __FUNCTION__; $group = $prefix . "_nickid-to-channelid"; $subgroup = $prefix . "_nickid1"; $leaf1 = $prefix . "_channelid1"; $leaf2 = $prefix . "_channelid2"; $ret = $ct->setMeta($group, $subgroup, $leaf1); $ret = $ct->setMeta($group, $subgroup, $leaf2); $ret = $ct->rmMeta($group); $this->assertEquals($ret, true, "the returned value should be true (rm success)"); $f = $c->container_cfg_server_dir . '/' . $group . '/' . $subgroup . '/' . $leaf1; $ret = file_exists($f); $this->assertEquals($ret, false, "the leaf file should not exists anymore"); $f = $c->container_cfg_server_dir . '/' . $group . '/' . $subgroup . '/' . $leaf2; $ret = file_exists($f); $this->assertEquals($ret, false, "the leaf file should not exists anymore"); $d = $c->container_cfg_server_dir . '/' . $group . '/' . $subgroup; $ret = file_exists($d); $this->assertEquals($ret, false, "the subgroup directory should not exists anymore"); $d = $c->container_cfg_server_dir . '/' . $group; $ret = file_exists($d); $this->assertEquals($ret, false, "the group directory should not exists anymore"); } } // on desactive le timeout car se script peut mettre bcp de temps a s'executer ini_set('max_execution_time', 0); $suite = new PHPUnit_TestSuite(); $suite->addTestSuite("pfcContainerTestcase_File"); $result =& PHPUnit::run($suite); echo "<pre>"; print_r($result->toString()); echo "</pre>";