‪TYPO3CMS  11.5
YamlSourceTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪YamlSourceTest extends UnitTestCase
29 {
30  protected ‪$resetSingletonInstances = true;
31 
36  {
37  $this->expectException(ParseErrorException::class);
38  $this->expectExceptionCode(1480195405);
39 
40  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
41  'dummy',
42  ], [], '', false);
43 
44  $input = [
45  'EXT:form/Resources/Forms/_example.yaml',
46  ];
47 
48  $mockYamlSource->_call('load', $input);
49  }
50 
55  {
56  $this->expectException(ParseErrorException::class);
57  $this->expectExceptionCode(1480195405);
58 
59  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
60  'dummy',
61  ], [], '', false);
62 
63  $input = [
64  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/Invalid.yaml',
65  ];
66 
67  $mockYamlSource->_call('load', $input);
68  }
69 
73  public function ‪getHeaderFromFileReturnsHeaderPart(): void
74  {
75  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
76  'dummy',
77  ], [], '', false);
78 
79  $input = GeneralUtility::getFileAbsFileName('EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/Header.yaml');
80  $expected =
81 '# Header 1
82 # Header 2
83 ';
84 
85  self::assertSame($expected, $mockYamlSource->_call('getHeaderFromFile', $input));
86  }
87 
92  {
93  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, ['dummy'], [], '', false);
94 
95  $input = [
96  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/OverruleNonArrayValuesOverArrayValues1.yaml',
97  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/OverruleNonArrayValuesOverArrayValues2.yaml',
98  ];
99 
100  $expected = [
101  'Form' => [
102  'klaus01' => null,
103  'key03' => 'value2',
104  ],
105  ];
106 
107  self::assertSame($expected, $mockYamlSource->_call('load', $input));
108  }
109 }
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration
Definition: ConfigurationManagerTest.php:18
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\loadOverruleNonArrayValuesOverArrayValues
‪loadOverruleNonArrayValuesOverArrayValues()
Definition: YamlSourceTest.php:91
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\loadThrowsExceptionIfFileToLoadIsNotValidYamlUseSymfonyParser
‪loadThrowsExceptionIfFileToLoadIsNotValidYamlUseSymfonyParser()
Definition: YamlSourceTest.php:54
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\$resetSingletonInstances
‪$resetSingletonInstances
Definition: YamlSourceTest.php:30
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest
Definition: YamlSourceTest.php:29
‪TYPO3\CMS\Form\Mvc\Configuration\YamlSource
Definition: YamlSource.php:44
‪TYPO3\CMS\Form\Mvc\Configuration\Exception\ParseErrorException
Definition: ParseErrorException.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\getHeaderFromFileReturnsHeaderPart
‪getHeaderFromFileReturnsHeaderPart()
Definition: YamlSourceTest.php:73
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\loadThrowsExceptionIfFileToLoadNotExists
‪loadThrowsExceptionIfFileToLoadNotExists()
Definition: YamlSourceTest.php:35