adding test manager test case, some whitespace changes throughout the testsuite and the schema model

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7839 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
DarkAngelBGE 2008-11-07 11:33:13 +00:00
parent df4a8bcd32
commit e882d990d7
4 changed files with 154 additions and 31 deletions

View file

@ -240,6 +240,7 @@ class CakeSchema extends Object {
}
}
}
if (!empty($currentTables)) {
foreach ($currentTables as $table) {
if ($prefix) {
@ -400,7 +401,7 @@ class CakeSchema extends Object {
}
$diff = array_diff_assoc($old[$table], $fields);
if (!empty($diff)) {
$tables[$table]['drop'] = $diff;
$tables[$table]['drop'] = $diff;
}
}
foreach ($fields as $field => $value) {
@ -456,7 +457,6 @@ class CakeSchema extends Object {
$fields = $Obj->schema(true);
$columns = $props = array();
foreach ($fields as $name => $value) {
if ($Obj->primaryKey == $name) {
$value['key'] = 'primary';
}

View file

@ -0,0 +1,97 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
* Copyright 2005-2008, Cake Software Foundation, Inc.
* 1785 E. Sahara Avenue, Suite 490-204
* Las Vegas, Nevada 89104
*
* 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.
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
* @package cake.tests
* @subpackage cake.tests.cases.libs
* @since CakePHP(tm) v 1.2.0.4206
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
App::import('Core', 'TestManager');
class TestManagerTest extends CakeTestCase {
function testRunAllTests() {
$manager = new TestManager();
$folder = new Folder($manager->_getTestsPath());
$extension = str_replace('.', '\.', Testmanager::getExtension('test'));
$out = $folder->findRecursive('.*' . $extension);
$reporter = new CakeHtmlReporter();
$list = TestManager::runAllTests($reporter, true);
$this->assertEqual(count($out), count($list->_test_cases));
}
/**
* undocumented function
*
* @return void
* @access public
*/
function testRunTestCase() {
}
/**
* undocumented function
*
* @return void
* @access public
*/
function testRunGroupTest() {
}
/**
* undocumented function
*
* @return void
* @access public
*/
function testAddTestCasesFromDirectory() {
}
/**
* undocumented function
*
* @return void
* @access public
*/
function testAddTestFile() {
}
/**
* undocumented function
*
* @return void
* @access public
*/
function testGetTestCaseList() {
}
/**
* undocumented function
*
* @return void
* @access public
*/
function testGetGroupTestList() {
}
}
?>

View file

@ -25,12 +25,13 @@
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
*/
?>
<div id="content">
<h2>SimpleTest is not installed</h2>
<p>You must install SimpleTest to use the CakePHP(tm) Test Suite.</p>
<p>SimpleTest can be placed in one of the following directories.</p>
<ul>
<li><?php echo CAKE; ?>vendors </li>
<li><?php echo APP_DIR . DS; ?>vendors</li>
</ul>
<p><a href="http://simpletest.org/en/download.html" target="_blank">Download SimpleTest</a></p>
<div id="content">
<h2>SimpleTest is not installed</h2>
<p>You must install SimpleTest to use the CakePHP(tm) Test Suite.</p>
<p>SimpleTest can be placed in one of the following directories.</p>
<ul>
<li><?php echo CAKE; ?>vendors </li>
<li><?php echo APP_DIR . DS; ?>vendors</li>
</ul>
<p><a href="http://simpletest.org/en/download.html" target="_blank">Download SimpleTest</a></p>
</div>

View file

@ -61,7 +61,11 @@ class TestManager {
* @access public
*/
function _installSimpleTest() {
App::import('Vendor', array('simpletest'.DS.'unit_tester', 'simpletest'.DS.'mock_objects', 'simpletest'.DS.'web_tester'));
App::import('Vendor', array(
'simpletest' . DS . 'unit_tester',
'simpletest' . DS . 'mock_objects',
'simpletest' . DS . 'web_tester'
));
require_once(CAKE_TESTS_LIB . 'cake_web_test_case.php');
require_once(CAKE_TESTS_LIB . 'cake_test_case.php');
}
@ -72,7 +76,7 @@ class TestManager {
* @return void
* @access public
*/
function runAllTests(&$reporter) {
function runAllTests(&$reporter, $testing = false) {
$manager =& new TestManager();
$testCases =& $manager->_getTestFileList($manager->_getTestsPath());
@ -87,6 +91,11 @@ class TestManager {
foreach ($testCases as $testCase) {
$test->addTestFile($testCase);
}
if ($testing) {
return $test;
}
return $test->run($reporter);
}
/**
@ -101,7 +110,7 @@ class TestManager {
$manager =& new TestManager();
$testCaseFileWithPath = $manager->_getTestsPath() . DS . $testCaseFile;
if (! file_exists($testCaseFileWithPath)) {
if (!file_exists($testCaseFileWithPath)) {
trigger_error("Test case {$testCaseFile} cannot be found", E_USER_ERROR);
}
$test =& new GroupTest("Individual test case: " . $testCaseFile);
@ -242,12 +251,11 @@ class TestManager {
function &_getGroupTestClassNames($groupTestFile) {
$file = implode("\n", file($groupTestFile));
preg_match("~lass\s+?(.*)\s+?extends GroupTest~", $file, $matches);
if (! empty($matches)) {
if (!empty($matches)) {
unset($matches[0]);
return $matches;
} else {
return array();
}
return array();
}
/**
* Gets a recursive list of files from a given directory and matches then against
@ -335,6 +343,20 @@ class TestManager {
}
return $result;
}
/**
* undocumented function
*
* @param string $type
* @return void
* @access public
*/
function getExtension($type = 'test') {
$manager =& new TestManager();
if ($type == 'test') {
return $manager->_testExtension;
}
return $manager->_groupExtension;
}
}
/**
* The CliTestManager ensures that the list of available files are printed in the correct cli format
@ -411,7 +433,7 @@ class TextTestManager extends TestManager {
$groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups'));
$buffer = "Core Test Groups:\n";
$urlExtra = null;
$urlExtra = '';
if ($manager->appTest) {
$buffer = "App Test Groups:\n";
$urlExtra = '&app=true';
@ -438,7 +460,7 @@ class TextTestManager extends TestManager {
$testCases =& $manager->_getTestCaseList($manager->_getTestsPath());
$buffer = "Core Test Cases:\n";
$urlExtra = null;
$urlExtra = '';
if ($manager->appTest) {
$buffer = "App Test Cases:\n";
$urlExtra = '&app=true';
@ -510,7 +532,7 @@ class HtmlTestManager extends TestManager {
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group=all$urlExtra'>All tests</a></li>\n";
foreach ((array)$groupTests as $groupTest) {
foreach ($groupTests as $groupTest) {
$buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}" . "{$urlExtra}'>" . $groupTest . "</a></li>\n";
}
$buffer .= "</ul>\n";
@ -569,10 +591,10 @@ if (function_exists('caketestsgetreporter')) {
case CAKE_TEST_OUTPUT_HTML:
require_once CAKE_TESTS_LIB . 'cake_reporter.php';
$Reporter =& new CakeHtmlReporter();
break;
break;
default:
$Reporter =& new TextReporter();
break;
break;
}
}
return $Reporter;
@ -618,7 +640,8 @@ if (function_exists('caketestsgetreporter')) {
}
ob_start();
echo "<p><a href='" . RUN_TEST_LINK . $show . "'>Run more tests</a> | <a href='" . RUN_TEST_LINK . $query . "&show_passes=1'>Show Passes</a> | \n";
break;
break;
}
}
/**
@ -648,7 +671,8 @@ if (function_exists('caketestsgetreporter')) {
$query .= '&amp;code_coverage=true';
ob_start();
echo " <a href='" . RUN_TEST_LINK . $query . "'>Analyze Code Coverage</a></p>\n";
break;
break;
}
}
/**
@ -662,11 +686,11 @@ if (function_exists('caketestsgetreporter')) {
case CAKE_TEST_OUTPUT_HTML:
ob_start();
echo HtmlTestManager::getTestCaseList();
break;
break;
case CAKE_TEST_OUTPUT_TEXT:
default:
echo TextTestManager::getTestCaseList();
break;
break;
}
}
/**
@ -679,7 +703,7 @@ if (function_exists('caketestsgetreporter')) {
switch (CAKE_TEST_OUTPUT) {
case CAKE_TEST_OUTPUT_HTML:
echo HtmlTestManager::getGroupTestList();
break;
break;
case CAKE_TEST_OUTPUT_TEXT:
default:
echo TextTestManager::getGroupTestList();
@ -705,11 +729,12 @@ if (function_exists('caketestsgetreporter')) {
$baseUrl = BASE;
$characterSet = 'charset=utf-8';
include CAKE_TESTS_LIB . 'header.php';
break;
break;
case CAKE_TEST_OUTPUT_TEXT:
default:
header('content-type: text/plain');
break;
break;
}
}
/**
@ -726,7 +751,7 @@ if (function_exists('caketestsgetreporter')) {
$cases = $_SERVER['PHP_SELF'].'?show=cases';
$plugins = Configure::listObjects('plugin');
include CAKE_TESTS_LIB . 'content.php';
break;
break;
}
}
/**
@ -741,7 +766,7 @@ if (function_exists('caketestsgetreporter')) {
ob_start();
$baseUrl = BASE;
include CAKE_TESTS_LIB . 'footer.php';
break;
break;
}
}
}