PageRenderTime 49ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/Cake/Test/Case/Console/Command/ApiShellTest.php

https://gitlab.com/manuperazafa/elsartenbackend
PHP | 95 lines | 57 code | 7 blank | 31 comment | 0 complexity | c61adbba65a1f5d05e03e5393316eabd MD5 | raw file
  1. <?php
  2. /**
  3. * ApiShellTest file
  4. *
  5. * CakePHP : Rapid Development Framework (http://cakephp.org)
  6. * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  7. *
  8. * Licensed under The MIT License
  9. * For full copyright and license information, please see the LICENSE.txt
  10. * Redistributions of files must retain the above copyright notice.
  11. *
  12. * @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
  13. * @link http://cakephp.org CakePHP Project
  14. * @package Cake.Test.Case.Console.Command
  15. * @since CakePHP v 1.2.0.7726
  16. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  17. */
  18. App::uses('ConsoleOutput', 'Console');
  19. App::uses('ConsoleInput', 'Console');
  20. App::uses('ShellDispatcher', 'Console');
  21. App::uses('Shell', 'Console');
  22. App::uses('ApiShell', 'Console/Command');
  23. /**
  24. * ApiShellTest class
  25. *
  26. * @package Cake.Test.Case.Console.Command
  27. */
  28. class ApiShellTest extends CakeTestCase {
  29. /**
  30. * setUp method
  31. *
  32. * @return void
  33. */
  34. public function setUp() {
  35. parent::setUp();
  36. $out = $this->getMock('ConsoleOutput', array(), array(), '', false);
  37. $in = $this->getMock('ConsoleInput', array(), array(), '', false);
  38. $this->Shell = $this->getMock(
  39. 'ApiShell',
  40. array('in', 'out', 'createFile', 'hr', '_stop'),
  41. array($out, $out, $in)
  42. );
  43. }
  44. /**
  45. * Test that method names are detected properly including those with no arguments.
  46. *
  47. * @return void
  48. */
  49. public function testMethodNameDetection() {
  50. $this->Shell->expects($this->any())->method('in')->will($this->returnValue('q'));
  51. $this->Shell->expects($this->at(0))->method('out')->with('Controller');
  52. $expected = array(
  53. '1. afterFilter()',
  54. '2. afterScaffoldSave($method)',
  55. '3. afterScaffoldSaveError($method)',
  56. '4. beforeFilter()',
  57. '5. beforeRedirect($url, $status = NULL, $exit = true)',
  58. '6. beforeRender()',
  59. '7. beforeScaffold($method)',
  60. '8. constructClasses()',
  61. '9. disableCache()',
  62. '10. flash($message, $url, $pause = 1, $layout = \'flash\')',
  63. '11. getEventManager()',
  64. '12. header($status)',
  65. '13. httpCodes($code = NULL)',
  66. '14. implementedEvents()',
  67. '15. invokeAction($request)',
  68. '16. loadModel($modelClass = NULL, $id = NULL)',
  69. '17. paginate($object = NULL, $scope = array (), $whitelist = array ())',
  70. '18. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)',
  71. '19. redirect($url, $status = NULL, $exit = true)',
  72. '20. referer($default = NULL, $local = false)',
  73. '21. render($view = NULL, $layout = NULL)',
  74. '22. scaffoldError($method)',
  75. '23. set($one, $two = NULL)',
  76. '24. setAction($action)',
  77. '25. setRequest($request)',
  78. '26. shutdownProcess()',
  79. '27. startupProcess()',
  80. '28. validate()',
  81. '29. validateErrors()'
  82. );
  83. $this->Shell->expects($this->at(2))->method('out')->with($expected);
  84. $this->Shell->args = array('controller');
  85. $this->Shell->paths['controller'] = CAKE . 'Controller' . DS;
  86. $this->Shell->main();
  87. }
  88. }