PageRenderTime 53ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/cakeusermanagement/cake/tests/lib/test_manager.php

https://github.com/miamiruby/cakestuff
PHP | 760 lines | 628 code | 7 blank | 125 comment | 14 complexity | 170103c016aa48e2a3be6eaf71648038 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause, LGPL-2.0, MIT
  1. <?php
  2. /* SVN FILE: $Id: test_manager.php 7690 2008-10-02 04:56:53Z nate $ */
  3. /**
  4. * Short description for file.
  5. *
  6. * Long description for file
  7. *
  8. * PHP versions 4 and 5
  9. *
  10. * CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
  11. * Copyright 2005-2008, Cake Software Foundation, Inc.
  12. * 1785 E. Sahara Avenue, Suite 490-204
  13. * Las Vegas, Nevada 89104
  14. *
  15. * Licensed under The Open Group Test Suite License
  16. * Redistributions of files must retain the above copyright notice.
  17. *
  18. * @filesource
  19. * @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
  20. * @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
  21. * @package cake
  22. * @subpackage cake.cake.tests.lib
  23. * @since CakePHP(tm) v 1.2.0.4433
  24. * @version $Revision: 7690 $
  25. * @modifiedby $LastChangedBy: nate $
  26. * @lastmodified $Date: 2008-10-02 00:56:53 -0400 (Thu, 02 Oct 2008) $
  27. * @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
  28. */
  29. define ('CORE_TEST_CASES', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'cases');
  30. define ('CORE_TEST_GROUPS', TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'groups');
  31. define ('APP_TEST_CASES', TESTS . 'cases');
  32. define ('APP_TEST_GROUPS', TESTS . 'groups');
  33. /**
  34. * Short description for class.
  35. *
  36. * @package cake
  37. * @subpackage cake.cake.tests.lib
  38. */
  39. class TestManager {
  40. var $_testExtension = '.test.php';
  41. var $_groupExtension = '.group.php';
  42. var $appTest = false;
  43. var $pluginTest = false;
  44. /**
  45. * Constructor for the TestManager class
  46. *
  47. * @return void
  48. * @access public
  49. */
  50. function TestManager() {
  51. $this->_installSimpleTest();
  52. if (isset($_GET['app'])) {
  53. $this->appTest = true;
  54. }
  55. if (isset($_GET['plugin'])) {
  56. $this->pluginTest = $_GET['plugin'];
  57. }
  58. }
  59. /**
  60. * Includes the required simpletest files in order for the testsuite to run
  61. *
  62. * @return void
  63. * @access public
  64. */
  65. function _installSimpleTest() {
  66. App::import('Vendor', array('simpletest'.DS.'unit_tester', 'simpletest'.DS.'mock_objects', 'simpletest'.DS.'web_tester'));
  67. require_once(CAKE_TESTS_LIB . 'cake_web_test_case.php');
  68. require_once(CAKE_TESTS_LIB . 'cake_test_case.php');
  69. }
  70. /**
  71. * Runs all tests in the Application depending on the current appTest setting
  72. *
  73. * @param string $reporter
  74. * @return void
  75. * @access public
  76. */
  77. function runAllTests(&$reporter) {
  78. $manager =& new TestManager();
  79. $testCases =& $manager->_getTestFileList($manager->_getTestsPath());
  80. if ($manager->appTest) {
  81. $test =& new GroupTest('All App Tests');
  82. } else if ($manager->pluginTest) {
  83. $test =& new GroupTest('All ' . Inflector::humanize($manager->pluginTest) . ' Plugin Tests');
  84. } else {
  85. $test =& new GroupTest('All Core Tests');
  86. }
  87. foreach ($testCases as $testCase) {
  88. $test->addTestFile($testCase);
  89. }
  90. return $test->run($reporter);
  91. }
  92. /**
  93. * Runs a specific test case file
  94. *
  95. * @param string $testCaseFile
  96. * @param string $reporter
  97. * @return void
  98. * @access public
  99. */
  100. function runTestCase($testCaseFile, &$reporter) {
  101. $manager =& new TestManager();
  102. $testCaseFileWithPath = $manager->_getTestsPath() . DS . $testCaseFile;
  103. if (! file_exists($testCaseFileWithPath)) {
  104. trigger_error("Test case {$testCaseFile} cannot be found", E_USER_ERROR);
  105. }
  106. $test =& new GroupTest("Individual test case: " . $testCaseFile);
  107. $test->addTestFile($testCaseFileWithPath);
  108. return $test->run($reporter);
  109. }
  110. /**
  111. * Runs a specific group test file
  112. *
  113. * @param string $groupTestName
  114. * @param string $reporter
  115. * @return void
  116. * @access public
  117. */
  118. function runGroupTest($groupTestName, &$reporter) {
  119. $manager =& new TestManager();
  120. $filePath = $manager->_getTestsPath('groups') . DS . strtolower($groupTestName) . $manager->_groupExtension;
  121. if (!file_exists($filePath)) {
  122. trigger_error("Group test {$groupTestName} cannot be found at {$filePath}", E_USER_ERROR);
  123. }
  124. require_once $filePath;
  125. $test =& new GroupTest($groupTestName . ' group test');
  126. foreach ($manager->_getGroupTestClassNames($filePath) as $groupTest) {
  127. $testCase = new $groupTest();
  128. $test->addTestCase($testCase);
  129. if (isset($testCase->label)) {
  130. $test->_label = $testCase->label;
  131. }
  132. }
  133. return $test->run($reporter);
  134. }
  135. /**
  136. * Adds all testcases in a given directory to a given GroupTest object
  137. *
  138. * @param string $groupTest
  139. * @param string $directory
  140. * @return void
  141. * @access public
  142. */
  143. function addTestCasesFromDirectory(&$groupTest, $directory = '.') {
  144. $manager =& new TestManager();
  145. $testCases =& $manager->_getTestFileList($directory);
  146. foreach ($testCases as $testCase) {
  147. $groupTest->addTestFile($testCase);
  148. }
  149. }
  150. /**
  151. * Adds a specific test file and thereby all of its test cases and group tests to a given group test file
  152. *
  153. * @param string $groupTest
  154. * @param string $file
  155. * @return void
  156. * @access public
  157. */
  158. function addTestFile(&$groupTest, $file) {
  159. $manager =& new TestManager();
  160. if (file_exists($file.'.test.php')) {
  161. $file .= '.test.php';
  162. } elseif (file_exists($file.'.group.php')) {
  163. $file .= '.group.php';
  164. }
  165. $groupTest->addTestFile($file);
  166. }
  167. /**
  168. * Returns a list of test cases found in the current valid test case path
  169. *
  170. * @access public
  171. */
  172. function &getTestCaseList() {
  173. $manager =& new TestManager();
  174. $return = $manager->_getTestCaseList($manager->_getTestsPath());
  175. return $return;
  176. }
  177. /**
  178. * Builds the list of test cases from a given directory
  179. *
  180. * @access public
  181. */
  182. function &_getTestCaseList($directory = '.') {
  183. $fileList =& $this->_getTestFileList($directory);
  184. $testCases = array();
  185. foreach ($fileList as $testCaseFile) {
  186. $testCases[$testCaseFile] = str_replace($directory . DS, '', $testCaseFile);
  187. }
  188. return $testCases;
  189. }
  190. /**
  191. * Returns a list of test files from a given directory
  192. *
  193. * @access public
  194. */
  195. function &_getTestFileList($directory = '.') {
  196. $return = $this->_getRecursiveFileList($directory, array(&$this, '_isTestCaseFile'));
  197. return $return;
  198. }
  199. /**
  200. * Returns a list of group tests found in the current valid test case path
  201. *
  202. * @access public
  203. */
  204. function &getGroupTestList() {
  205. $manager =& new TestManager();
  206. $return = $manager->_getTestGroupList($manager->_getTestsPath('groups'));
  207. return $return;
  208. }
  209. /**
  210. * Returns a list of group test files from a given directory
  211. *
  212. * @access public
  213. */
  214. function &_getTestGroupFileList($directory = '.') {
  215. $return = $this->_getRecursiveFileList($directory, array(&$this, '_isTestGroupFile'));
  216. return $return;
  217. }
  218. /**
  219. * Returns a list of group test files from a given directory
  220. *
  221. * @access public
  222. */
  223. function &_getTestGroupList($directory = '.') {
  224. $fileList =& $this->_getTestGroupFileList($directory);
  225. $groupTests = array();
  226. foreach ($fileList as $groupTestFile) {
  227. $groupTests[$groupTestFile] = str_replace($this->_groupExtension, '', basename($groupTestFile));
  228. }
  229. sort($groupTests);
  230. return $groupTests;
  231. }
  232. /**
  233. * Returns a list of class names from a group test file
  234. *
  235. * @access public
  236. */
  237. function &_getGroupTestClassNames($groupTestFile) {
  238. $file = implode("\n", file($groupTestFile));
  239. preg_match("~lass\s+?(.*)\s+?extends GroupTest~", $file, $matches);
  240. if (! empty($matches)) {
  241. unset($matches[0]);
  242. return $matches;
  243. } else {
  244. return array();
  245. }
  246. }
  247. /**
  248. * Gets a recursive list of files from a given directory and matches then against
  249. * a given fileTestFunction, like isTestCaseFile()
  250. *
  251. * @access public
  252. */
  253. function &_getRecursiveFileList($directory = '.', $fileTestFunction) {
  254. $fileList = array();
  255. if (!is_dir($directory)) {
  256. return $fileList;
  257. }
  258. $dh = opendir($directory);
  259. if (! is_resource($dh)) {
  260. trigger_error("Couldn't open {$directory}", E_USER_ERROR);
  261. }
  262. while ($file = readdir($dh)) {
  263. $filePath = $directory . DIRECTORY_SEPARATOR . $file;
  264. if (0 === strpos($file, '.')) {
  265. continue;
  266. }
  267. if (is_dir($filePath)) {
  268. $fileList = array_merge($fileList, $this->_getRecursiveFileList($filePath, $fileTestFunction));
  269. }
  270. if ($fileTestFunction[0]->$fileTestFunction[1]($file)) {
  271. $fileList[] = $filePath;
  272. }
  273. }
  274. closedir($dh);
  275. return $fileList;
  276. }
  277. /**
  278. * Tests if a file has the correct test case extension
  279. *
  280. * @param string $file
  281. * @return void
  282. * @access public
  283. */
  284. function _isTestCaseFile($file) {
  285. return $this->_hasExpectedExtension($file, $this->_testExtension);
  286. }
  287. /**
  288. * Tests if a file has the correct group test extension
  289. *
  290. * @param string $file
  291. * @return void
  292. * @access public
  293. */
  294. function _isTestGroupFile($file) {
  295. return $this->_hasExpectedExtension($file, $this->_groupExtension);
  296. }
  297. /**
  298. * Check if a file has a specific extension
  299. *
  300. * @param string $file
  301. * @param string $extension
  302. * @return void
  303. * @access public
  304. */
  305. function _hasExpectedExtension($file, $extension) {
  306. return $extension == strtolower(substr($file, (0 - strlen($extension))));
  307. }
  308. /**
  309. * Returns the given path to the test files depending on a given type of tests (cases, group, ..)
  310. *
  311. * @param string $type
  312. * @return void
  313. * @access public
  314. */
  315. function _getTestsPath($type = 'cases') {
  316. if (!empty($this->appTest)) {
  317. if ($type == 'cases') {
  318. $result = APP_TEST_CASES;
  319. } else if ($type == 'groups') {
  320. $result = APP_TEST_GROUPS;
  321. }
  322. } else if (!empty($this->pluginTest)) {
  323. $_pluginBasePath = APP . 'plugins' . DS . $this->pluginTest . DS . 'tests';
  324. $pluginPaths = Configure::read('pluginPaths');
  325. foreach ($pluginPaths as $path) {
  326. if (file_exists($path . $this->pluginTest . DS . 'tests')) {
  327. $_pluginBasePath = $path . $this->pluginTest . DS . 'tests';
  328. break;
  329. }
  330. }
  331. $result = $_pluginBasePath . DS . $type;
  332. } else {
  333. if ($type == 'cases') {
  334. $result = CORE_TEST_CASES;
  335. } else if ($type == 'groups') {
  336. $result = CORE_TEST_GROUPS;
  337. }
  338. }
  339. return $result;
  340. }
  341. }
  342. /**
  343. * The CliTestManager ensures that the list of available files are printed in the correct cli format
  344. *
  345. * @package cake
  346. * @subpackage cake.cake.tests.lib
  347. */
  348. class CliTestManager extends TestManager {
  349. /**
  350. * Prints the list of group tests in a cli friendly format
  351. *
  352. * @access public
  353. */
  354. function &getGroupTestList() {
  355. $manager =& new CliTestManager();
  356. $groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups'));
  357. $buffer = "Available Group Test:\n";
  358. foreach ($groupTests as $groupTest) {
  359. $buffer .= " " . $groupTest . "\n";
  360. }
  361. return $buffer . "\n";
  362. }
  363. /**
  364. * Prints the list of test cases in a cli friendly format
  365. *
  366. * @access public
  367. */
  368. function &getTestCaseList() {
  369. $manager =& new CliTestManager();
  370. $testCases =& $manager->_getTestCaseList($manager->_getTestsPath());
  371. $buffer = "Available Test Cases:\n";
  372. foreach ($testCases as $testCaseFile => $testCase) {
  373. $buffer .= " " . $testCaseFile . "\n";
  374. }
  375. return $buffer . "\n";
  376. }
  377. }
  378. /**
  379. * The TextTestManager ensures that the list of available tests is printed as a list of urls in a text-friendly format
  380. *
  381. * @package cake
  382. * @subpackage cake.cake.tests.lib
  383. */
  384. class TextTestManager extends TestManager {
  385. var $_url;
  386. /**
  387. * Constructor
  388. *
  389. * @return void
  390. * @access public
  391. */
  392. function TextTestManager() {
  393. parent::TestManager();
  394. $this->_url = $_SERVER['PHP_SELF'];
  395. }
  396. /**
  397. * Returns the base url
  398. *
  399. * @return void
  400. * @access public
  401. */
  402. function getBaseURL() {
  403. return $this->_url;
  404. }
  405. /**
  406. * Returns a list of available group tests in a text-friendly format
  407. *
  408. * @access public
  409. */
  410. function &getGroupTestList() {
  411. $manager =& new TextTestManager();
  412. $groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups'));
  413. $buffer = "Core Test Groups:\n";
  414. $urlExtra = null;
  415. if ($manager->appTest) {
  416. $buffer = "App Test Groups:\n";
  417. $urlExtra = '&app=true';
  418. } else if ($manager->pluginTest) {
  419. $buffer = Inflector::humanize($manager->pluginTest) . " Test Groups:\n";
  420. $urlExtra = '&plugin=' . $manager->pluginTest;
  421. }
  422. $buffer .= "All tests\n" . $_SERVER['SERVER_NAME'] . $manager->getBaseURL() . "?group=all&output=txt{$urlExtra}\n";
  423. foreach ((array)$groupTests as $groupTest) {
  424. $buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?group=" . $groupTest . "&output=txt{$urlExtra}"."\n";
  425. }
  426. return $buffer;
  427. }
  428. /**
  429. * Returns a list of available test cases in a text-friendly format
  430. *
  431. * @access public
  432. */
  433. function &getTestCaseList() {
  434. $manager =& new TextTestManager();
  435. $testCases =& $manager->_getTestCaseList($manager->_getTestsPath());
  436. $buffer = "Core Test Cases:\n";
  437. $urlExtra = null;
  438. if ($manager->appTest) {
  439. $buffer = "App Test Cases:\n";
  440. $urlExtra = '&app=true';
  441. } else if ($manager->pluginTest) {
  442. $buffer = Inflector::humanize($manager->pluginTest) . " Test Cases:\n";
  443. $urlExtra = '&plugin=' . $manager->pluginTest;
  444. }
  445. if (1 > count($testCases)) {
  446. $buffer .= "EMPTY";
  447. return $buffer;
  448. }
  449. foreach ($testCases as $testCaseFile => $testCase) {
  450. $buffer .= $_SERVER['SERVER_NAME']. $manager->getBaseURL()."?case=" . $testCase . "&output=txt"."\n";
  451. }
  452. $buffer .= "\n";
  453. return $buffer;
  454. }
  455. }
  456. /**
  457. * The HtmlTestManager provides the foundation for the web-based CakePHP testsuite.
  458. * It prints the different lists of tests and provides the interface for CodeCoverage, etc.
  459. *
  460. * @package cake
  461. * @subpackage cake.cake.tests.lib
  462. */
  463. class HtmlTestManager extends TestManager {
  464. var $_url;
  465. /**
  466. * Constructor
  467. *
  468. * @return void
  469. * @access public
  470. */
  471. function HtmlTestManager() {
  472. parent::TestManager();
  473. $this->_url = $_SERVER['PHP_SELF'];
  474. }
  475. /**
  476. * Returns the current base url
  477. *
  478. * @return void
  479. * @access public
  480. */
  481. function getBaseURL() {
  482. return $this->_url;
  483. }
  484. /**
  485. * Prints the links to the available group tests
  486. *
  487. * @access public
  488. */
  489. function &getGroupTestList() {
  490. $urlExtra = '';
  491. $manager =& new HtmlTestManager();
  492. $groupTests =& $manager->_getTestGroupList($manager->_getTestsPath('groups'));
  493. $buffer = "<h3>Core Test Groups:</h3>\n<ul>";
  494. $urlExtra = null;
  495. if ($manager->appTest) {
  496. $buffer = "<h3>App Test Groups:</h3>\n<ul>";
  497. $urlExtra = '&app=true';
  498. } else if ($manager->pluginTest) {
  499. $buffer = "<h3>" . Inflector::humanize($manager->pluginTest) . " Test Groups:</h3>\n<ul>";
  500. $urlExtra = '&plugin=' . $manager->pluginTest;
  501. }
  502. $buffer .= "<li><a href='" . $manager->getBaseURL() . "?group=all$urlExtra'>All tests</a></li>\n";
  503. foreach ((array)$groupTests as $groupTest) {
  504. $buffer .= "<li><a href='" . $manager->getBaseURL() . "?group={$groupTest}" . "{$urlExtra}'>" . $groupTest . "</a></li>\n";
  505. }
  506. $buffer .= "</ul>\n";
  507. return $buffer;
  508. }
  509. /**
  510. * Prints the links to the available test cases
  511. *
  512. * @access public
  513. */
  514. function &getTestCaseList() {
  515. $urlExtra = '';
  516. $manager =& new HtmlTestManager();
  517. $testCases =& $manager->_getTestCaseList($manager->_getTestsPath());
  518. $buffer = "<h3>Core Test Cases:</h3>\n<ul>";
  519. $urlExtra = null;
  520. if ($manager->appTest) {
  521. $buffer = "<h3>App Test Cases:</h3>\n<ul>";
  522. $urlExtra = '&app=true';
  523. } else if ($manager->pluginTest) {
  524. $buffer = "<h3>" . Inflector::humanize($manager->pluginTest) . " Test Cases:</h3>\n<ul>";
  525. $urlExtra = '&plugin=' . $manager->pluginTest;
  526. }
  527. if (1 > count($testCases)) {
  528. $buffer .= "<strong>EMPTY</strong>";
  529. return $buffer;
  530. }
  531. foreach ($testCases as $testCaseFile => $testCase) {
  532. $title = explode(strpos($testCase, '\\') ? '\\' : '/', str_replace('.test.php', '', $testCase));
  533. $title[count($title) - 1] = Inflector::camelize($title[count($title) - 1]);
  534. $title = join(' / ', $title);
  535. $buffer .= "<li><a href='" . $manager->getBaseURL() . "?case=" . urlencode($testCase) . $urlExtra ."'>" . $title . "</a></li>\n";
  536. }
  537. $buffer .= "</ul>\n";
  538. return $buffer;
  539. }
  540. }
  541. if (function_exists('caketestsgetreporter')) {
  542. echo "You need a new test.php. \n";
  543. echo "Try this one: " . CONSOLE_LIBS . "templates" . DS . "skel" . DS . "webroot" . DS . "test.php";
  544. exit();
  545. } else {
  546. /**
  547. * Returns an object of the currently needed reporter
  548. *
  549. * @access public
  550. */
  551. function &CakeTestsGetReporter() {
  552. static $Reporter = NULL;
  553. if (!$Reporter) {
  554. switch (CAKE_TEST_OUTPUT) {
  555. case CAKE_TEST_OUTPUT_HTML:
  556. require_once CAKE_TESTS_LIB . 'cake_reporter.php';
  557. $Reporter =& new CakeHtmlReporter();
  558. break;
  559. default:
  560. $Reporter =& new TextReporter();
  561. break;
  562. }
  563. }
  564. return $Reporter;
  565. }
  566. /**
  567. * Provides the "Run More" links in the testsuite interface
  568. *
  569. * @return void
  570. * @access public
  571. */
  572. function CakePHPTestRunMore() {
  573. switch (CAKE_TEST_OUTPUT) {
  574. case CAKE_TEST_OUTPUT_HTML:
  575. if (isset($_GET['group'])) {
  576. if (isset($_GET['app'])) {
  577. $show = '?show=groups&amp;app=true';
  578. } else if (isset($_GET['plugin'])) {
  579. $show = '?show=groups&amp;plugin=' . $_GET['plugin'];
  580. } else {
  581. $show = '?show=groups';
  582. }
  583. $query = '?group='.$_GET['group'];
  584. if (isset($_GET['app'])) {
  585. $query .= '&amp;app=true';
  586. } elseif (isset($_GET['plugin'])) {
  587. $query .= '&amp;plugin=' . $_GET['plugin'];
  588. }
  589. }
  590. if (isset($_GET['case'])) {
  591. if (isset($_GET['app'])) {
  592. $show = '?show=cases&amp;app=true';
  593. } else if (isset($_GET['plugin'])) {
  594. $show = '?show=cases&amp;plugin=' . $_GET['plugin'];
  595. } else {
  596. $show = '?show=cases';
  597. }
  598. $query = '?case='.$_GET['case'];
  599. if (isset($_GET['app'])) {
  600. $query .= '&amp;app=true';
  601. } elseif (isset($_GET['plugin'])) {
  602. $query .= '&amp;plugin=' . $_GET['plugin'];
  603. }
  604. }
  605. ob_start();
  606. 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";
  607. break;
  608. }
  609. }
  610. /**
  611. * Provides the links to analyzing code coverage
  612. *
  613. * @return void
  614. * @access public
  615. */
  616. function CakePHPTestAnalyzeCodeCoverage() {
  617. switch (CAKE_TEST_OUTPUT) {
  618. case CAKE_TEST_OUTPUT_HTML:
  619. if (isset($_GET['case'])) {
  620. $query = '?case='.$_GET['case'];
  621. if (isset($_GET['app'])) {
  622. $query .= '&amp;app=true';
  623. } elseif (isset($_GET['plugin'])) {
  624. $query .= '&amp;plugin=' . $_GET['plugin'];
  625. }
  626. } else {
  627. $query = '?group='.$_GET['group'];
  628. if (isset($_GET['app'])) {
  629. $query .= '&amp;app=true';
  630. } elseif (isset($_GET['plugin'])) {
  631. $query .= '&amp;plugin=' . $_GET['plugin'];
  632. }
  633. }
  634. $query .= '&amp;code_coverage=true';
  635. ob_start();
  636. echo " <a href='" . RUN_TEST_LINK . $query . "'>Analyze Code Coverage</a></p>\n";
  637. break;
  638. }
  639. }
  640. /**
  641. * Prints a list of test cases
  642. *
  643. * @return void
  644. * @access public
  645. */
  646. function CakePHPTestCaseList() {
  647. switch (CAKE_TEST_OUTPUT) {
  648. case CAKE_TEST_OUTPUT_HTML:
  649. ob_start();
  650. echo HtmlTestManager::getTestCaseList();
  651. break;
  652. case CAKE_TEST_OUTPUT_TEXT:
  653. default:
  654. echo TextTestManager::getTestCaseList();
  655. break;
  656. }
  657. }
  658. /**
  659. * Prints a list of group tests
  660. *
  661. * @return void
  662. * @access public
  663. */
  664. function CakePHPTestGroupTestList() {
  665. switch (CAKE_TEST_OUTPUT) {
  666. case CAKE_TEST_OUTPUT_HTML:
  667. echo HtmlTestManager::getGroupTestList();
  668. break;
  669. case CAKE_TEST_OUTPUT_TEXT:
  670. default:
  671. echo TextTestManager::getGroupTestList();
  672. break;
  673. }
  674. }
  675. /**
  676. * Includes the Testsuite Header
  677. *
  678. * @return void
  679. * @access public
  680. */
  681. function CakePHPTestHeader() {
  682. switch (CAKE_TEST_OUTPUT) {
  683. case CAKE_TEST_OUTPUT_HTML:
  684. ob_start();
  685. if (!class_exists('dispatcher')) {
  686. require CAKE . 'dispatcher.php';
  687. }
  688. $dispatch =& new Dispatcher();
  689. $dispatch->baseUrl();
  690. define('BASE', $dispatch->webroot);
  691. $baseUrl = BASE;
  692. $characterSet = 'charset=utf-8';
  693. include CAKE_TESTS_LIB . 'header.php';
  694. break;
  695. case CAKE_TEST_OUTPUT_TEXT:
  696. default:
  697. header('content-type: text/plain');
  698. break;
  699. }
  700. }
  701. /**
  702. * Provides the left hand navigation for the testsuite
  703. *
  704. * @return void
  705. * @access public
  706. */
  707. function CakePHPTestSuiteHeader() {
  708. switch (CAKE_TEST_OUTPUT) {
  709. case CAKE_TEST_OUTPUT_HTML:
  710. ob_start();
  711. $groups = $_SERVER['PHP_SELF'].'?show=groups';
  712. $cases = $_SERVER['PHP_SELF'].'?show=cases';
  713. $plugins = Configure::listObjects('plugin');
  714. include CAKE_TESTS_LIB . 'content.php';
  715. break;
  716. }
  717. }
  718. /**
  719. * Provides the testsuite footer text
  720. *
  721. * @return void
  722. * @access public
  723. */
  724. function CakePHPTestSuiteFooter() {
  725. switch ( CAKE_TEST_OUTPUT) {
  726. case CAKE_TEST_OUTPUT_HTML:
  727. ob_start();
  728. $baseUrl = BASE;
  729. include CAKE_TESTS_LIB . 'footer.php';
  730. break;
  731. }
  732. }
  733. }
  734. ?>