2009-06-25 13:34:28 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-07-23 13:31:16 +00:00
|
|
|
* ApiShellTest file
|
2009-06-25 13:34:28 +00:00
|
|
|
*
|
2017-06-10 21:33:55 +00:00
|
|
|
* CakePHP : Rapid Development Framework (https://cakephp.org)
|
2017-06-10 22:10:52 +00:00
|
|
|
* Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2009-06-25 13:34:28 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
2013-02-08 12:22:51 +00:00
|
|
|
* For full copyright and license information, please see the LICENSE.txt
|
2009-06-25 13:34:28 +00:00
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2017-06-10 22:10:52 +00:00
|
|
|
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
|
2017-06-10 21:33:55 +00:00
|
|
|
* @link https://cakephp.org CakePHP Project
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command
|
2009-06-25 13:34:28 +00:00
|
|
|
* @since CakePHP v 1.2.0.7726
|
2017-06-10 22:23:14 +00:00
|
|
|
* @license https://opensource.org/licenses/mit-license.php MIT License
|
2009-06-25 13:34:28 +00:00
|
|
|
*/
|
|
|
|
|
2012-05-25 16:27:40 +00:00
|
|
|
App::uses('ConsoleOutput', 'Console');
|
|
|
|
App::uses('ConsoleInput', 'Console');
|
2010-12-09 03:45:18 +00:00
|
|
|
App::uses('ShellDispatcher', 'Console');
|
|
|
|
App::uses('Shell', 'Console');
|
|
|
|
App::uses('ApiShell', 'Console/Command');
|
2009-06-25 13:34:28 +00:00
|
|
|
|
|
|
|
/**
|
2009-07-23 13:31:16 +00:00
|
|
|
* ApiShellTest class
|
2009-06-25 13:34:28 +00:00
|
|
|
*
|
2011-07-26 06:16:14 +00:00
|
|
|
* @package Cake.Test.Case.Console.Command
|
2009-06-25 13:34:28 +00:00
|
|
|
*/
|
2009-07-23 13:31:16 +00:00
|
|
|
class ApiShellTest extends CakeTestCase {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-06-25 13:34:28 +00:00
|
|
|
/**
|
2010-09-26 01:36:49 +00:00
|
|
|
* setUp method
|
2009-06-25 13:34:28 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-09-26 01:36:49 +00:00
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2010-10-07 02:52:42 +00:00
|
|
|
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
|
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
|
|
2010-05-23 02:09:07 +00:00
|
|
|
$this->Shell = $this->getMock(
|
|
|
|
'ApiShell',
|
|
|
|
array('in', 'out', 'createFile', 'hr', '_stop'),
|
2013-08-06 09:13:53 +00:00
|
|
|
array($out, $out, $in)
|
2010-05-23 02:09:07 +00:00
|
|
|
);
|
2009-06-25 13:34:28 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-06-25 13:34:28 +00:00
|
|
|
/**
|
|
|
|
* Test that method names are detected properly including those with no arguments.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2012-02-23 13:38:02 +00:00
|
|
|
public function testMethodNameDetection() {
|
2010-05-23 02:09:07 +00:00
|
|
|
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('q'));
|
|
|
|
$this->Shell->expects($this->at(0))->method('out')->with('Controller');
|
|
|
|
|
2009-06-25 13:34:28 +00:00
|
|
|
$expected = array(
|
2010-05-23 02:09:07 +00:00
|
|
|
'1. afterFilter()',
|
2011-08-25 01:45:33 +00:00
|
|
|
'2. afterScaffoldSave($method)',
|
|
|
|
'3. afterScaffoldSaveError($method)',
|
|
|
|
'4. beforeFilter()',
|
|
|
|
'5. beforeRedirect($url, $status = NULL, $exit = true)',
|
|
|
|
'6. beforeRender()',
|
|
|
|
'7. beforeScaffold($method)',
|
|
|
|
'8. constructClasses()',
|
|
|
|
'9. disableCache()',
|
|
|
|
'10. flash($message, $url, $pause = 1, $layout = \'flash\')',
|
2011-12-26 02:22:12 +00:00
|
|
|
'11. getEventManager()',
|
|
|
|
'12. header($status)',
|
|
|
|
'13. httpCodes($code = NULL)',
|
|
|
|
'14. implementedEvents()',
|
|
|
|
'15. invokeAction($request)',
|
|
|
|
'16. loadModel($modelClass = NULL, $id = NULL)',
|
|
|
|
'17. paginate($object = NULL, $scope = array (), $whitelist = array ())',
|
|
|
|
'18. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)',
|
|
|
|
'19. redirect($url, $status = NULL, $exit = true)',
|
|
|
|
'20. referer($default = NULL, $local = false)',
|
|
|
|
'21. render($view = NULL, $layout = NULL)',
|
|
|
|
'22. scaffoldError($method)',
|
|
|
|
'23. set($one, $two = NULL)',
|
|
|
|
'24. setAction($action)',
|
|
|
|
'25. setRequest($request)',
|
|
|
|
'26. shutdownProcess()',
|
|
|
|
'27. startupProcess()',
|
|
|
|
'28. validate()',
|
|
|
|
'29. validateErrors()'
|
2009-06-25 13:34:28 +00:00
|
|
|
);
|
2010-05-23 02:09:07 +00:00
|
|
|
$this->Shell->expects($this->at(2))->method('out')->with($expected);
|
2009-07-20 16:31:56 +00:00
|
|
|
|
2009-06-25 13:34:28 +00:00
|
|
|
$this->Shell->args = array('controller');
|
2011-04-17 10:35:21 +00:00
|
|
|
$this->Shell->paths['controller'] = CAKE . 'Controller' . DS;
|
2009-06-25 13:34:28 +00:00
|
|
|
$this->Shell->main();
|
|
|
|
}
|
|
|
|
}
|