/** * A method to return the HTML code needed to display a tree-based * menu of all the OpenX tests. * * @return string A string containing the HTML code needed to display * the tests in a tree-based menu. */ function buildTree() { preg_match('/^(\\d+\\.\\d+)/', VERSION, $aMatches); // Create the root of the test suite $menu = new HTML_TreeMenu(); $rootNode = new HTML_TreeNode(array('text' => PRODUCT_NAME . ' ' . $aMatches[1] . ' Tests', 'icon' => "package.png")); // Create the top-level test groups foreach ($GLOBALS['_MAX']['TEST']['groups'] as $type) { $nodeName = $type . 'RootNode'; ${$nodeName} = new HTML_TreeNode(array('text' => ucwords($type) . ' Test Suite', 'icon' => "package.png", 'link' => "run.php?type={$type}&level=all", 'linkTarget' => "right")); $structure = TestFiles::getAllTestFiles($type); foreach ($structure as $layerCode => $folders) { $firstNode =& ${$nodeName}->addItem(new HTML_TreeNode(array('text' => $GLOBALS['_MAX']['TEST'][$type . '_layers'][$layerCode][0], 'icon' => "package.png", 'link' => "run.php?type={$type}&level=layer&layer={$layerCode}", 'linkTarget' => 'right'))); foreach ($folders as $folder => $files) { if (count($files)) { $secondNode =& $firstNode->addItem(new HTML_TreeNode(array('text' => $folder, 'icon' => "class_folder.png", 'link' => "run.php?type={$type}&level=folder&layer={$layerCode}&folder={$folder}", 'linkTarget' => 'right'))); } foreach ($files as $index => $file) { $secondNode->addItem(new HTML_TreeNode(array('text' => $file, 'icon' => "Method.png", 'link' => "run.php?type={$type}&level=file&layer={$layerCode}&folder={$folder}&file={$file}", 'linkTarget' => 'right'))); } } } $rootNode->addItem(${$nodeName}); } /** * @TODO Clean up the following code to ensure that adding new * PEAR PHPUnit tests to the test suite is easier! */ // Create the PEAR PHPUnit tests $nodeName = 'PearRootNode'; ${$nodeName} = new HTML_TreeNode(array('text' => 'PEAR PHPUnit Test Suite', 'icon' => "package.png", 'link' => "", 'linkTarget' => "right")); $firstNode =& ${$nodeName}->addItem(new HTML_TreeNode(array('text' => 'PEAR::MDB2', 'icon' => "package.png", 'link' => "run.php?type=phpunit&dir=../lib/pear/MDB2/tests", 'linkTarget' => 'right'))); $firstNode =& ${$nodeName}->addItem(new HTML_TreeNode(array('text' => 'PEAR::MDB2_Schema', 'icon' => "package.png", 'link' => "run.php?type=phpunit&dir=../lib/pear/MDB2_Schema/tests", 'linkTarget' => 'right'))); $rootNode->addItem(${$nodeName}); // Add the root node to the menu, and return the HTML code $menu->addItem($rootNode); $tree = new HTML_TreeMenu_DHTML($menu); $code = file_get_contents(MAX_PATH . '/tests/testClasses/menu.css'); $code .= "\n<script>\n"; $code .= file_get_contents(MAX_PATH . '/tests/testClasses/TreeMenu.js'); $code .= "\n</script>"; $code .= $tree->toHTML(); return $code; }
require_once MAX_PATH . '/tests/xmlreporter.php'; require_once MAX_PATH . '/tests/testClasses/TestFiles.php'; if ($_SERVER['argc'] < 2) { echo "Usage: " . __FILE__ . " php-command [unit|integration]"; exit(1); } $php = $_SERVER['argv'][1]; $testName = isset($_SERVER['argv'][2]) ? $_SERVER['argv'][2] : ""; $aLayer = array('unit', 'integration'); // Take a copy in memory of the conf file $testConfFile = dirname(__FILE__) . '/../var/test.conf.php'; $testConf = file_get_contents($testConfFile); $oReporter = new ReviveXmlReporter(); $oReporter->paintGroupStart("Tests", count($aLayer)); foreach ($aLayer as $layer) { $aTestFiles = TestFiles::getAllTestFiles($layer); $oReporter->paintGroupStart("Layer {$layer}", count($aTestFiles)); foreach ($aTestFiles as $subLayer => $aDirectories) { $oReporter->paintGroupStart("Sublayer {$subLayer}", count($aDirectories)); foreach ($aDirectories as $dirName => $aFiles) { $oReporter->paintGroupStart("Directory {$dirName} ({$testName})", count($aFiles)); foreach ($aFiles as $fileName) { $oReporter->paintCaseStart("File {$fileName} ({$testName})"); // Prepare the name of the test to display when running for ($counter = 0; $counter < count($GLOBALS['_MAX']['TEST']['groups']) - 1; $counter++) { if ($layer == $GLOBALS['_MAX']['TEST']['groups'][$counter]) { $layerDisplayName = $GLOBALS['_MAX']['TEST'][$GLOBALS['_MAX']['TEST']['groups'][$counter] . '_layers'][$subLayer][0]; } } preg_match('/^([^\\.]+)/', $fileName, $aMatches); $testDisplayName = ucfirst(strtolower($layer)) . '.' . $layerDisplayName . '.' . $aMatches[1];
/** * A method to all tests in a layer/folder. * * @param string $layer The layer group to run. * @param string $folder The folder group to run. */ function runFolder($layer, $folder) { $type = $GLOBALS['_MAX']['TEST']['test_type']; // Set up the environment for the test TestRunner::setupEnv($layer); // Find all the tests in the layer/folder, but ensure // that they are NOT obtained recursively! $tests = TestFiles::getTestFiles($type, $layer, MAX_PROJECT_PATH . '/' . $folder, false); // Add the test files to a SimpleTest group $testName = $this->_testName($layer, $folder); $secondaryName = $this->_secondaryTestName($layer); $test = new GroupTest($testName, $secondaryName); foreach ($tests as $folder => $data) { foreach ($data as $index => $file) { $testFile = MAX_PROJECT_PATH . '/' . $folder . '/' . constant($type . '_TEST_STORE') . '/' . $file; $test->addTestFile($testFile); } } $this->runCase($test); // Tear down the environment for the test TestRunner::teardownEnv($layer); }