[TASK] Replace inject methods with @inject
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Mvc / Controller / CommandControllerTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * All rights reserved
8 *
9 * This class is a backport of the corresponding class of TYPO3 Flow.
10 * All credits go to the TYPO3 Flow team.
11 *
12 * This script is part of the TYPO3 project. The TYPO3 project is
13 * free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * The GNU General Public License can be found at
19 * http://www.gnu.org/copyleft/gpl.html.
20 *
21 * This script is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
25 *
26 * This copyright notice MUST APPEAR in all copies of the script!
27 ***************************************************************/
28 /**
29 * Testcase for the Command Controller
30 */
31 class CommandControllerTest extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase {
32
33 /**
34 * @var \TYPO3\CMS\Extbase\Mvc\Controller\CommandController|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface
35 */
36 protected $commandController;
37
38 public function setUp() {
39 $this->commandController = $this->getAccessibleMock('TYPO3\\CMS\\Extbase\\Mvc\\Controller\\CommandController', array('dummy'));
40 }
41
42 /**
43 * @test
44 */
45 public function outputAppendsGivenStringToTheResponseContent() {
46 $mockResponse = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response');
47 $mockResponse->expects($this->once())->method('appendContent')->with('some text');
48 $this->commandController->_set('response', $mockResponse);
49 $this->commandController->_call('output', 'some text');
50 }
51
52 /**
53 * @test
54 */
55 public function outputReplacesArgumentsInGivenString() {
56 $mockResponse = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response');
57 $mockResponse->expects($this->once())->method('appendContent')->with('some text');
58 $this->commandController->_set('response', $mockResponse);
59 $this->commandController->_call('output', '%2$s %1$s', array('text', 'some'));
60 }
61
62 /**
63 * @test
64 */
65 public function outputLineAppendsGivenStringAndNewlineToTheResponseContent() {
66 $mockResponse = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response');
67 $mockResponse->expects($this->once())->method('appendContent')->with('some text' . PHP_EOL);
68 $this->commandController->_set('response', $mockResponse);
69 $this->commandController->_call('outputLine', 'some text');
70 }
71
72 /**
73 * @test
74 * @expectedException \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
75 */
76 public function quitThrowsStopActionException() {
77 $mockResponse = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response');
78 $this->commandController->_set('response', $mockResponse);
79 $this->commandController->_call('quit');
80 }
81
82 /**
83 * @test
84 * @expectedException \TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
85 */
86 public function quitSetsResponseExitCode() {
87 $mockResponse = $this->getMock('TYPO3\\CMS\\Extbase\\Mvc\\Cli\\Response');
88 $mockResponse->expects($this->once())->method('setExitCode')->with(123);
89 $this->commandController->_set('response', $mockResponse);
90 $this->commandController->_call('quit', 123);
91 }
92 }
93
94 ?>