PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/tests/cases/console/libs/api.test.php

http://github.com/abalonepaul/eav_behavior
PHP | 116 lines | 65 code | 9 blank | 42 comment | 3 complexity | 54573572f817d1e2b204980765ed7323 MD5 | raw file
  1. <?php
  2. /**
  3. * ApiShellTest file
  4. *
  5. * PHP versions 4 and 5
  6. *
  7. * CakePHP : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2005-2011, Cake Software Foundation, Inc.
  9. *
  10. * Licensed under The MIT License
  11. * Redistributions of files must retain the above copyright notice.
  12. *
  13. * @copyright Copyright 2005-2011, Cake Software Foundation, Inc.
  14. * @link http://cakephp.org CakePHP Project
  15. * @package cake
  16. * @subpackage cake.tests.cases.console.libs.tasks
  17. * @since CakePHP v 1.2.0.7726
  18. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  19. */
  20. App::import('Shell', 'Shell', false);
  21. if (!defined('DISABLE_AUTO_DISPATCH')) {
  22. define('DISABLE_AUTO_DISPATCH', true);
  23. }
  24. if (!class_exists('ShellDispatcher')) {
  25. ob_start();
  26. $argv = false;
  27. require CAKE . 'console' . DS . 'cake.php';
  28. ob_end_clean();
  29. }
  30. if (!class_exists('ApiShell')) {
  31. require CAKE . 'console' . DS . 'libs' . DS . 'api.php';
  32. }
  33. Mock::generatePartial(
  34. 'ShellDispatcher', 'ApiShellMockShellDispatcher',
  35. array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
  36. );
  37. Mock::generatePartial(
  38. 'ApiShell', 'MockApiShell',
  39. array('in', 'out', 'createFile', 'hr', '_stop')
  40. );
  41. /**
  42. * ApiShellTest class
  43. *
  44. * @package cake
  45. * @subpackage cake.tests.cases.console.libs.tasks
  46. */
  47. class ApiShellTest extends CakeTestCase {
  48. /**
  49. * setUp method
  50. *
  51. * @return void
  52. * @access public
  53. */
  54. function startTest() {
  55. $this->Dispatcher =& new ApiShellMockShellDispatcher();
  56. $this->Shell =& new MockApiShell($this->Dispatcher);
  57. $this->Shell->Dispatch =& $this->Dispatcher;
  58. }
  59. /**
  60. * tearDown method
  61. *
  62. * @return void
  63. * @access public
  64. */
  65. function endTest() {
  66. ClassRegistry::flush();
  67. }
  68. /**
  69. * Test that method names are detected properly including those with no arguments.
  70. *
  71. * @return void
  72. * @access public
  73. */
  74. function testMethodNameDetection () {
  75. $this->Shell->setReturnValueAt(0, 'in', 'q');
  76. $this->Shell->expectAt(0, 'out', array('Controller'));
  77. $expected = array(
  78. array(
  79. '1. afterFilter()',
  80. '2. beforeFilter()',
  81. '3. beforeRender()',
  82. '4. constructClasses()',
  83. '5. disableCache()',
  84. '6. flash($message, $url, $pause = 1, $layout = \'flash\')',
  85. '7. header($status)',
  86. '8. httpCodes($code = null)',
  87. '9. isAuthorized()',
  88. '10. loadModel($modelClass = null, $id = null)',
  89. '11. paginate($object = null, $scope = array(), $whitelist = array())',
  90. '12. postConditions($data = array(), $op = null, $bool = \'AND\', $exclusive = false)',
  91. '13. redirect($url, $status = null, $exit = true)',
  92. '14. referer($default = null, $local = false)',
  93. '15. render($action = null, $layout = null, $file = null)',
  94. '16. set($one, $two = null)',
  95. '17. setAction($action)',
  96. '18. shutdownProcess()',
  97. '19. startupProcess()',
  98. '20. validate()',
  99. '21. validateErrors()'
  100. )
  101. );
  102. $this->Shell->expectAt(1, 'out', $expected);
  103. $this->Shell->args = array('controller');
  104. $this->Shell->paths['controller'] = CAKE_CORE_INCLUDE_PATH . DS . LIBS . 'controller' . DS;
  105. $this->Shell->main();
  106. }
  107. }