[TASK] Re-work/simplify copyright header in PHP files - Part 2
[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 $errorMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\ErrorStatus', array('dummy'));
29 $warningMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\WarningStatus', array('dummy'));
30 $okMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\OkStatus', array('dummy'));
31 $infoMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\InfoStatus', array('dummy'));
32 $noticeMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\NoticeStatus', array('dummy'));
33 $statusUtility = new StatusUtility();
34 $return = $statusUtility->sortBySeverity(array($noticeMock, $infoMock, $okMock, $warningMock, $errorMock));
35 $this->assertSame(array($errorMock), $return['error']);
36 $this->assertSame(array($warningMock), $return['warning']);
37 $this->assertSame(array($okMock), $return['ok']);
38 $this->assertSame(array($infoMock), $return['information']);
39 $this->assertSame(array($noticeMock), $return['notice']);
40 }
41
42 /**
43 * @test
44 * @expectedException \TYPO3\CMS\Install\Status\Exception
45 */
46 public function filterBySeverityThrowsExceptionIfObjectNotImplementingStatusInterfaceIsGiven() {
47 $statusUtility = new StatusUtility();
48 $statusUtility->filterBySeverity(array(new \stdClass()));
49 }
50
51 /**
52 * @test
53 */
54 public function filterBySeverityReturnsSpecificSeverityOnly() {
55 $errorMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\ErrorStatus', array('dummy'));
56 $warningMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\WarningStatus', array('dummy'));
57 $statusUtility = new StatusUtility();
58 $return = $statusUtility->filterBySeverity(array($errorMock, $warningMock), 'error');
59 $this->assertSame(array($errorMock), $return);
60 }
61 }