TYPO3 CMS  TYPO3_8-7
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 
25 class YamlSourceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
26 {
27 
32  {
33  $this->expectException(NoSuchFileException::class);
34  $this->expectExceptionCode(1471473378);
35 
36  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
37  'dummy',
38  ], [], '', false);
39 
40  $input = [
41  'EXT:form/Resources/Forms/_example.yaml'
42  ];
43 
44  $mockYamlSource->_call('load', $input);
45  }
46 
51  {
52  $this->expectException(ParseErrorException::class);
53  $this->expectExceptionCode(1480195405);
54 
55  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
56  'dummy',
57  ], [], '', false);
58 
59  $input = [
60  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/Invalid.yaml'
61  ];
62 
63  $mockYamlSource->_call('load', $input);
64  }
65 
70  {
71  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, [
72  'dummy',
73  ], [], '', false);
74 
75  $input = GeneralUtility::getFileAbsFileName('EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/Header.yaml');
76  $expected =
77 '# Header 1
78 # Header 2
79 ';
80 
81  $this->assertSame($expected, $mockYamlSource->_call('getHeaderFromFile', $input));
82  }
83 
88  {
89  $mockYamlSource = $this->getAccessibleMock(YamlSource::class, ['dummy'], [], '', false);
90 
91  $input = [
92  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/OverruleNonArrayValuesOverArrayValues1.yaml',
93  'EXT:form/Tests/Unit/Mvc/Configuration/Fixtures/OverruleNonArrayValuesOverArrayValues2.yaml'
94  ];
95 
96  $expected = [
97  'Form' => [
98  'klaus01' => null,
99  'key03' => 'value2',
100  ],
101  ];
102 
103  $this->assertSame($expected, $mockYamlSource->_call('load', $input));
104  }
105 }
static getFileAbsFileName($filename, $_=null, $_2=null)