ApiShellTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * CakePHP : Rapid Development Framework (http://cakephp.org)
  4. * Copyright 2005-2012, Cake Software Foundation, Inc.
  5. *
  6. * Licensed under The MIT License
  7. * Redistributions of files must retain the above copyright notice.
  8. *
  9. * @copyright Copyright 2005-2012, Cake Software Foundation, Inc.
  10. * @link http://cakephp.org CakePHP Project
  11. * @since CakePHP v 1.2.0.7726
  12. * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
  13. */
  14. namespace Cake\Test\TestCase\Console\Command;
  15. use Cake\Console\Command\ApiShellShell;
  16. use Cake\TestSuite\TestCase;
  17. /**
  18. * ApiShellTest class
  19. *
  20. */
  21. class ApiShellTest extends TestCase {
  22. /**
  23. * setUp method
  24. *
  25. * @return void
  26. */
  27. public function setUp() {
  28. parent::setUp();
  29. $out = $this->getMock('Cake\Console\ConsoleOutput', [], [], '', false);
  30. $in = $this->getMock('Cake\Console\ConsoleInput', [], [], '', false);
  31. $this->Shell = $this->getMock(
  32. 'Cake\Console\Command\ApiShell',
  33. ['in', 'out', 'createFile', 'hr', '_stop'],
  34. [$out, $out, $in]
  35. );
  36. }
  37. /**
  38. * Test that method names are detected properly including those with no arguments.
  39. *
  40. * @return void
  41. */
  42. public function testMethodNameDetection() {
  43. $this->Shell->expects($this->any())
  44. ->method('in')->will($this->returnValue('q'));
  45. $this->Shell->expects($this->at(0))
  46. ->method('out')->with('Controller');
  47. $this->Shell->expects($this->at(2))
  48. ->method('out')
  49. ->with($this->logicalAnd(
  50. $this->contains('8. beforeFilter($event)'),
  51. $this->contains('21. render($view = NULL, $layout = NULL)')
  52. ));
  53. $this->Shell->args = ['controller'];
  54. $this->Shell->paths['controller'] = CAKE . 'Controller/';
  55. $this->Shell->main();
  56. }
  57. }