function runAllTests() { $test = new TestSuite(); $test->addTestFile($this->webTestDir . 'wtest_uploadform.php'); $test->addTestFile($this->webTestDir . 'wtest_loginform.php'); $test->run(new HtmlReporter()); }
/** * 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()); }
public static function suite() { $suite = new TestSuite('onPHP-' . ONPHP_VERSION); foreach (self::$paths as $testPath) { foreach (glob($testPath . '*Test' . EXT_CLASS, GLOB_BRACE) as $file) { $suite->addTestFile($file); } } // meta, DB and DAOs ordered tests portion if (self::$dbs) { try { Singleton::getInstance('DBTestPool', self::$dbs)->connect(); } catch (Exception $e) { Singleton::dropInstance('DBTestPool'); Singleton::getInstance('DBTestPool'); } // build stuff from meta $metaDir = ONPHP_TEST_PATH . 'meta' . DIRECTORY_SEPARATOR; $path = ONPHP_META_PATH . 'bin' . DIRECTORY_SEPARATOR . 'build.php'; $_SERVER['argv'] = array(); $_SERVER['argv'][0] = $path; $_SERVER['argv'][1] = $metaDir . 'config.inc.php'; $_SERVER['argv'][2] = $metaDir . 'config.meta.xml'; $_SERVER['argv'][] = '--force'; $_SERVER['argv'][] = '--no-schema-check'; $_SERVER['argv'][] = '--drop-stale-files'; include $path; // provide paths to autogenerated stuff set_include_path(get_include_path() . PATH_SEPARATOR . ONPHP_META_AUTO_BUSINESS_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_DAO_DIR . PATH_SEPARATOR . ONPHP_META_AUTO_PROTO_DIR . PATH_SEPARATOR . ONPHP_META_DAO_DIR . PATH_SEPARATOR . ONPHP_META_BUSINESS_DIR . PATH_SEPARATOR . ONPHP_META_PROTO_DIR); $daoTest = new DAOTest(); $out = MetaConfiguration::me()->getOutput(); foreach (DBTestPool::me()->getPool() as $connector => $db) { DBPool::me()->setDefault($db); $out->info('Using ')->info(get_class($db), true)->infoLine(' connector.'); try { $daoTest->drop(); } catch (DatabaseException $e) { // previous shutdown was clean } $daoTest->create()->fill(false); MetaConfiguration::me()->checkIntegrity(); $out->newLine(); $daoTest->drop(); } DBPool::me()->dropDefault(); } $suite->addTestSuite('DAOTest'); return $suite; }
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()); }
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); }
public static function suite() { $suite = new TestSuite('onPHP-' . ONPHP_VERSION); // meta, DB and DAOs ordered tests portion if (self::$dbs) { try { /** * @todo fail - constructor with argument, but static method 'me' - without */ Singleton::getInstance('DBTestPool', self::$dbs)->connect(); } catch (Exception $e) { Singleton::dropInstance('DBTestPool'); Singleton::getInstance('DBTestPool'); } // build stuff from meta $metaDir = ONPHP_TEST_PATH . 'meta' . DIRECTORY_SEPARATOR; $path = ONPHP_META_PATH . 'bin' . DIRECTORY_SEPARATOR . 'build.php'; $_SERVER['argv'] = array(); $_SERVER['argv'][0] = $path; $_SERVER['argv'][1] = $metaDir . 'config.inc.php'; $_SERVER['argv'][2] = $metaDir . 'config.meta.xml'; $_SERVER['argv'][] = '--force'; $_SERVER['argv'][] = '--no-schema-check'; $_SERVER['argv'][] = '--drop-stale-files'; include $path; AutoloaderPool::get('onPHP')->addPaths(array(ONPHP_META_AUTO_BUSINESS_DIR, ONPHP_META_AUTO_DAO_DIR, ONPHP_META_AUTO_PROTO_DIR, ONPHP_META_DAO_DIR, ONPHP_META_BUSINESS_DIR, ONPHP_META_PROTO_DIR)); $dBCreator = DBTestCreator::create()->setSchemaPath(ONPHP_META_AUTO_DIR . 'schema.php')->setTestPool(DBTestPool::me()); $out = MetaConfiguration::me()->getOutput(); foreach (DBTestPool::me()->getPool() as $connector => $db) { DBPool::me()->setDefault($db); $out->info('Using ')->info(get_class($db), true)->infoLine(' connector.'); $dBCreator->dropDB(true); $dBCreator->createDB()->fillDB(); MetaConfiguration::me()->checkIntegrity(); $out->newLine(); $dBCreator->dropDB(); } DBPool::me()->dropDefault(); } foreach (self::$paths as $testPath) { foreach (glob($testPath . '*Test' . EXT_CLASS, GLOB_BRACE) as $file) { $suite->addTestFile($file); } } return $suite; }
public static function suite() { $suite = new TestSuite(); $finder = new Finder(); echo "Searching for installed bundles...\n"; $bundles = array(); foreach ($finder->directories()->in('../src/')->name('Tests') as $dir) { $target = $dir->getPathName(); $bundleName = basename(dirname($target)); $name = __DIR__ . "/{$bundleName}"; $bundles[] = $bundleName; if (!file_exists($name)) { echo "Adding bundle symlink: {$target}\n"; symlink($target, $name); } } echo "\nPurging broken symlinks...\n"; $finder = new Finder(); foreach ($bundles as $bundle) { /* will list only broken symlinks */ $symlinks = $finder->files()->in(__DIR__)->name('*Bundle'); foreach ($symlinks as $symlink) { if (!in_array($symlink->getFilename(), $bundles)) { echo "Removing broken bundle symlink: {$symlink->getFilename()}\n"; @unlink($symlink->getPathName()); } } } // ---------- COMMENT OUT TO TEST A SPECIFIC FILE ---------- // $suite->addTestFile('../src/<yourbundle>/DefaultBundle/Tests/Controller/SomeControllerTest.php'); // return $suite; // ---------- $finder = new Finder(); echo "\nSearching for test cases...\n"; foreach ($finder->files()->in('../src/')->name('*Test.php') as $file) { if (preg_match('%/Tests/[\\w-/]+Test.php%i', $file->getPathName())) { echo 'Adding test : ' . $file->getPathName() . "\n"; $suite->addTestFile($file->getPathName()); } } echo "\n"; return $suite; }
/** * Runs a specific test case file * * @param string $testCaseFile * @param string $reporter * @return void * @access public */ function runTestCase($testCaseFile, &$reporter, $testing = false) { $manager = new TestManager(); $testCaseFileWithPath = $manager->_getTestsPath() . DS . $testCaseFile; if (!file_exists($testCaseFileWithPath)) { trigger_error("Test case {$testCaseFile} cannot be found", E_USER_ERROR); return false; } if ($testing) { return true; } $test = new TestSuite("Individual test case: " . $testCaseFile); $test->addTestFile($testCaseFileWithPath); return $test->run($reporter); }
include ROOT . 'index.php'; $CI =& get_instance(); ob_end_clean(); $CI->load->library('session'); $CI->session->sess_destroy(); $CI->load->helper('directory'); // Get all main tests if ($run_all or !empty($_POST) && !isset($_POST['test'])) { $test_objs = array('controllers', 'models', 'views', 'libraries', 'bugs', 'helpers'); foreach ($test_objs as $obj) { if (isset($_POST[$obj]) or $run_all) { $dir = TESTS_DIR . $obj; $dir_files = directory_map($dir); foreach ($dir_files as $file) { if ($file != 'index.html') { $test_suite->addTestFile($dir . '/' . $file); } } } } } elseif (isset($_POST['test'])) { $file = $_POST['test']; if (file_exists(TESTS_DIR . $file)) { $test_suite->addTestFile(TESTS_DIR . $file); } } // ------------------------------------------------------------------------ /** * Function to map tests and strip .html files. * *
$test_path = "{$CONFIG->path}/engine/tests"; require_once "{$vendor_path}/unit_tester.php"; require_once "{$vendor_path}/mock_objects.php"; require_once "{$vendor_path}/reporter.php"; require_once "{$test_path}/elgg_unit_test.php"; // turn off system log elgg_unregister_event_handler('all', 'all', 'system_log_listener'); elgg_unregister_event_handler('log', 'systemlog', 'system_log_default_logger'); // Disable maximum execution time. // Tests take a while... set_time_limit(0); $suite = new TestSuite('Elgg Core Unit Tests'); // emit a hook to pull in all tests $test_files = elgg_trigger_plugin_hook('unit_test', 'system', null, array()); foreach ($test_files as $file) { $suite->addTestFile($file); } // Only run tests in debug mode. if (!isset($CONFIG->debug)) { exit('The site must be in debug mode to run unit tests.'); } if (TextReporter::inCli()) { // In CLI error codes are returned: 0 is success elgg_set_ignore_access(TRUE); exit($suite->Run(new TextReporter()) ? 0 : 1); } // Ensure that only logged-in users can see this page //admin_gatekeeper(); $old = elgg_set_ignore_access(TRUE); $suite->Run(new HtmlReporter('utf-8')); elgg_set_ignore_access($old);
<?php require_once '../unit_tester.php'; require_once '../reporter.php'; $test = new TestSuite('This should fail'); $test->addTestFile('test_with_parse_error.php'); $test->run(new HtmlReporter());
add_test('libraries', $file, $test); } } elseif (false !== strpos($file, '_bug')) { if (file_exists(TESTS_DIR . 'bugs/' . $file)) { add_test('bugs', $file, $test); } } elseif (false !== strpos($file, '_helper')) { if (file_exists(TESTS_DIR . 'helpers/' . $file)) { add_test('helpers', $file, $test); } } } } } } elseif (isset($_POST['test'])) { $file = $_POST['test']; //autorun will load failed test if no tests are present to run require_once SIMPLETEST . 'autorun.php'; require_once SIMPLETEST . 'web_tester.php'; require_once SIMPLETEST . 'mock_objects.php'; require_once SIMPLETEST . 'extensions/my_reporter.php'; $test = new TestSuite(); $test->_label = 'CodeIgniter Test Suite'; if (file_exists(TESTS_DIR . $file)) { $run_tests = TRUE; $test->addTestFile(TESTS_DIR . $file); } } $form_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //display the form include TESTS_DIR . 'test_gui.php';
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); }
/** * Runs all of the tests * @author Lachlan Donald */ require_once dirname(__FILE__) . '/testconfig.php'; require_once SIMPLEFORM_PATH . 'simpleform.php'; require_once SIMPLETEST_PATH . 'unit_tester.php'; require_once SIMPLETEST_PATH . 'reporter.php'; require_once SIMPLETEST_PATH . 'mock_objects.php'; // set up basic parameters error_reporting(E_ALL); ini_set("memory_limit", TEST_MEMORYLIMIT); // set up test class loading $testPath = SIMPLEFORM_TESTPATH . "testcases/"; $testClassLoader = new SimpleForm_ClassLoader($testPath); // run all tests $test = new TestSuite('All Tests'); //foreach(glob("$testPath/Test*.php") as $file) $test->addTestFile($file); // basic DOM tests $test->addTestFile("{$testPath}/TestDomHtmlElement.php"); $test->addTestFile("{$testPath}/TestDomInputElement.php"); $test->addTestFile("{$testPath}/TestDomTextareaElement.php"); $test->addTestFile("{$testPath}/TestDomSelectElement.php"); $test->addTestFile("{$testPath}/TestDomFormModel.php"); // other form components $test->addTestFile("{$testPath}/TestFormArrayHelper.php"); $test->addTestFile("{$testPath}/TestLabelParsing.php"); $test->addTestFile("{$testPath}/TestRequestInteraction.php"); // system tests $test->addTestFile("{$testPath}/TestForm.php"); $test->run(new HtmlReporter());
<?php /* * Limb PHP Framework * * @link http://limb-project.com * @copyright Copyright © 2004-2009 BIT(http://bit-creative.com) * @license LGPL http://www.gnu.org/copyleft/lesser.html */ if (isset($argv[1])) { define('SIMPLE_TEST', $argv[1]); } require_once dirname(__FILE__) . '/cases/.setup.php'; $group = new TestSuite(); foreach (glob(dirname(__FILE__) . '/cases/*Test.class.php') as $file) { $group->addTestFile($file); } if (!($res = $group->run(new TextReporter()))) { exit(1); }
add_test('helpers', $file, $test); } } } } } } elseif (isset($_POST['test'])) { $file = $_POST['test']; //autorun will load failed test if no tests are present to run require_once SIMPLETEST . 'autorun.php'; require_once SIMPLETEST . 'web_tester.php'; require_once SIMPLETEST . 'mock_objects.php'; require_once SIMPLETEST . 'extensions/my_reporter.php'; $test = new TestSuite(); $test->_label = '68kb Test Suite'; if (false !== strpos($file, 'addons')) { $file = str_replace('addons/', '', $file); if (file_exists(EXTPATH . $file)) { $run_tests = TRUE; $test->addTestFile(EXTPATH . $file); } } else { if (file_exists(TESTS_DIR . $file)) { $run_tests = TRUE; $test->addTestFile(TESTS_DIR . $file); } } } $form_url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; //display the form include TESTS_DIR . 'test_gui.php';