diff --git a/app/webroot/test.php b/app/webroot/test.php index 3716313c3..ca482b010 100644 --- a/app/webroot/test.php +++ b/app/webroot/test.php @@ -69,7 +69,7 @@ if (isset($corePath[0])) { } else { define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH); } -require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php'; +require_once CAKE_TESTS_LIB . 'test_manager.php'; if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); @@ -81,172 +81,45 @@ if (!isset($_SERVER['SERVER_NAME'])) { if (empty( $_GET['output'])) { $_GET['output'] = 'html'; } - -$dispatch =& new Dispatcher(); -$dispatch->baseUrl(); -define('BASE', $dispatch->webroot); - /** * * Used to determine output to display */ -define('CAKE_TEST_OUTPUT_HTML',1); -define('CAKE_TEST_OUTPUT_TEXT',2); +define('CAKE_TEST_OUTPUT_HTML', 1); +define('CAKE_TEST_OUTPUT_TEXT', 2); if (isset($_GET['output']) && $_GET['output'] == 'html') { define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML); } else { + Debugger::output('txt'); define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT); } if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { CakePHPTestHeader(); - include CAKE . 'tests' . DS . 'lib' . DS . 'simpletest.php'; + include CAKE_TESTS_LIB . 'simpletest.php'; CakePHPTestSuiteFooter(); exit(); } - function &CakeTestsGetReporter() { - static $Reporter = NULL; - if (!$Reporter) { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - require_once LIB_TESTS . 'cake_reporter.php'; - $Reporter = new CakeHtmlReporter(); - break; - default: - $Reporter = new TextReporter(); - break; - } - } - return $Reporter; - } +CakePHPTestHeader(); +CakePHPTestSuiteHeader(); +define('RUN_TEST_LINK', $_SERVER['PHP_SELF']); - function CakePHPTestRunMore() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['group'])) { - if (isset($_GET['app'])) { - $show = '?show=groups&app=true'; - } else { - $show = '?show=groups'; - } - } - if (isset($_GET['case'])) { - if (isset($_GET['app'])) { - $show = '?show=cases&app=true'; - } else { - $show = '?show=cases'; - } - } - echo "
\n"; - break; - } - } - - function CakePHPTestCaseList() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['app'])) { - echo HtmlTestManager::getTestCaseList(APP_TEST_CASES); - } else { - echo HtmlTestManager::getTestCaseList(CORE_TEST_CASES); - } - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - if (isset($_GET['app'])) { - echo TextTestManager::getTestCaseList(APP_TEST_CASES); - } else { - echo TextTestManager::getTestCaseList(CORE_TEST_CASES); - } - break; - } - } - - function CakePHPTestGroupTestList() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['app'])) { - echo HtmlTestManager::getGroupTestList(APP_TEST_GROUPS); - } else { - echo HtmlTestManager::getGroupTestList(CORE_TEST_GROUPS); - } - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - if (isset($_GET['app'])) { - echo TextTestManager::getGroupTestList(APP_TEST_GROUPS); - } else { - echo TextTestManager::getGroupTestList(CORE_TEST_GROUPS); - } - break; - } - } - - function CakePHPTestHeader() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - $baseUrl = BASE; - $characterSet = 'charset=utf-8'; - include CAKE . 'tests' . DS . 'lib' . DS . 'header.php'; - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - header(' content-type: text/plain'); - break; - } - } - - function CakePHPTestSuiteHeader() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - $groups = $_SERVER['PHP_SELF'].'?show=groups'; - $cases = $_SERVER['PHP_SELF'].'?show=cases'; - include CAKE . 'tests' . DS . 'lib' . DS . 'content.php'; - break; - } - } - - function CakePHPTestSuiteFooter() { - switch ( CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - $baseUrl = BASE; - include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php'; - break; - } - } - - CakePHPTestHeader(); - CakePHPTestSuiteHeader(); - define('RUN_TEST_LINK', $_SERVER['PHP_SELF']); - - if (isset($_GET['group'])) { - if ('all' == $_GET['group']) { - TestManager::runAllTests(CakeTestsGetReporter()); - } else { - if (isset($_GET['app'])) { - TestManager::runGroupTest(ucfirst($_GET['group']), APP_TEST_GROUPS, CakeTestsGetReporter()); - } else { - TestManager::runGroupTest(ucfirst($_GET['group']), CORE_TEST_GROUPS, CakeTestsGetReporter()); - } - } - CakePHPTestRunMore(); - CakePHPTestSuiteFooter(); - exit(); - } - - if (isset($_GET['case'])) { - TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); - CakePHPTestRunMore(); - CakePHPTestSuiteFooter(); - exit(); - } - - if (isset($_GET['show']) && $_GET['show'] == 'cases') { - CakePHPTestCaseList(); +if (isset($_GET['group'])) { + if ('all' == $_GET['group']) { + TestManager::runAllTests(CakeTestsGetReporter()); } else { - CakePHPTestGroupTestList(); + TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter()); } - CakePHPTestSuiteFooter(); + CakePHPTestRunMore(); +} elseif (isset($_GET['case'])) { + TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); + CakePHPTestRunMore(); +}elseif (isset($_GET['show']) && $_GET['show'] == 'cases') { + CakePHPTestCaseList(); +} else { + CakePHPTestGroupTestList(); +} +CakePHPTestSuiteFooter(); ?> \ No newline at end of file diff --git a/cake/config/paths.php b/cake/config/paths.php index 16163193b..f98521fa6 100644 --- a/cake/config/paths.php +++ b/cake/config/paths.php @@ -114,6 +114,17 @@ if (!defined('TESTS')) { define ('TESTS', APP.'tests'.DS); } +/** + * Path to the core tests directory. + */ +if (!defined('CAKE_TESTS')) { + define ('CAKE_TESTS', CAKE.'tests'.DS); +} +/** + * Path to the test suite. + */ + define ('CAKE_TESTS_LIB', CAKE_TESTS.'lib'.DS); + /** * Path to the controller test directory. */ @@ -133,7 +144,7 @@ if (!defined('TESTS')) { /** * Path to the lib test directory. */ - define ('LIB_TESTS', CAKE.'tests'.DS.'lib'.DS); + define ('LIB_TESTS', CAKE_TESTS.'cases'.DS.'lib'.DS); /** * Path to the temporary files directory. */ diff --git a/cake/console/libs/templates/skel/webroot/test.php b/cake/console/libs/templates/skel/webroot/test.php index 514ec070a..ca482b010 100644 --- a/cake/console/libs/templates/skel/webroot/test.php +++ b/cake/console/libs/templates/skel/webroot/test.php @@ -69,7 +69,7 @@ if (isset($corePath[0])) { } else { define('TEST_CAKE_CORE_INCLUDE_PATH', CAKE_CORE_INCLUDE_PATH); } -require_once CAKE . 'tests' . DS . 'lib' . DS . 'test_manager.php'; +require_once CAKE_TESTS_LIB . 'test_manager.php'; if (Configure::read('debug') < 1) { die(__('Debug setting does not allow access to this url.', true)); @@ -81,172 +81,45 @@ if (!isset($_SERVER['SERVER_NAME'])) { if (empty( $_GET['output'])) { $_GET['output'] = 'html'; } - -$dispatch =& new Dispatcher(); -$dispatch->baseUrl(); -define('BASE', $dispatch->webroot); - /** * * Used to determine output to display */ -define('CAKE_TEST_OUTPUT_HTML',1); -define('CAKE_TEST_OUTPUT_TEXT',2); +define('CAKE_TEST_OUTPUT_HTML', 1); +define('CAKE_TEST_OUTPUT_TEXT', 2); if (isset($_GET['output']) && $_GET['output'] == 'html') { define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_HTML); } else { + Debugger::output('txt'); define('CAKE_TEST_OUTPUT', CAKE_TEST_OUTPUT_TEXT); } if (!App::import('Vendor', 'simpletest' . DS . 'reporter')) { CakePHPTestHeader(); - include CAKE . 'tests' . DS . 'lib' . DS . 'simpletest.php'; + include CAKE_TESTS_LIB . 'simpletest.php'; CakePHPTestSuiteFooter(); exit(); } - function &CakeTestsGetReporter() { - static $Reporter = NULL; - if (!$Reporter) { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - require_once LIB_TESTS . 'cake_reporter.php'; - $Reporter = new CakeHtmlReporter(); - break; - default: - $Reporter = new TextReporter(); - break; - } - } - return $Reporter; - } +CakePHPTestHeader(); +CakePHPTestSuiteHeader(); +define('RUN_TEST_LINK', $_SERVER['PHP_SELF']); - function CakePHPTestRunMore() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['group'])) { - if (isset($_GET['app'])) { - $show = '?show=groups&app=true'; - } else { - $show = '?show=groups'; - } - } - if (isset($_GET['case'])) { - if (isset($_GET['app'])) { - $show = '??show=cases&app=truee'; - } else { - $show = '?show=cases'; - } - } - echo "\n"; - break; - } - } - - function CakePHPTestCaseList() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['app'])) { - echo HtmlTestManager::getTestCaseList(APP_TEST_CASES); - } else { - echo HtmlTestManager::getTestCaseList(CORE_TEST_CASES); - } - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - if (isset($_GET['app'])) { - echo TextTestManager::getTestCaseList(APP_TEST_CASES); - } else { - echo TextTestManager::getTestCaseList(CORE_TEST_CASES); - } - break; - } - } - - function CakePHPTestGroupTestList() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - if (isset($_GET['app'])) { - echo HtmlTestManager::getGroupTestList(APP_TEST_GROUPS); - } else { - echo HtmlTestManager::getGroupTestList(CORE_TEST_GROUPS); - } - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - if (isset($_GET['app'])) { - echo TextTestManager::getGroupTestList(APP_TEST_GROUPS); - } else { - echo TextTestManager::getGroupTestList(CORE_TEST_GROUPS); - } - break; - } - } - - function CakePHPTestHeader() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - $baseUrl = BASE; - $characterSet = 'charset=utf-8'; - include CAKE . 'tests' . DS . 'lib' . DS . 'header.php'; - break; - case CAKE_TEST_OUTPUT_TEXT: - default: - header(' content-type: text/plain'); - break; - } - } - - function CakePHPTestSuiteHeader() { - switch (CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - $groups = $_SERVER['PHP_SELF'].'?show=groups'; - $cases = $_SERVER['PHP_SELF'].'?show=cases'; - include CAKE . 'tests' . DS . 'lib' . DS . 'content.php'; - break; - } - } - - function CakePHPTestSuiteFooter() { - switch ( CAKE_TEST_OUTPUT) { - case CAKE_TEST_OUTPUT_HTML: - $baseUrl = BASE; - include CAKE . 'tests' . DS . 'lib' . DS . 'footer.php'; - break; - } - } - - CakePHPTestHeader(); - CakePHPTestSuiteHeader(); - define('RUN_TEST_LINK', $_SERVER['PHP_SELF']); - - if (isset($_GET['group'])) { - if ('all' == $_GET['group']) { - TestManager::runAllTests(CakeTestsGetReporter()); - } else { - if (isset($_GET['app'])) { - TestManager::runGroupTest(ucfirst($_GET['group']), APP_TEST_GROUPS, CakeTestsGetReporter()); - } else { - TestManager::runGroupTest(ucfirst($_GET['group']), CORE_TEST_GROUPS, CakeTestsGetReporter()); - } - } - CakePHPTestRunMore(); - CakePHPTestSuiteFooter(); - exit(); - } - - if (isset($_GET['case'])) { - TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); - CakePHPTestRunMore(); - CakePHPTestSuiteFooter(); - exit(); - } - - if (isset($_GET['show']) && $_GET['show'] == 'cases') { - CakePHPTestCaseList(); +if (isset($_GET['group'])) { + if ('all' == $_GET['group']) { + TestManager::runAllTests(CakeTestsGetReporter()); } else { - CakePHPTestGroupTestList(); + TestManager::runGroupTest(ucfirst($_GET['group']), CakeTestsGetReporter()); } - CakePHPTestSuiteFooter(); + CakePHPTestRunMore(); +} elseif (isset($_GET['case'])) { + TestManager::runTestCase($_GET['case'], CakeTestsGetReporter()); + CakePHPTestRunMore(); +}elseif (isset($_GET['show']) && $_GET['show'] == 'cases') { + CakePHPTestCaseList(); +} else { + CakePHPTestGroupTestList(); +} +CakePHPTestSuiteFooter(); ?> \ No newline at end of file diff --git a/cake/tests/lib/cake_test_case.php b/cake/tests/lib/cake_test_case.php index b86f76185..f290cde59 100644 --- a/cake/tests/lib/cake_test_case.php +++ b/cake/tests/lib/cake_test_case.php @@ -26,8 +26,8 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ -require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_model.php'; -require_once CAKE . 'tests' . DS . 'lib' . DS . 'cake_test_fixture.php'; +require_once CAKE_TESTS_LIB . 'cake_test_model.php'; +require_once CAKE_TESTS_LIB . 'cake_test_fixture.php'; !App::import('Vendor', 'simpletest' . DS . 'unit_tester'); /** * Short description for class. @@ -473,7 +473,16 @@ class CakeTestCase extends UnitTestCase { } elseif (strpos($fixture, 'app.') === 0) { $fixture = substr($fixture, strlen('app.')); $fixturePaths = array( - TESTS . DS . 'fixtures', + TESTS . 'fixtures', + VENDORS . 'tests' . DS . 'fixtures' + ); + } elseif (strpos($fixture, 'plugin.') === 0) { + $parts = explode('.', $fixture, 3); + $pluginName = $parts[1]; + $fixture = $parts[2]; + $fixturePaths = array( + APP . 'plugins' . DS . $pluginName . DS . 'tests' . DS . 'fixtures', + TESTS . 'fixtures', VENDORS . 'tests' . DS . 'fixtures' ); } else { diff --git a/cake/tests/lib/content.php b/cake/tests/lib/content.php index bde790b12..fe53719d0 100644 --- a/cake/tests/lib/content.php +++ b/cake/tests/lib/content.php @@ -27,12 +27,39 @@ * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License */ ?> +