[!!!][TASK] Rewrite install tool
[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 * Copyright notice
6 *
7 * (c) 2013 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 *
19 * This script is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * This copyright notice MUST APPEAR in all copies of the script!
25 ***************************************************************/
26
27 /**
28 * Test case
29 */
30 class StatusUtilityTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
31
32 /**
33 * @test
34 */
35 public function sortBySeveritySortsGivenStatusObjects() {
36 $errorMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\ErrorStatus', array('dummy'));
37 $warningMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\WarningStatus', array('dummy'));
38 $okMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\OkStatus', array('dummy'));
39 $infoMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\InfoStatus', array('dummy'));
40 $noticeMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\NoticeStatus', array('dummy'));
41 $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
42 $return = $statusUtility->sortBySeverity(array($noticeMock, $infoMock, $okMock, $warningMock, $errorMock));
43 $this->assertSame(array($errorMock), $return['error']);
44 $this->assertSame(array($warningMock), $return['warning']);
45 $this->assertSame(array($okMock), $return['ok']);
46 $this->assertSame(array($infoMock), $return['information']);
47 $this->assertSame(array($noticeMock), $return['notice']);
48 }
49
50 /**
51 * @test
52 * @expectedException \TYPO3\CMS\Install\Status\Exception
53 */
54 public function filterBySeverityThrowsExceptionIfObjectNotImplementingStatusInterfaceIsGiven() {
55 $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
56 $statusUtility->filterBySeverity(array(new \stdClass()));
57 }
58
59 /**
60 * @test
61 */
62 public function filterBySeverityReturnsSpecificSeverityOnly() {
63 $errorMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\ErrorStatus', array('dummy'));
64 $warningMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\WarningStatus', array('dummy'));
65 $statusUtility = new \TYPO3\CMS\Install\Status\StatusUtility();
66 $return = $statusUtility->filterBySeverity(array($errorMock, $warningMock), 'error');
67 $this->assertSame(array($errorMock), $return);
68 }
69 }
70 ?>