TYPO3 CMS  TYPO3_8-7
StatusUtilityTest.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  */
16 
19 
23 class StatusUtilityTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
24 {
29  {
30  $errorMock = $this->getMockBuilder(\TYPO3\CMS\Install\Status\ErrorStatus::class)
31  ->setMethods(['dummy'])
32  ->getMock();
33  $warningMock = $this->getMockBuilder(\TYPO3\CMS\Install\Status\WarningStatus::class)
34  ->setMethods(['dummy'])
35  ->getMock();
36  $okMock = $this->getMockBuilder(\TYPO3\CMS\Install\Status\OkStatus::class)
37  ->setMethods(['dummy'])
38  ->getMock();
39  $infoMock = $this->getMockBuilder(\TYPO3\CMS\Install\Status\InfoStatus::class)
40  ->setMethods(['dummy'])
41  ->getMock();
42  $noticeMock = $this->getMockBuilder(\TYPO3\CMS\Install\Status\NoticeStatus::class)
43  ->setMethods(['dummy'])
44  ->getMock();
45  $statusUtility = new StatusUtility();
46  $return = $statusUtility->sortBySeverity([$noticeMock, $infoMock, $okMock, $warningMock, $errorMock]);
47  $this->assertSame([$errorMock], $return['error']);
48  $this->assertSame([$warningMock], $return['warning']);
49  $this->assertSame([$okMock], $return['ok']);
50  $this->assertSame([$infoMock], $return['information']);
51  $this->assertSame([$noticeMock], $return['notice']);
52  }
53 
58  {
59  $this->expectException(Exception::class);
60  $this->expectExceptionCode(1366919442);
61  $statusUtility = new StatusUtility();
62  $statusUtility->filterBySeverity([new \stdClass()]);
63  }
64 
69  {
70  $errorMock = $this->getMockBuilder(\TYPO3\CMS\Install\Status\ErrorStatus::class)
71  ->setMethods(['dummy'])
72  ->getMock();
73  $warningMock = $this->getMockBuilder(\TYPO3\CMS\Install\Status\WarningStatus::class)
74  ->setMethods(['dummy'])
75  ->getMock();
76  $statusUtility = new StatusUtility();
77  $return = $statusUtility->filterBySeverity([$errorMock, $warningMock], 'error');
78  $this->assertSame([$errorMock], $return);
79  }
80 }