‪TYPO3CMS  9.5
YamlSourceTest.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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪YamlSourceTest extends UnitTestCase
27 {
28  protected ‪$resetSingletonInstances = true;
29 
34  {
35  $this->expectException(NoSuchFileException::class);
36  $this->expectExceptionCode(1471473378);
37 
38  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
39  'dummy',
40  ], [], '', false);
41 
42  $input = [
43  'EXT:form/Resources/Forms/_example.yaml'
44  ];
45 
46  $mockYamlSource->_call('load', $input);
47  }
48 
53  {
54  $this->expectException(ParseErrorException::class);
55  $this->expectExceptionCode(1480195405);
56 
57  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
58  'dummy',
59  ], [], '', false);
60 
61  $input = [
62  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/Invalid.yaml'
63  ];
64 
65  $mockYamlSource->_call('load', $input);
66  }
67 
72  {
73  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
74  'dummy',
75  ], [], '', false);
76 
77  $input = GeneralUtility::getFileAbsFileName('EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/Header.yaml');
78  $expected =
79 '# Header 1
80 # Header 2
81 ';
82 
83  $this->assertSame($expected, $mockYamlSource->_call('getHeaderFromFile', $input));
84  }
85 
90  {
91  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, ['dummy'], [], '', false);
92 
93  $input = [
94  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/OverruleNonArrayValuesOverArrayValues1.yaml',
95  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/OverruleNonArrayValuesOverArrayValues2.yaml'
96  ];
97 
98  $expected = [
99  'Form' => [
100  'klaus01' => null,
101  'key03' => 'value2',
102  ],
103  ];
104 
105  $this->assertSame($expected, $mockYamlSource->_call('load', $input));
106  }
107 }
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration
Definition: InheritancesResolverServiceTest.php:3
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\loadOverruleNonArrayValuesOverArrayValues
‪loadOverruleNonArrayValuesOverArrayValues()
Definition: YamlSourceTest.php:89
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\loadThrowsExceptionIfFileToLoadIsNotValidYamlUseSymfonyParser
‪loadThrowsExceptionIfFileToLoadIsNotValidYamlUseSymfonyParser()
Definition: YamlSourceTest.php:52
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\$resetSingletonInstances
‪$resetSingletonInstances
Definition: YamlSourceTest.php:28
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest
Definition: YamlSourceTest.php:27
‪TYPO3\CMS\Form\Mvc\Configuration\YamlSource
Definition: YamlSource.php:39
‪TYPO3\CMS\Form\Mvc\Configuration\Exception\ParseErrorException
Definition: ParseErrorException.php:24
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\getHeaderFromFileReturnsHeaderPart
‪getHeaderFromFileReturnsHeaderPart()
Definition: YamlSourceTest.php:71
‪TYPO3\CMS\Form\Tests\Unit\Mvc\Configuration\YamlSourceTest\loadThrowsExceptionIfFileToLoadNotExists
‪loadThrowsExceptionIfFileToLoadNotExists()
Definition: YamlSourceTest.php:33
‪TYPO3\CMS\Form\Mvc\Configuration\Exception\NoSuchFileException
Definition: NoSuchFileException.php:24