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
|
|
|
*
|
2010-10-03 16:31:21 +00:00
|
|
|
* PHP 5
|
2009-06-25 13:34:28 +00:00
|
|
|
*
|
2010-01-26 22:15:15 +00:00
|
|
|
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
2011-05-29 21:31:39 +00:00
|
|
|
* Copyright 2005-2011, Cake Software Foundation, Inc.
|
2009-06-25 13:34:28 +00:00
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
2011-05-29 21:31:39 +00:00
|
|
|
* @copyright Copyright 2005-2011, Cake Software Foundation, Inc.
|
2009-11-06 06:00:11 +00:00
|
|
|
* @link http://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
|
2009-11-06 06:51:51 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2009-06-25 13:34:28 +00:00
|
|
|
*/
|
|
|
|
|
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'),
|
2010-10-24 19:11:30 +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
|
|
|
|
*/
|
2010-04-05 03:19:38 +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()',
|
|
|
|
'2. beforeFilter()',
|
2011-02-05 06:40:14 +00:00
|
|
|
'3. beforeRedirect($url, $status = NULL, $exit = true)',
|
|
|
|
'4. beforeRender()',
|
|
|
|
'5. constructClasses()',
|
|
|
|
'6. disableCache()',
|
|
|
|
'7. flash($message, $url, $pause = 1, $layout = \'flash\')',
|
2011-07-20 02:51:49 +00:00
|
|
|
'8. header($status)',
|
|
|
|
'9. httpCodes($code = NULL)',
|
|
|
|
'10. invokeAction($request)',
|
|
|
|
'11. loadModel($modelClass = NULL, $id = NULL)',
|
|
|
|
'12. paginate($object = NULL, $scope = array (), $whitelist = array ())',
|
|
|
|
'13. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)',
|
|
|
|
'14. redirect($url, $status = NULL, $exit = true)',
|
|
|
|
'15. referer($default = NULL, $local = false)',
|
|
|
|
'16. render($view = NULL, $layout = NULL)',
|
|
|
|
'17. set($one, $two = NULL)',
|
|
|
|
'18. setAction($action)',
|
|
|
|
'19. setRequest($request)',
|
|
|
|
'20. shutdownProcess()',
|
|
|
|
'21. startupProcess()',
|
|
|
|
'22. validate()',
|
|
|
|
'23. 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();
|
|
|
|
}
|
|
|
|
}
|