TYPO3 CMS  TYPO3_8-7
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 
23 
27 class ArrayFormFactoryTest extends \TYPO3\TestingFramework\Core\Unit\UnitTestCase
28 {
29 
34  {
35  $this->expectException(IdentifierNotValidException::class);
36  $this->expectExceptionCode(1329289436);
37 
38  $section = new Section('test', 'page');
39  $arrayFormFactory = $this->getAccessibleMock(ArrayFormFactory::class, ['dummy']);
40 
41  $arrayFormFactory->_call('addNestedRenderable', [], $section);
42  }
43 
48  {
49  $unknownElement = new UnknownFormElement('test-2', 'test');
50 
51  $section = $this->prophesize(Section::class);
52  $section->willBeConstructedWith(['test-1', 'Section']);
53  $section->createElement(Argument::cetera())->willReturn($unknownElement);
54 
55  $arrayFormFactory = $this->getAccessibleMock(ArrayFormFactory::class, ['dummy']);
56 
57  $configuration = [
58  'identifier' => 'test-3',
59  'type' => 'Foo',
60  'renderables' => [
61  0 => [
62  'identifier' => 'test-4',
63  ],
64  ],
65  ];
66 
67  $typeErrorExists = false;
68  try {
69  $arrayFormFactory->_call('addNestedRenderable', $configuration, $section->reveal());
70  } catch (\TypeError $error) {
71  $typeErrorExists = true;
72  }
73  $this->assertFalse($typeErrorExists);
74  }
75 }