ApiShellTest.php 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * ApiShellTest file
  4. *
  5. * PHP 5
  6. *
  7. * CakePHP : Rapid Development Framework (http://cakephp.org)
  8. * Copyright 2006-2010, 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 2006-2010, Cake Software Foundation, Inc.
  14. * @link http://cakephp.org CakePHP Project
  15. * @package cake.tests.cases.console.libs.tasks
  16. * @since CakePHP v 1.2.0.7726
  17. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  18. */
  19. App::uses('ShellDispatcher', 'Console');
  20. App::uses('Shell', 'Console');
  21. App::uses('ApiShell', 'Console/Command');
  22. /**
  23. * ApiShellTest class
  24. *
  25. * @package cake.tests.cases.console.libs.tasks
  26. */
  27. class ApiShellTest extends CakeTestCase {
  28. /**
  29. * setUp method
  30. *
  31. * @return void
  32. */
  33. public function setUp() {
  34. parent::setUp();
  35. $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
  36. $in = $this->getMock('ConsoleInput', array(), array(), '', false);
  37. $this->Shell = $this->getMock(
  38. 'ApiShell',
  39. array('in', 'out', 'createFile', 'hr', '_stop'),
  40. array( $out, $out, $in)
  41. );
  42. }
  43. /**
  44. * Test that method names are detected properly including those with no arguments.
  45. *
  46. * @return void
  47. */
  48. public function testMethodNameDetection () {
  49. $this->Shell->expects($this->any())->method('in')->will($this->returnValue('q'));
  50. $this->Shell->expects($this->at(0))->method('out')->with('Controller');
  51. $expected = array(
  52. '1. afterFilter()',
  53. '2. beforeFilter()',
  54. '3. beforeRedirect($url, $status = NULL, $exit = true)',
  55. '4. beforeRender()',
  56. '5. constructClasses()',
  57. '6. disableCache()',
  58. '7. flash($message, $url, $pause = 1, $layout = \'flash\')',
  59. '8. getResponse()',
  60. '9. header($status)',
  61. '10. httpCodes($code = NULL)',
  62. '11. loadModel($modelClass = NULL, $id = NULL)',
  63. '12. paginate($object = NULL, $scope = array (), $whitelist = array ())',
  64. '13. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)',
  65. '14. redirect($url, $status = NULL, $exit = true)',
  66. '15. referer($default = NULL, $local = false)',
  67. '16. render($view = NULL, $layout = NULL)',
  68. '17. set($one, $two = NULL)',
  69. '18. setAction($action)',
  70. '19. setRequest($request)',
  71. '20. shutdownProcess()',
  72. '21. startupProcess()',
  73. '22. validate()',
  74. '23. validateErrors()'
  75. );
  76. $this->Shell->expects($this->at(2))->method('out')->with($expected);
  77. $this->Shell->args = array('controller');
  78. $this->Shell->paths['controller'] = LIBS . 'Controller' . DS;
  79. $this->Shell->main();
  80. }
  81. }