TYPO3 CMS  TYPO3_8-7
PhpErrorCodeViewHelperTest.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 
18 
22 class PhpErrorCodeViewHelperTest extends ViewHelperBaseTestcase
23 {
27  protected $viewHelper;
28 
32  protected function setUp()
33  {
34  parent::setUp();
35  $this->viewHelper = $this->getAccessibleMock(\TYPO3\CMS\Install\ViewHelpers\Format\PhpErrorCodeViewHelper::class, ['dummy']);
36  $this->injectDependenciesIntoViewHelper($this->viewHelper);
37  $this->viewHelper->initializeArguments();
38  }
39 
43  public function errorCodesDataProvider()
44  {
45  return [
46  [
47  'errorCode' => E_ERROR,
48  'expectedString' => 'E_ERROR',
49  ],
50  [
51  'errorCode' => E_ALL,
52  'expectedString' => 'E_ALL',
53  ],
54  [
55  'errorCode' => E_ERROR ^ E_WARNING ^ E_PARSE,
56  'expectedString' => 'E_ERROR | E_WARNING | E_PARSE',
57  ],
58  [
59  'errorCode' => E_RECOVERABLE_ERROR ^ E_USER_DEPRECATED,
60  'expectedString' => 'E_RECOVERABLE_ERROR | E_USER_DEPRECATED',
61  ]
62  ];
63  }
64 
71  public function renderPhpCodesCorrectly($errorCode, $expectedString)
72  {
73  $this->viewHelper->setArguments([
74  'phpErrorCode' => $errorCode
75  ]);
76  $actualString = $this->viewHelper->render();
77  $this->assertEquals($expectedString, $actualString);
78  }
79 }