‪TYPO3CMS  9.5
CommandControllerTest.php
Go to the documentation of this file.
1 <?php
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  */
17 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
18 
22 class ‪CommandControllerTest extends UnitTestCase
23 {
27  protected ‪$commandController;
28 
32  protected ‪$mockConsoleOutput;
33 
34  protected function ‪setUp()
35  {
36  $this->commandController = $this->getAccessibleMock(\‪TYPO3\CMS\‪Extbase\Mvc\Controller\CommandController::class, ['dummyCommand']);
37  $this->mockConsoleOutput = $this->getMockBuilder(\‪TYPO3\CMS\‪Extbase\Mvc\Cli\ConsoleOutput::class)->disableOriginalConstructor()->getMock();
38  $this->commandController->_set('output', $this->mockConsoleOutput);
39  }
40 
45  {
46  $this->mockConsoleOutput->expects($this->once())->method('output')->with('some text');
47  $this->commandController->_call('output', 'some text');
48  }
49 
54  {
55  $this->mockConsoleOutput->expects($this->once())->method('output')->with('%2$s %1$s', ['text', 'some']);
56  $this->commandController->_call('output', '%2$s %1$s', ['text', 'some']);
57  }
58 
62  public function ‪quitThrowsStopActionException()
63  {
64  $this->expectException(StopActionException::class);
65  // @TODO expectExceptionCode is 0
66  $mockResponse = $this->createMock(\‪TYPO3\CMS\‪Extbase\Mvc\Cli\Response::class);
67  $this->commandController->_set('response', $mockResponse);
68  $this->commandController->_call('quit');
69  }
70 
74  public function ‪quitSetsResponseExitCode()
75  {
76  $this->expectException(StopActionException::class);
77  // @TODO expectExceptionCode is 0
78  $mockResponse = $this->createMock(\‪TYPO3\CMS\‪Extbase\Mvc\Cli\Response::class);
79  $mockResponse->expects($this->once())->method('setExitCode')->with(123);
80  $this->commandController->_set('response', $mockResponse);
81  $this->commandController->_call('quit', 123);
82  }
83 }
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller\CommandControllerTest\outputReplacesArgumentsInGivenString
‪outputReplacesArgumentsInGivenString()
Definition: CommandControllerTest.php:52
‪TYPO3\CMS\Extbase\Mvc\Exception\StopActionException
Definition: StopActionException.php:26
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller\CommandControllerTest\$mockConsoleOutput
‪$mockConsoleOutput
Definition: CommandControllerTest.php:31
‪TYPO3\CMS\Extbase\Annotation
Definition: IgnoreValidation.php:4
‪TYPO3
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller\CommandControllerTest\outputAppendsGivenStringToTheResponseContent
‪outputAppendsGivenStringToTheResponseContent()
Definition: CommandControllerTest.php:43
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller\CommandControllerTest
Definition: CommandControllerTest.php:23
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller
Definition: CommandControllerTest.php:2
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller\CommandControllerTest\setUp
‪setUp()
Definition: CommandControllerTest.php:33
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller\CommandControllerTest\quitSetsResponseExitCode
‪quitSetsResponseExitCode()
Definition: CommandControllerTest.php:73
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller\CommandControllerTest\quitThrowsStopActionException
‪quitThrowsStopActionException()
Definition: CommandControllerTest.php:61
‪TYPO3\CMS\Extbase\Tests\UnitDeprecated\Mvc\Controller\CommandControllerTest\$commandController
‪TYPO3 CMS Extbase Mvc Controller CommandController PHPUnit_Framework_MockObject_MockObject TYPO3 TestingFramework Core AccessibleObjectInterface $commandController
Definition: CommandControllerTest.php:26