[+FEATURE] Backport CommandController Implementation
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / MVC / CLI / RequestTest.php
1 <?php
2 /* *
3 * This script belongs to the Extbase framework. *
4 * *
5 * It is free software; you can redistribute it and/or modify it under *
6 * the terms of the GNU Lesser General Public License as published by the *
7 * Free Software Foundation, either version 3 of the License, or (at your *
8 * option) any later version. *
9 * *
10 * This script is distributed in the hope that it will be useful, but *
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
12 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
13 * General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU Lesser General Public *
16 * License along with the script. *
17 * If not, see http://www.gnu.org/licenses/lgpl.html *
18 * *
19 * The TYPO3 project - inspiring people to share! *
20 * */
21
22 /**
23 * Testcase for the CLI Request class
24 */
25 class Tx_Extbase_Tests_Unit_MVC_CLI_RequestTest extends Tx_Extbase_Tests_Unit_BaseTestCase {
26
27 /**
28 * @var Tx_Extbase_MVC_CLI_Request
29 */
30 protected $request;
31
32 /**
33 * @var Tx_Extbase_Object_ObjectManagerInterface
34 */
35 protected $mockObjectManager;
36
37 /**
38 * Sets up this test case
39 */
40 public function setUp() {
41 $this->request = new Tx_Extbase_MVC_CLI_Request();
42
43 $this->mockObjectManager = $this->getMock('Tx_Extbase_Object_ObjectManagerInterface');
44 $this->request->injectObjectManager($this->mockObjectManager);
45 }
46
47 /**
48 * @test
49 * @author Robert Lemke <robert@typo3.org>
50 */
51 public function getCommandReturnsTheCommandObjectReflectingTheRequestInformation() {
52 $this->request->setControllerObjectName('Tx_Extbase_Command_CacheCommandController');
53 $this->request->setControllerCommandName('flush');
54
55 $this->mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_MVC_CLI_Command', 'Tx_Extbase_Command_CacheCommandController', 'flush');
56 $this->request->getCommand();
57 }
58
59 /**
60 * @test
61 * @author Robert Lemke <robert@typo3.org>
62 */
63 public function setControllerObjectNameAndSetControllerCommandNameUnsetTheBuiltCommandObject() {
64 $this->request->setControllerObjectName('Tx_Extbase_Command_CacheCommandController');
65 $this->request->setControllerCommandName('flush');
66 $this->request->getCommand();
67
68 $this->request->setControllerObjectName('Tx_SomeExtension_Command_BeerCommandController');
69 $this->request->setControllerCommandName('drink');
70
71 $this->mockObjectManager->expects($this->once())->method('get')->with('Tx_Extbase_MVC_CLI_Command', 'Tx_SomeExtension_Command_BeerCommandController', 'drink');
72 $this->request->getCommand();
73 }
74 }
75 ?>