83bcf02669a6dc0884981cb53167d411e9adbcf5
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Tests / Unit / Domain / Configuration / ConfigurationServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Form\Tests\Unit\Domain\Configuration;
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
17 use TYPO3\CMS\Form\Domain\Configuration\ConfigurationService;
18 use TYPO3\CMS\Form\Domain\Configuration\Exception\PrototypeNotFoundException;
19
20 /**
21 * Test case
22 */
23 class ConfigurationServiceTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
24 {
25
26 /**
27 * @test
28 */
29 public function getPrototypeConfigurationReturnsPrototypeConfiguration()
30 {
31 $mockConfigurationService = $this->getAccessibleMock(ConfigurationService::class, [
32 'dummy'
33 ], [], '', false);
34
35 $mockConfigurationService->_set('formSettings', [
36 'prototypes' => [
37 'standard' => [
38 'key' => 'value',
39 ],
40 ],
41 ]);
42
43 $expected = [
44 'key' => 'value',
45 ];
46
47 $this->assertSame($expected, $mockConfigurationService->getPrototypeConfiguration('standard'));
48 }
49
50 /**
51 * @test
52 */
53 public function getPrototypeConfigurationThrowsExceptionIfNoPrototypeFound()
54 {
55 $mockConfigurationService = $this->getAccessibleMock(ConfigurationService::class, [
56 'dummy'
57 ], [], '', false);
58
59 $this->expectException(PrototypeNotFoundException::class);
60 $this->expectExceptionCode(1475924277);
61
62 $mockConfigurationService->_set('formSettings', [
63 'prototypes' => [
64 'noStandard' => [],
65 ],
66 ]);
67
68 $mockConfigurationService->getPrototypeConfiguration('standard');
69 }
70 }