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 12:31:21 -04:00
|
|
|
* PHP 5
|
2009-06-25 13:34:28 +00:00
|
|
|
*
|
2010-01-26 17:15:15 -05:00
|
|
|
* CakePHP : Rapid Development Framework (http://cakephp.org)
|
2010-01-13 23:47:14 -05:00
|
|
|
* Copyright 2006-2010, 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.
|
|
|
|
*
|
2010-01-13 23:47:14 -05:00
|
|
|
* @copyright Copyright 2006-2010, Cake Software Foundation, Inc.
|
2009-11-06 17:00:11 +11:00
|
|
|
* @link http://cakephp.org CakePHP Project
|
2010-12-24 13:57:20 -05:00
|
|
|
* @package cake.tests.cases.console.libs.tasks
|
2009-06-25 13:34:28 +00:00
|
|
|
* @since CakePHP v 1.2.0.7726
|
2009-11-06 17:51:51 +11:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2009-06-25 13:34:28 +00:00
|
|
|
*/
|
2009-07-25 18:27:02 -07:00
|
|
|
App::import('Shell', 'Shell', false);
|
2010-10-17 15:43:20 -04:00
|
|
|
App::import('Shell', 'Api');
|
2009-06-25 13:34:28 +00:00
|
|
|
|
2010-10-03 01:53:42 -04:00
|
|
|
require_once CAKE . 'console' . DS . 'shell_dispatcher.php';
|
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
|
|
|
*
|
2010-12-24 13:57:20 -05:00
|
|
|
* @package cake.tests.cases.console.libs.tasks
|
2009-06-25 13:34:28 +00:00
|
|
|
*/
|
2009-07-23 13:31:16 +00:00
|
|
|
class ApiShellTest extends CakeTestCase {
|
2009-07-24 21:18:37 +02:00
|
|
|
|
2009-06-25 13:34:28 +00:00
|
|
|
/**
|
2010-09-25 21:36:49 -04:00
|
|
|
* setUp method
|
2009-06-25 13:34:28 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
2010-09-25 21:36:49 -04:00
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2010-10-06 22:52:42 -04:00
|
|
|
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
|
|
|
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
|
|
|
|
2010-05-22 22:09:07 -04:00
|
|
|
$this->Shell = $this->getMock(
|
|
|
|
'ApiShell',
|
|
|
|
array('in', 'out', 'createFile', 'hr', '_stop'),
|
2010-10-24 15:11:30 -04:00
|
|
|
array( $out, $out, $in)
|
2010-05-22 22:09:07 -04:00
|
|
|
);
|
2009-06-25 13:34:28 +00:00
|
|
|
}
|
2009-07-24 21:18:37 +02: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 13:19:38 +10:00
|
|
|
public function testMethodNameDetection () {
|
2010-05-22 22:09:07 -04: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-22 22:09:07 -04:00
|
|
|
'1. afterFilter()',
|
|
|
|
'2. beforeFilter()',
|
|
|
|
'3. beforeRender()',
|
|
|
|
'4. constructClasses()',
|
|
|
|
'5. disableCache()',
|
|
|
|
'6. flash($message, $url, $pause = 1, $layout = \'flash\')',
|
2010-09-07 23:42:18 -04:00
|
|
|
'7. getResponse()',
|
|
|
|
'8. header($status)',
|
|
|
|
'9. httpCodes($code = NULL)',
|
|
|
|
'10. isAuthorized()',
|
|
|
|
'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($action = NULL, $layout = NULL, $file = NULL)',
|
|
|
|
'17. set($one, $two = NULL)',
|
|
|
|
'18. setAction($action)',
|
2010-12-15 22:08:24 -05:00
|
|
|
'19. setRequest($request)',
|
|
|
|
'20. shutdownProcess()',
|
|
|
|
'21. startupProcess()',
|
|
|
|
'22. validate()',
|
|
|
|
'23. validateErrors()'
|
2009-06-25 13:34:28 +00:00
|
|
|
);
|
2010-05-22 22:09:07 -04:00
|
|
|
$this->Shell->expects($this->at(2))->method('out')->with($expected);
|
2009-07-20 09:31:56 -07:00
|
|
|
|
2009-06-25 13:34:28 +00:00
|
|
|
$this->Shell->args = array('controller');
|
2010-12-05 23:32:34 -05:00
|
|
|
$this->Shell->paths['controller'] = LIBS . 'controller' . DS;
|
2009-06-25 13:34:28 +00:00
|
|
|
$this->Shell->main();
|
|
|
|
}
|
|
|
|
}
|