[TASK] Streamline and optimize JavaScript in install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / View / JsonViewTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\Unit\View;
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 use TYPO3\CMS\Core\Tests\UnitTestCase;
18
19 /**
20 * Tests for the custom json view class
21 */
22 class JsonViewTest extends UnitTestCase
23 {
24 /**
25 * @test
26 */
27 public function transformStatusArrayToArrayReturnsArray()
28 {
29 $jsonView = $this->getAccessibleMock(\TYPO3\CMS\Install\View\JsonView::class, ['dummy']);
30 $this->assertInternalType('array', $jsonView->_call('transformStatusMessagesToArray'));
31 }
32
33 /**
34 * @test
35 * @expectedException \TYPO3\CMS\Install\Status\Exception
36 */
37 public function transformStatusArrayToArrayThrowsExceptionIfArrayContainsNotAMessageInterfaceMessage()
38 {
39 $jsonView = $this->getAccessibleMock(\TYPO3\CMS\Install\View\JsonView::class, ['dummy']);
40 $jsonView->_call('transformStatusMessagesToArray', ['foo']);
41 }
42
43 /**
44 * @test
45 */
46 public function transformStatusToArrayCreatesArrayFromStatusMessage()
47 {
48 $status = $this->getMock(\TYPO3\CMS\Install\Status\StatusInterface::class);
49 $status->expects($this->once())->method('getSeverity')->will($this->returnValue(-2));
50 $status->expects($this->once())->method('getTitle')->will($this->returnValue('aTitle'));
51 $status->expects($this->once())->method('getMessage')->will($this->returnValue('aMessage'));
52 $jsonView = $this->getAccessibleMock(\TYPO3\CMS\Install\View\JsonView::class, ['dummy']);
53 $return = $jsonView->_call('transformStatusToArray', $status);
54 $this->assertSame(-2, $return['severity']);
55 $this->assertSame('aTitle', $return['title']);
56 $this->assertSame('aMessage', $return['message']);
57 }
58 }