‪TYPO3CMS  9.5
ArrayFormFactoryTest.php
Go to the documentation of this file.
1 <?php
2 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 
18 use Prophecy\Argument;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪ArrayFormFactoryTest extends UnitTestCase
29 {
30 
35  {
36  $this->expectException(IdentifierNotValidException::class);
37  $this->expectExceptionCode(1329289436);
38 
39  $section = new ‪Section('test', 'page');
40  $arrayFormFactory = $this->getAccessibleMock(ArrayFormFactory::class, ['dummy']);
41 
42  $arrayFormFactory->_call('addNestedRenderable', [], $section);
43  }
44 
49  {
50  $unknownElement = new ‪UnknownFormElement('test-2', 'test');
51 
52  $section = $this->prophesize(Section::class);
53  $section->willBeConstructedWith(['test-1', 'Section']);
54  $section->createElement(Argument::cetera())->willReturn($unknownElement);
55 
56  $arrayFormFactory = $this->getAccessibleMock(ArrayFormFactory::class, ['dummy']);
57 
58  $configuration = [
59  'identifier' => 'test-3',
60  'type' => 'Foo',
61  'renderables' => [
62  0 => [
63  'identifier' => 'test-4',
64  ],
65  ],
66  ];
67 
68  $typeErrorExists = false;
69  try {
70  $arrayFormFactory->_call('addNestedRenderable', $configuration, $section->reveal());
71  } catch (\TypeError $error) {
72  $typeErrorExists = true;
73  }
74  $this->assertFalse($typeErrorExists);
75  }
76 }
‪TYPO3\CMS\Form\Domain\Factory\ArrayFormFactory
Definition: ArrayFormFactory.php:36
‪TYPO3\CMS\Form\Domain\Exception\IdentifierNotValidException
Definition: IdentifierNotValidException.php:27
‪TYPO3\CMS\Form\Domain\Model\FormElements\Section
Definition: Section.php:35
‪TYPO3\CMS\Form\Tests\Unit\Domain\Factory
Definition: ArrayFormFactoryTest.php:3
‪TYPO3\CMS\Form\Tests\Unit\Domain\Factory\ArrayFormFactoryTest
Definition: ArrayFormFactoryTest.php:29
‪TYPO3\CMS\Form\Domain\Model\FormElements\UnknownFormElement
Definition: UnknownFormElement.php:30
‪TYPO3\CMS\Form\Tests\Unit\Domain\Factory\ArrayFormFactoryTest\addNestedRenderableSkipChildElementRenderingIfCompositElementIsUnknown
‪addNestedRenderableSkipChildElementRenderingIfCompositElementIsUnknown()
Definition: ArrayFormFactoryTest.php:48
‪TYPO3\CMS\Form\Tests\Unit\Domain\Factory\ArrayFormFactoryTest\addNestedRenderableThrowsExceptionIfIdentifierIsMissing
‪addNestedRenderableThrowsExceptionIfIdentifierIsMissing()
Definition: ArrayFormFactoryTest.php:34