[CLEANUP] Rework/simplify copyright header and remove @package
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Mvc / Cli / RequestTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Cli;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Test case
19 */
20 class RequestTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
21
22 /**
23 * @var \TYPO3\CMS\Extbase\Mvc\Cli\Request|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
24 */
25 protected $request;
26
27 /**
28 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
29 */
30 protected $mockObjectManager;
31
32 /**
33 * Sets up this test case
34 */
35 public function setUp() {
36 $this->request = $this->getAccessibleMock('TYPO3\CMS\Extbase\Mvc\Cli\Request', array('dummy'));
37 $this->mockObjectManager = $this->getMock('TYPO3\\CMS\\Extbase\\Object\\ObjectManagerInterface');
38 $this->request->_set('objectManager', $this->mockObjectManager);
39 }
40
41 /**
42 * @test
43 * @author Robert Lemke <robert@typo3.org>
44 */
45 public function getCommandReturnsTheCommandObjectReflectingTheRequestInformation() {
46 $this->request->setControllerObjectName('Tx_Extbase_Command_CacheCommandController');
47 $this->request->setControllerCommandName('flush');
48 $this->mockObjectManager->expects($this->once())->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Command', 'Tx_Extbase_Command_CacheCommandController', 'flush');
49 $this->request->getCommand();
50 }
51
52 /**
53 * @test
54 * @author Robert Lemke <robert@typo3.org>
55 */
56 public function setControllerObjectNameAndSetControllerCommandNameUnsetTheBuiltCommandObject() {
57 $this->request->setControllerObjectName('Tx_Extbase_Command_CacheCommandController');
58 $this->request->setControllerCommandName('flush');
59 $this->request->getCommand();
60 $this->request->setControllerObjectName('Tx_SomeExtension_Command_BeerCommandController');
61 $this->request->setControllerCommandName('drink');
62 $this->mockObjectManager->expects($this->once())->method('get')->with('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Command', 'Tx_SomeExtension_Command_BeerCommandController', 'drink');
63 $this->request->getCommand();
64 }
65
66 /**
67 * @test
68 */
69 public function setControllerObjectNameProperlyResolvesExtensionNameWithNamespaces() {
70 $mockCliRequest = new \TYPO3\CMS\Extbase\Mvc\Cli\Request;
71 $mockCliRequest->setControllerObjectName('TYPO3\CMS\Extbase\Command\NamespacedMockCommandController');
72
73 $this->assertSame('Extbase', $mockCliRequest->getControllerExtensionName());
74 }
75
76 /**
77 * @test
78 */
79 public function setControllerObjectNameProperlyResolvesExtensionNameWithoutNamespaces() {
80 $mockCliRequest = new \TYPO3\CMS\Extbase\Mvc\Cli\Request;
81 $mockCliRequest->setControllerObjectName('Tx_Extbase_Command_OldschoolMockCommandController');
82
83 $this->assertSame('Extbase', $mockCliRequest->getControllerExtensionName());
84 }
85 }