2 declare(strict_types = 1);
19 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
32 $fileName =
'Berta.yml';
45 'betterthanbefore' => 1
49 $subject = $this->getAccessibleMock(YamlFileLoader::class, [
'getFileContents']);
50 $subject->expects($this->once())->method(
'getFileContents')->with($fileName)->willReturn($fileContents);
51 $output = $subject->load($fileName);
52 $this->assertSame($expected,
$output);
61 $fileName =
'Berta.yml';
64 - { resource: Secondfile.yml }
72 $importFileName =
'Secondfile.yml';
73 $importFileContents =
'
85 'betterthanbefore' => 1
89 $subject = $this->getAccessibleMock(YamlFileLoader::class, [
'getFileContents']);
90 $subject->expects($this->at(0))->method(
'getFileContents')->with($fileName)->willReturn($fileContents);
91 $subject->expects($this->at(1))->method(
'getFileContents')->with($importFileName)->willReturn($importFileContents);
92 $output = $subject->load($fileName);
93 $this->assertSame($expected,
$output);
102 $fileName =
'Berta.yml';
110 betterthanbefore: \'%firstset.myinitialversion%\'
115 'myinitialversion' => 13
121 'betterthanbefore' => 13
125 $subject = $this->getAccessibleMock(YamlFileLoader::class, [
'getFileContents']);
126 $subject->expects($this->once())->method(
'getFileContents')->with($fileName)->willReturn($fileContents);
127 $output = $subject->load($fileName);
128 $this->assertSame($expected,
$output);
136 'carl: \'%env(foo)%\'',
141 "carl: '%env(''foo'')%'",
144 'double quoted var' => [
146 "carl: '%env(\"foo\")%'",
149 'var in the middle' => [
151 "carl: 'https://%env(foo)%/foo'",
152 [
'carl' =>
'https://heinz/foo']
154 'quoted var in the middle' => [
156 "carl: 'https://%env(''foo'')%/foo'",
157 [
'carl' =>
'https://heinz/foo']
159 'double quoted var in the middle' => [
161 "carl: 'https://%env(\"foo\")%/foo'",
162 [
'carl' =>
'https://heinz/foo']
165 [
'foo=karl',
'bar=heinz'],
166 'carl: \'%env(foo)%::%env(bar)%\'',
167 [
'carl' =>
'karl::heinz']
169 'three env vars' => [
170 [
'foo=karl',
'bar=heinz',
'baz=bencer'],
171 'carl: \'%env(foo)%::%env(bar)%::%env(baz)%\'',
172 [
'carl' =>
'karl::heinz::bencer']
174 'three env vars with baz being undefined' => [
175 [
'foo=karl',
'bar=heinz'],
176 'carl: \'%env(foo)%::%env(bar)%::%env(baz)%\'',
177 [
'carl' =>
'karl::heinz::%env(baz)%']
179 'three undefined env vars' => [
181 'carl: \'%env(foo)%::%env(bar)%::%env(baz)%\'',
182 [
'carl' =>
'%env(foo)%::%env(bar)%::%env(baz)%']
198 foreach ($envs as $env) {
201 $fileName =
'Berta.yml';
202 $fileContents = $yamlContent;
205 $subject = $this->getAccessibleMock(YamlFileLoader::class, [
'getFileContents']);
206 $subject->expects($this->once())->method(
'getFileContents')->with($fileName)->willReturn($fileContents);
207 $output = $subject->load($fileName);
208 $this->assertSame($expected,
$output);
221 $fileName =
'Berta.yml';
229 betterthanbefore: \'%env(mynonexistingenv)%\'
234 'myinitialversion' => 13
240 'betterthanbefore' =>
'%env(mynonexistingenv)%'
244 $subject = $this->getAccessibleMock(YamlFileLoader::class, [
'getFileContents']);
245 $subject->expects($this->once())->method(
'getFileContents')->with($fileName)->willReturn($fileContents);
246 $output = $subject->load($fileName);
247 $this->assertSame($expected,
$output);
257 'regular string' => [
273 'invalid placeholder with only % at the beginning' => [
277 'invalid placeholder with only % at the end' => [
281 'invalid placeholder with two % but not at the end' => [
285 'invalid placeholder with two % but not at the beginning nor end' => [
289 'valid placeholder with just numbers' => [
293 'valid placeholder' => [
309 $subject = $this->getAccessibleMock(YamlFileLoader::class, [
'dummy']);
310 $output = $subject->_call(
'isPlaceholder', $placeholderValue);
311 $this->assertSame($expected,
$output);