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