Revert "[FOLLOWUP][TASK] Base Install Tool on Bootstrap"
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / Status / StatusUtilityTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\Unit\Status;
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\Install\Status\StatusUtility;
18
19 /**
20 * Test case
21 */
22 class StatusUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
23 {
24 /**
25 * @test
26 */
27 public function sortBySeveritySortsGivenStatusObjects()
28 {
29 $errorMock = $this->getMock(\TYPO3\CMS\Install\Status\ErrorStatus::class, array('dummy'));
30 $warningMock = $this->getMock(\TYPO3\CMS\Install\Status\WarningStatus::class, array('dummy'));
31 $okMock = $this->getMock(\TYPO3\CMS\Install\Status\OkStatus::class, array('dummy'));
32 $infoMock = $this->getMock(\TYPO3\CMS\Install\Status\InfoStatus::class, array('dummy'));
33 $noticeMock = $this->getMock(\TYPO3\CMS\Install\Status\NoticeStatus::class, array('dummy'));
34 $statusUtility = new StatusUtility();
35 $return = $statusUtility->sortBySeverity(array($noticeMock, $infoMock, $okMock, $warningMock, $errorMock));
36 $this->assertSame(array($errorMock), $return['error']);
37 $this->assertSame(array($warningMock), $return['warning']);
38 $this->assertSame(array($okMock), $return['ok']);
39 $this->assertSame(array($infoMock), $return['information']);
40 $this->assertSame(array($noticeMock), $return['notice']);
41 }
42
43 /**
44 * @test
45 * @expectedException \TYPO3\CMS\Install\Status\Exception
46 */
47 public function filterBySeverityThrowsExceptionIfObjectNotImplementingStatusInterfaceIsGiven()
48 {
49 $statusUtility = new StatusUtility();
50 $statusUtility->filterBySeverity(array(new \stdClass()));
51 }
52
53 /**
54 * @test
55 */
56 public function filterBySeverityReturnsSpecificSeverityOnly()
57 {
58 $errorMock = $this->getMock(\TYPO3\CMS\Install\Status\ErrorStatus::class, array('dummy'));
59 $warningMock = $this->getMock(\TYPO3\CMS\Install\Status\WarningStatus::class, array('dummy'));
60 $statusUtility = new StatusUtility();
61 $return = $statusUtility->filterBySeverity(array($errorMock, $warningMock), 'error');
62 $this->assertSame(array($errorMock), $return);
63 }
64 }