mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
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:
parent
df4a8bcd32
commit
e882d990d7
4 changed files with 154 additions and 31 deletions
|
@ -240,6 +240,7 @@ class CakeSchema extends Object {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($currentTables)) {
|
||||
foreach ($currentTables as $table) {
|
||||
if ($prefix) {
|
||||
|
@ -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';
|
||||
}
|
||||
|
|
97
cake/tests/cases/libs/test_manager.test.php
Normal file
97
cake/tests/cases/libs/test_manager.test.php
Normal 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() {
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -25,7 +25,7 @@
|
|||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||
*/
|
||||
?>
|
||||
<div id="content">
|
||||
<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>
|
||||
|
@ -34,3 +34,4 @@
|
|||
<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>
|
|
@ -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";
|
||||
|
@ -618,6 +640,7 @@ 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;
|
||||
}
|
||||
}
|
||||
|
@ -648,6 +671,7 @@ if (function_exists('caketestsgetreporter')) {
|
|||
$query .= '&code_coverage=true';
|
||||
ob_start();
|
||||
echo " <a href='" . RUN_TEST_LINK . $query . "'>Analyze Code Coverage</a></p>\n";
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -705,6 +729,7 @@ if (function_exists('caketestsgetreporter')) {
|
|||
$baseUrl = BASE;
|
||||
$characterSet = 'charset=utf-8';
|
||||
include CAKE_TESTS_LIB . 'header.php';
|
||||
|
||||
break;
|
||||
case CAKE_TEST_OUTPUT_TEXT:
|
||||
default:
|
||||
|
|
Loading…
Add table
Reference in a new issue