f313411a3cf645aaa2377be258ee1e7a950bc6f0
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / ViewHelpers / Format / PhpErrorCodeViewHelperTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\Unit\ViewHelpers\Format;
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\Fluid\Core\Rendering\RenderingContext;
18 use TYPO3\CMS\Fluid\Tests\Unit\Core\Rendering\RenderingContextFixture;
19
20 /**
21 * Test case
22 */
23 class PhpErrorCodeViewHelperTest extends \TYPO3\CMS\Core\Tests\UnitTestCase
24 {
25 /**
26 * @var \TYPO3\CMS\Fluid\ViewHelpers\Format\NumberViewHelper
27 */
28 protected $viewHelper;
29
30 /**
31 * Setup the test case scenario
32 */
33 protected function setUp()
34 {
35 $this->viewHelper = $this->getMockBuilder(\TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper::class)
36 ->setMethods(array('dummy'))
37 ->getMock();
38 /** @var RenderingContext $renderingContext */
39 $renderingContext = new RenderingContextFixture();
40 $this->viewHelper->setRenderingContext($renderingContext);
41 }
42
43 /**
44 * @return array
45 */
46 public function errorCodesDataProvider()
47 {
48 return array(
49 array(
50 'errorCode' => E_ERROR,
51 'expectedString' => 'E_ERROR',
52 ),
53 array(
54 'errorCode' => E_ALL,
55 'expectedString' => 'E_ALL',
56 ),
57 array(
58 'errorCode' => E_ERROR ^ E_WARNING ^ E_PARSE,
59 'expectedString' => 'E_ERROR | E_WARNING | E_PARSE',
60 ),
61 array(
62 'errorCode' => E_RECOVERABLE_ERROR ^ E_USER_DEPRECATED,
63 'expectedString' => 'E_RECOVERABLE_ERROR | E_USER_DEPRECATED',
64 )
65 );
66 }
67
68 /**
69 * @param $errorCode
70 * @param $expectedString
71 * @test
72 * @dataProvider errorCodesDataProvider
73 */
74 public function renderPhpCodesCorrectly($errorCode, $expectedString)
75 {
76 $actualString = $this->viewHelper->render($errorCode);
77 $this->assertEquals($expectedString, $actualString);
78 }
79 }