pictcode / lib / Cake / Test / Case / Console / Command / ApiShellTest.php @ 0b1b8047
履歴 | 表示 | アノテート | ダウンロード (2.944 KB)
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 |
|
19 |
App::uses('ConsoleOutput', 'Console'); |
20 |
App::uses('ConsoleInput', 'Console'); |
21 |
App::uses('ShellDispatcher', 'Console'); |
22 |
App::uses('Shell', 'Console'); |
23 |
App::uses('ApiShell', 'Console/Command'); |
24 |
|
25 |
/**
|
26 |
* ApiShellTest class
|
27 |
*
|
28 |
* @package Cake.Test.Case.Console.Command
|
29 |
*/
|
30 |
class ApiShellTest extends CakeTestCase { |
31 |
|
32 |
/**
|
33 |
* setUp method
|
34 |
*
|
35 |
* @return void
|
36 |
*/
|
37 |
public function setUp() { |
38 |
parent::setUp();
|
39 |
$out = $this->getMock('ConsoleOutput', array(), array(), '', false); |
40 |
$in = $this->getMock('ConsoleInput', array(), array(), '', false); |
41 |
|
42 |
$this->Shell = $this->getMock( |
43 |
'ApiShell',
|
44 |
array('in', 'out', 'createFile', 'hr', '_stop'), |
45 |
array($out, $out, $in) |
46 |
); |
47 |
} |
48 |
|
49 |
/**
|
50 |
* Test that method names are detected properly including those with no arguments.
|
51 |
*
|
52 |
* @return void
|
53 |
*/
|
54 |
public function testMethodNameDetection() { |
55 |
$this->Shell->expects($this->any())->method('in')->will($this->returnValue('q')); |
56 |
$this->Shell->expects($this->at(0))->method('out')->with('Controller'); |
57 |
|
58 |
$expected = array( |
59 |
'1. afterFilter()',
|
60 |
'2. afterScaffoldSave($method)',
|
61 |
'3. afterScaffoldSaveError($method)',
|
62 |
'4. beforeFilter()',
|
63 |
'5. beforeRedirect($url, $status = NULL, $exit = true)',
|
64 |
'6. beforeRender()',
|
65 |
'7. beforeScaffold($method)',
|
66 |
'8. constructClasses()',
|
67 |
'9. disableCache()',
|
68 |
'10. flash($message, $url, $pause = 1, $layout = \'flash\')',
|
69 |
'11. getEventManager()',
|
70 |
'12. header($status)',
|
71 |
'13. httpCodes($code = NULL)',
|
72 |
'14. implementedEvents()',
|
73 |
'15. invokeAction($request)',
|
74 |
'16. loadModel($modelClass = NULL, $id = NULL)',
|
75 |
'17. paginate($object = NULL, $scope = array (), $whitelist = array ())',
|
76 |
'18. postConditions($data = array (), $op = NULL, $bool = \'AND\', $exclusive = false)',
|
77 |
'19. redirect($url, $status = NULL, $exit = true)',
|
78 |
'20. referer($default = NULL, $local = false)',
|
79 |
'21. render($view = NULL, $layout = NULL)',
|
80 |
'22. scaffoldError($method)',
|
81 |
'23. set($one, $two = NULL)',
|
82 |
'24. setAction($action)',
|
83 |
'25. setRequest($request)',
|
84 |
'26. shutdownProcess()',
|
85 |
'27. startupProcess()',
|
86 |
'28. validate()',
|
87 |
'29. validateErrors()'
|
88 |
); |
89 |
$this->Shell->expects($this->at(2))->method('out')->with($expected); |
90 |
|
91 |
$this->Shell->args = array('controller'); |
92 |
$this->Shell->paths['controller'] = CAKE . 'Controller' . DS; |
93 |
$this->Shell->main(); |
94 |
} |
95 |
} |