[TASK] Remove old language labels in EXT:setup
[Packages/TYPO3.CMS.git] / typo3 / sysext / form / Tests / Unit / Utility / TypoScriptToJsonConverterTest.php
1 <?php
2 namespace TYPO3\CMS\Form\Tests\Unit\Utility;
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\Core\Tests\AccessibleObjectInterface;
18 use TYPO3\CMS\Core\Tests\UnitTestCase;
19 use TYPO3\CMS\Form\Domain\Model\Json\FormJsonElement;
20 use TYPO3\CMS\Form\Utility\TypoScriptToJsonConverter;
21
22 /**
23 * Test case for \TYPO3\CMS\Form\Utility\TypoScriptToJsonConverter
24 */
25 class TypoScriptToJsonConverterTest extends UnitTestCase
26 {
27 /**
28 * Checks if calling protected method getChildElementsByIntegerKey with different data
29 * calls the addMethod in the mocked FormJsonElement for an expected method count.
30 *
31 * @dataProvider getChildElementsByIntegerKeyCallsAddElementDataProvider
32 * @param array $typoScript
33 * @param int $methodCount
34 * @test
35 */
36 public function getChildElementsByIntegerKeyCallsAddElement(array $typoScript, $methodCount)
37 {
38 /** @var FormJsonElement|\PHPUnit_Framework_MockObject_MockObject $mockSubject */
39 $parentElement = $this->getMockBuilder(FormJsonElement::class)
40 ->setMethods(['addElement'])
41 ->getMock();
42 // check if method gets called exactly X times
43 $parentElement->expects($this->exactly($methodCount))->method('addElement');
44
45 /** @var TypoScriptToJsonConverter|\PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface $subjectAccessible */
46 $accessibleSubject = $this->getAccessibleMock(TypoScriptToJsonConverter::class, ['dummy']);
47 $accessibleSubject->_call('getChildElementsByIntegerKey', $parentElement, $typoScript);
48 }
49
50 /**
51 * Data provider for test method getChildElementsByIntegerKeyCallsAddElement.
52 *
53 * @return array
54 */
55 public function getChildElementsByIntegerKeyCallsAddElementDataProvider()
56 {
57 return [
58 [
59 'typoscript' => [
60 'prefix' => 'tx_form',
61 'confirmation' => '1',
62 'postProcessor.' => [
63 '1' => 'mail',
64 '1.' => [
65 'recipientEmail' => '',
66 'senderEmail' => '',
67 ],
68 ],
69 '10' => 'FILEUPLOAD',
70 '10.' => [
71 'name' => 'foo',
72 'type' => 'file',
73 'label.' => [
74 'value' => 'Edit this label',
75 ],
76 ],
77 ],
78 1
79 ],
80 ];
81 }
82 }