function &_getRegistry() { static $registry = false; if (!$registry) { $registry = SimpleTestOptions::_getDefaults(); } return $registry; }
function AllTests() { $this->GroupTest('All tests for SimpleTest ' . SimpleTestOptions::getVersion()); $this->AddTestCase(new UnitTests()); $this->addTestFile('shell_test.php'); $this->addTestFile('live_test.php'); $this->addTestFile('acceptance_test.php'); $this->addTestFile('real_sites_test.php'); }
***********************************************************************************/ require_once LIMB_DIR . 'core/lib/db/db_factory.class.php'; require_once LIMB_DIR . 'core/model/site_objects/site_object.class.php'; require_once LIMB_DIR . 'core/model/site_object_factory.class.php'; class mock_root_object extends site_object { function mock_root_object() { parent::site_object(); } function _define_class_properties() { return array('can_be_parent' => 1); } } SimpleTestOptions::ignore('test_site_object_template'); class test_site_object_template extends UnitTestCase { var $db = null; var $object = null; var $parent_node_id = ''; var $sub_node_id = ''; function test_site_object_template() { $this->db =& db_factory::instance(); parent::UnitTestCase(); } function &_create_site_object() { return null; }
<?php /********************************************************************************** * Copyright 2004 BIT, Ltd. http://limb-project.com, mailto: support@limb-project.com * * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id: CacheRegistryTest.class.php 1340 2005-05-31 15:01:35Z pachanga $ * ***********************************************************************************/ SimpleTestOptions :: ignore('CacheBaseTest'); // NOTE: abstract class class CacheBaseTest extends LimbTestCase { var $cache; function &_createPersisterImp() { return null; } function setUp() { $this->cache =& $this->_createPersisterImp(); $this->cache->flushAll(); } function testGetId() { $this->assertNotNull($this->cache->getId());
/** * Accessor for additional partial mock code. * @return string Extra code. * @access public */ function getPartialMockCode() { $registry =& SimpleTestOptions::_getRegistry(); return $registry['AdditionalPartialMockCode']; }
function _createGroupFromClasses($title, $classes) { $group = new GroupTest($title); foreach ($classes as $class) { if (SimpleTestOptions::isIgnored($class)) { continue; } $group->addTestClass($class); } return $group; }
* * $Id$ * ***********************************************************************************/ require_once LIMB_DIR . '/core/lib/util/dataspace.class.php'; class NullClass { } class Filter { function do_filter() { } } Mock::generate('Filter', 'MockFilter'); SimpleTestOptions::ignore('dataspace_test'); class dataspace_test extends UnitTestCase { var $dataspace; var $filter; function setUp() { $this->dataspace = new dataspace(); } function tearDown() { unset($this->dataspace); } function test_instance() { $d1 =& dataspace::instance('test');
<?php /** * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved * * * * abstract */ class SanitizerTestCase extends UnitTestCase { function SimpleSanitizerTest($test_name = false) { $this->UnitTestCase($test_name); } function testSanitize() { trigger_error("testSanitize() not yet implemented"); } } //We just tells SimpleTest to always ignore this testcase SimpleTestOptions::ignore('SanitizerTestCase');
* * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite> * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * * Licensed under The Open Group Test Suite License * Redistributions of files must retain the above copyright notice. * * @filesource * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org) * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests * @package cake * @subpackage cake.cake.tests.lib * @since CakePHP(tm) v 1.2.0.4433 * @version $Revision$ * @modifiedby $LastChangedBy$ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ /** * Short description */ SimpleTestOptions::ignore('CakeWebTestCase'); /** * Short description for class. * * @package cake * @subpackage cake.cake.tests.lib */ class CakeWebTestCase extends WebTestCase { }
<?php /********************************************************************************** * Copyright 2004 BIT, Ltd. http://limb-project.com, mailto: support@limb-project.com * * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id$ * ***********************************************************************************/ require_once(LIMB_DIR . '/class/core/Dataspace.class.php'); SimpleTestOptions :: ignore('DataspaceTest'); class DataspaceTest extends LimbTestCase { var $dataspace; var $filter; function setUp() { $this->dataspace = new Dataspace(); } function tearDown() { unset($this->dataspace); } function testGetUnsetVariable() {
/** * @deprecated */ function setMockBaseClass($mock_base = false) { SimpleTestOptions::setMockBaseClass($mock_base); }
<?php SimpleTestOptions::ignore('AbstractComponentAdapterTestCase'); abstract class AbstractComponentAdapterTestCase extends UnitTestCase { protected abstract function getComponentAdapterType(); protected function getDefaultPico() { return new DefaultPicoContainer($this->createDefaultComponentAdapterFactory()); } function testDEF_createsNewInstanceWithoutParams() { $picoContainer = $this->getDefaultPico(); $componentAdapter = $this->prepDEF_createsNewInstanceWithoutParams(); $this->assertEqual($this->getComponentAdapterType(), get_class($componentAdapter)); $this->assertNotNull($componentAdapter->getComponentInstance($picoContainer)); } function testDEF_createsNewInstanceWithConstantParamAndWithHint() { $picoContainer = $this->getDefaultPico(); $componentAdapter = $this->prepDEF_createsNewInstanceWithConstantParamAndWithHint(); $this->assertNotNull($ci = $componentAdapter->getComponentInstance($picoContainer)); } } class SetterInjectionComponentAdapterTestCase extends AbstractComponentAdapterTestCase { protected function getComponentAdapterType() { return 'SetterInjectionComponentAdapter'; } protected function createDefaultComponentAdapterFactory()
<?php /********************************************************************************** * Copyright 2004 BIT, Ltd. http://www.0x00.ru, mailto: bit@0x00.ru * * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id$ * ***********************************************************************************/ require_once LIMB_DIR . 'core/tree/tree.class.php'; require_once LIMB_DIR . 'core/lib/db/db_factory.class.php'; require_once LIMB_DIR . 'core/fetcher.class.php'; require_once LIMB_DIR . 'tests/cases/db_test.class.php'; SimpleTestOptions::ignore('limb_test'); class limb_test extends db_test { function limb_test() { parent::db_test(); } function tearDown() { parent::tearDown(); $user =& user::instance(); $user->logout(); } function _login_user($id, $groups) { $user =& user::instance();
<?php /********************************************************************************** * Copyright 2004 BIT, Ltd. http://www.0x00.ru, mailto: bit@0x00.ru * * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id$ * ***********************************************************************************/ require_once LIMB_DIR . 'core/lib/db/db_factory.class.php'; SimpleTestOptions::ignore('test_db_case'); class test_db_case extends UnitTestCase { var $db = null; var $dump_file = ''; var $tables_list = array(); var $table_records = array(); var $sql_array = array(); function test_db_case() { $this->db =& db_factory::instance(); parent::UnitTestCase(); } function _clean_up() { foreach ($this->tables_list as $table) { $this->db->sql_delete($table); } }
function AllTests() { $this->GroupTest("All tests for SimpleTest " . SimpleTestOptions::getVersion()); $this->AddTestCase(new UnitTests()); $this->AddTestCase(new BoundaryTests()); }
$col2->add($b); $this->assertFalse($col1->equals($col2)); } function testInitialArray() { $a = new StdClass(); $a->toto = 1; $b = new StdClass(); $b->toto = 2; $arr = array(); $arr[] = $a; $arr[] = $b; $col = new $this->collection_class_name($arr); $this->assertTrue($col->contains($a)); $this->assertTrue($col->contains($b)); } function testRemove() { $a = new StdClass(); $col = new $this->collection_class_name(); $col->add($a); $this->assertTrue($col->contains($a)); $this->assertTrue($col->remove($a)); $this->assertFalse($col->contains($a)); $col->remove($a); $this->assertFalse($col->remove($a)); } } //We just tells SimpleTest to always ignore this testcase SimpleTestOptions::ignore('CollectionTestCase');
<?php /********************************************************************************** * Copyright 2004 BIT, Ltd. http://limb-project.com, mailto: support@limb-project.com * * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id$ * ***********************************************************************************/ @define('PHP_IMAGE_DIR_C', LIMB_DIR . '/core/image/'); SimpleTestOptions :: ignore('ImageLibraryTest'); class ImageLibraryTest extends LimbTestCase { var $library = null; var $input_file = ''; var $output_file = ''; function setUp() { $this->input_file = LIMB_DIR . '/tests/cases/image/images/input.jpg'; $this->output_file = VAR_DIR . '/output.jpg'; if(!file_exists($this->output_file)) touch($this->output_file); $input_type = 'jpeg'; $output_type = 'jpeg'; $this->library->setInputFile($this->input_file, $input_type);
/** * Output anything that should appear below all the test output, e.g. summary information. */ function paintFooter($test_name) { $summarydata = new stdClass(); $summarydata->run = $this->getTestCaseProgress(); $summarydata->total = $this->getTestCaseCount(); $summarydata->passes = $this->getPassCount(); $summarydata->fails = $this->getFailCount(); $summarydata->exceptions = $this->getExceptionCount(); if ($summarydata->fails == 0 && $summarydata->exceptions == 0) { $status = "passed"; } else { $status = "failed"; } echo '<div class="unittestsummary ', $status, '">'; echo $this->get_string('summary', $summarydata); echo '</div>'; echo '<div class="performanceinfo">', $this->get_string('runat', userdate($this->timestart)), ' ', $this->get_string('timetakes', format_time(time() - $this->timestart)), ' ', $this->get_string('version', SimpleTestOptions::getVersion()), '</div>'; }
/** * @deprecated */ function ignore($class = false) { SimpleTestOptions::ignore($class); }
<?php require_once DOKU_INC . 'inc/html.php'; if (!extension_loaded('runkit')) { SimpleTestOptions::ignore('html_hilight_test'); trigger_error('Skipping html_hilight_test - http://www.php.net/runkit required'); } function html_hilight_test_unslash($string, $char = "'") { $str = str_replace('\\' . $char, $char, $string); return $str; } class html_hilight_test extends UnitTestCase { function setup() { if (function_exists('unslash')) { runkit_function_rename('unslash', 'html_hilight_test_unslash_real'); } runkit_function_rename('html_hilight_test_unslash', 'unslash'); } function teardown() { runkit_function_rename('unslash', 'html_hilight_test_unslash'); if (function_exists('html_hilight_test_unslash_real')) { runkit_function_rename('html_hilight_test_unslash_real', 'unslash'); } } function testHighlightOneWord() { $html = 'Foo bar Foo';
function testIgnoreList() { $this->assertFalse(SimpleTestOptions::isIgnored('ImaginaryTestCase')); SimpleTestOptions::ignore('ImaginaryTestCase'); $this->assertTrue(SimpleTestOptions::isIgnored('ImaginaryTestCase')); }
<?php /********************************************************************************** * Copyright 2004 BIT, Ltd. http://limb-project.com, mailto: support@limb-project.com * * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id$ * ***********************************************************************************/ define('TEST_PACKAGES_RESOLVER_DIR', dirname(__FILE__) . '/packages/'); SimpleTestOptions :: ignore('BasePackageFileResolverTest'); class BasePackageFileResolverTest extends LimbTestCase { var $resolver; function & _defineResolver() { die('abstract method: define file resolver!'); } function setUp() { Limb :: toolkit()->flushINICache(); PackagesInfo :: instance()->reset(); DebugMock :: init($this); $this->resolver =& $this->_defineResolver();
* * $Id$ * ***********************************************************************************/ require_once LIMB_DIR . '/core/lib/util/dataspace.class.php'; class NullClass { } class Filter { function do_filter() { } } Mock::generate('Filter', 'MockFilter'); SimpleTestOptions::ignore('shared_data_space_test_case'); class shared_data_space_test_case extends UnitTestCase { var $dataspace; var $filter; function shared_data_space_test_case($name = 'dataspace_test_case') { $this->UnitTestCase($name); } function setUp() { $this->dataspace = new dataspace(); } function tearDown() { unset($this->dataspace);
<?php /********************************************************************************** * Copyright 2004 BIT, Ltd. http://www.0x00.ru, mailto: bit@0x00.ru * * Released under the LGPL license (http://www.gnu.org/copyleft/lesser.html) *********************************************************************************** * * $Id$ * ***********************************************************************************/ if (!defined('PHP_IMAGE_DIR_C')) define('PHP_IMAGE_DIR_C', LIMB_DIR . 'core/lib/image/'); SimpleTestOptions::ignore('image_library_test'); class image_library_test extends UnitTestCase { var $library = null; var $input_file = ''; var $output_file = ''; function setUp() { $this->input_file = LIMB_DIR . '/tests/cases/image/images/input.jpg'; $this->output_file = VAR_DIR . '/output.jpg'; if(!file_exists($this->output_file)) touch($this->output_file); $input_type = 'jpeg'; $output_type = 'jpeg';
$mock->expectArgumentsAt(1, "aMethod", array("Hello")); $mock->aMethod(1, 2); $mock->aMethod("Goodbye"); } function testBadArgParameter() { $mock =& new MockDummy($this); $mock->expectArguments("aMethod", "foo"); $this->assertErrorPattern('/\\$args.*not an array/i'); $mock->aMethod(); $mock->tally(); } } SimpleTestOptions::addPartialMockCode('function sayHello() { return "Hello"; }'); Mock::generatePartial("Dummy", "TestDummy", array("anotherMethod")); SimpleTestOptions::addPartialMockCode(); class TestOfPartialMocks extends UnitTestCase { function TestOfPartialMocks() { $this->UnitTestCase(); } function testMethodReplacement() { $mock =& new TestDummy($this); $this->assertEqual($mock->aMethod(99), 99); $this->assertNull($mock->anotherMethod()); } function testSettingReturns() { $mock =& new TestDummy($this);
function setUp() { $this->addHeader('User-Agent: SimpleTest ' . SimpleTestOptions::getVersion()); }
<?php // $Id$ if (!defined("SIMPLE_TEST")) { define("SIMPLE_TEST", "../"); } require_once SIMPLE_TEST . 'xml.php'; Mock::generate('SimpleRunner'); if (!function_exists('xml_parser_create')) { SimpleTestOptions::ignore('TestOfXmlStructureParsing'); SimpleTestOptions::ignore('TestOfXmlResultsParsing'); } class TestOfNestingTags extends UnitTestCase { function TestOfNestingTags() { $this->UnitTestCase(); } function testGroupSize() { $nesting = new NestingGroupTag(array('SIZE' => 2)); $this->assertEqual($nesting->getSize(), 2); } } class TestOfXmlStructureParsing extends UnitTestCase { function TestOfXmlStructureParsing() { $this->UnitTestCase(); } function testValidXml()
parent::content_object(); } function _define_class_properties() { $props = $this->content_object->get_class_properties(); if (!isset($props['db_table_name'])) { $props['db_table_name'] = get_class($this->content_object); } return $props; } function get_db_table() { return $this->_get_db_table(); } } SimpleTestOptions::ignore('test_content_object_template'); class test_content_object_template extends test_site_object_template { function test_content_object_template() { parent::test_site_object_template(); } function _clean_up() { parent::_clean_up(); $this->db->sql_delete('sys_object_version'); $this->_clean_content_db_table_records(); } function _clean_content_db_table_records() { $content_object_adapter = new content_object_template_test_adapter($this->object);
/** * Starts with a fresh browser with no * cookie or any other state information. The * exception is that a default proxy will be * set up if specified in the options. * @access public */ function SimpleBrowser() { $this->_user_agent = &$this->_createUserAgent(); $this->_user_agent->useProxy( SimpleTestOptions::getDefaultProxy(), SimpleTestOptions::getDefaultProxyUsername(), SimpleTestOptions::getDefaultProxyPassword()); $this->_page = &new SimplePage(); $this->_history = &$this->_createHistory(); $this->_ignore_frames = false; }
<?php // $Id$ require_once dirname(__FILE__) . '/../unit_tester.php'; require_once dirname(__FILE__) . '/../socket.php'; require_once dirname(__FILE__) . '/../http.php'; require_once dirname(__FILE__) . '/../options.php'; if (SimpleTestOptions::getDefaultProxy()) { SimpleTestOptions::ignore('LiveHttpTestCase'); } class LiveHttpTestCase extends UnitTestCase { function testBadSocket() { $socket =& new SimpleSocket('bad_url', 111, 5); $this->assertTrue($socket->isError()); $this->assertWantedPattern('/Cannot open \\[bad_url:111\\] with \\[.*?\\] within \\[5\\] seconds/', $socket->getError()); $this->assertFalse($socket->isOpen()); $this->assertFalse($socket->write('A message')); } function testSocketClosure() { $socket =& new SimpleSocket('www.lastcraft.com', 80, 15); $this->assertTrue($socket->isOpen()); $this->assertTrue($socket->write("GET /test/network_confirm.php HTTP/1.0\r\n")); $socket->write("Host: www.lastcraft.com\r\n"); $socket->write("Connection: close\r\n\r\n"); $this->assertEqual($socket->read(8), "HTTP/1.1"); $socket->close(); $this->assertIdentical($socket->read(8), false); }