‪TYPO3CMS  10.4
PhpErrorCodeViewHelperTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
19 use TYPO3\TestingFramework\Fluid\Unit\ViewHelpers\ViewHelperBaseTestcase;
20 
24 class ‪PhpErrorCodeViewHelperTest extends ViewHelperBaseTestcase
25 {
29  protected ‪$viewHelper;
30 
34  protected function ‪setUp(): void
35  {
36  parent::setUp();
37  $this->viewHelper = new ‪PhpErrorCodeViewHelper();
38  $this->injectDependenciesIntoViewHelper($this->viewHelper);
39  $this->viewHelper->initializeArguments();
40  }
41 
45  public function ‪errorCodesDataProvider(): array
46  {
47  return [
48  [
49  'errorCode' => E_ERROR,
50  'expectedString' => 'E_ERROR',
51  ],
52  [
53  'errorCode' => E_ALL,
54  'expectedString' => 'E_ALL',
55  ],
56  [
57  'errorCode' => E_ERROR ^ E_WARNING ^ E_PARSE,
58  'expectedString' => 'E_ERROR | E_WARNING | E_PARSE',
59  ],
60  [
61  'errorCode' => E_RECOVERABLE_ERROR ^ E_USER_DEPRECATED,
62  'expectedString' => 'E_RECOVERABLE_ERROR | E_USER_DEPRECATED',
63  ]
64  ];
65  }
66 
73  public function ‪renderPhpCodesCorrectly($errorCode, $expectedString): void
74  {
75  $this->viewHelper->setArguments([
76  'phpErrorCode' => $errorCode
77  ]);
78  $actualString = $this->viewHelper->render();
79  self::assertEquals($expectedString, $actualString);
80  }
81 }
‪TYPO3\CMS\Install\Tests\Unit\ViewHelpers\Format\PhpErrorCodeViewHelperTest
Definition: PhpErrorCodeViewHelperTest.php:25
‪TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper
Definition: PhpErrorCodeViewHelper.php:28
‪TYPO3\CMS\Install\Tests\Unit\ViewHelpers\Format\PhpErrorCodeViewHelperTest\renderPhpCodesCorrectly
‪renderPhpCodesCorrectly($errorCode, $expectedString)
Definition: PhpErrorCodeViewHelperTest.php:72
‪TYPO3\CMS\Install\Tests\Unit\ViewHelpers\Format\PhpErrorCodeViewHelperTest\setUp
‪setUp()
Definition: PhpErrorCodeViewHelperTest.php:33
‪TYPO3\CMS\Install\Tests\Unit\ViewHelpers\Format\PhpErrorCodeViewHelperTest\errorCodesDataProvider
‪array errorCodesDataProvider()
Definition: PhpErrorCodeViewHelperTest.php:44
‪TYPO3\CMS\Install\Tests\Unit\ViewHelpers\Format
Definition: PhpErrorCodeViewHelperTest.php:16
‪TYPO3\CMS\Install\Tests\Unit\ViewHelpers\Format\PhpErrorCodeViewHelperTest\$viewHelper
‪TYPO3 CMS Fluid ViewHelpers Format NumberViewHelper $viewHelper
Definition: PhpErrorCodeViewHelperTest.php:28