[BUGFIX] Flexform suggest wizard no record found
[Packages/TYPO3.CMS.git] / typo3 / sysext / backend / Tests / Unit / Form / Wizard / SuggestWizardTest.php
1 <?php
2 namespace TYPO3\CMS\Backend\Tests\Unit\Form\Wizard;
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\Backend\Form\Wizard\SuggestWizard;
18 use TYPO3\CMS\Core\Tests\AccessibleObjectInterface;
19 use TYPO3\CMS\Core\Tests\UnitTestCase;
20
21 /**
22 * Test case
23 */
24 class SuggestWizardTest extends UnitTestCase
25 {
26 /**
27 * @test
28 */
29 public function getFieldConfigurationFetchesConfigurationDependentOnTheFullPathToField()
30 {
31 $config = [
32 'el' => [
33 'content' => [
34 'TCEforms' => [
35 'config' => [
36 'Sublevel field configuration',
37 ],
38 ],
39 ],
40 ],
41 ];
42
43 $dataStructure['sheets']['sSuggestCheckCombination']['ROOT']['el'] = [
44 'settings.topname1' => [
45 'el' => [
46 'item' => [
47 'el' => [
48 'content' => [
49 'TCEforms' => [
50 'config' => [
51 'different foo config for field with same name',
52 ],
53 ],
54 ],
55 ],
56 ],
57 ],
58 ],
59 'settings.topname3' => [
60 'el' => ['item' => $config]
61 ],
62 'settings.topname2' => [
63 'el' => [
64 'item' => [
65 'el' => [
66 'content' => [
67 'TCEforms' => [
68 'config' => [
69 'different foo config for field with same name',
70 ],
71 ],
72 ],
73 ],
74 ],
75 ],
76 ],
77 ];
78 $parts = [
79 0 => 'flex_1',
80 1 => 'data',
81 2 => 'sSuggestCheckCombination',
82 3 => 'lDEF',
83 4 => 'settings.topname3',
84 5 => 'el',
85 6 => 'ID-efa3ff7ed5-idx1460636854058-form',
86 7 => 'item',
87 8 => 'el',
88 9 => 'content',
89 10 => 'vDEF',
90 ];
91
92 /** @var SuggestWizard|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject $subject */
93 $subject = $this->getAccessibleMock(SuggestWizard::class, array('getNestedDsFieldConfig'), array(), '', false);
94 $subject
95 ->expects($this->once())
96 ->method('getNestedDsFieldConfig')
97 ->with($config, 'content');
98 $subject->_call('getFieldConfiguration', $parts, $dataStructure);
99 }
100
101 /**
102 * @test
103 */
104 public function getFieldConfigurationFetchesConfigurationForFieldsWithoutSheets()
105 {
106 $config = [
107 'ROOT' => [
108 'type' => 'array',
109 'el' => [
110 'content' => [
111 'TCEforms' => [
112 'label' => 'group_db_1 wizard suggest',
113 'config' => [
114 'type' => 'group',
115 'internal_type' => 'db',
116 'allowed' => 'tx_styleguide_staticdata',
117 'wizards' => [
118 'suggest' => [
119 'type' => 'suggest',
120 ],
121 ],
122 ],
123 ],
124 ],
125 ],
126 ]
127 ];
128 $dataStructure = [
129 'sheets' => [
130 'sDEF' => $config
131 ],
132 ];
133 $parts = [
134 0 => 'flex_1',
135 1 => 'data',
136 2 => 'sDEF',
137 3 => 'lDEF',
138 4 => 'content',
139 5 => 'vDEF',
140 ];
141
142 /** @var SuggestWizard|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject $subject */
143 $subject = $this->getAccessibleMock(SuggestWizard::class, array('getNestedDsFieldConfig'), array(), '', false);
144 $subject
145 ->expects($this->once())
146 ->method('getNestedDsFieldConfig')
147 ->with($config, 'content');
148
149 $subject->_call('getFieldConfiguration', $parts, $dataStructure);
150 }
151 }