TYPO3 CMS  TYPO3_7-6
ClassNamingUtilityTest.php
Go to the documentation of this file.
1 <?php
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 
21 {
29  public function repositoryAndModelClassNames()
30  {
31  return [
32  [
33  'Tx_BlogExample_Domain_Repository_BlogRepository',
34  'Tx_BlogExample_Domain_Model_Blog',
35  'Tx_BlogExample_Domain_Validator_BlogValidator'
36  ],
37  [
38  ' _Domain_Repository_Content_PageRepository',
39  ' _Domain_Model_Content_Page',
40  ' _Domain_Validator_Content_PageValidator'
41  ],
42  [
43  'Tx_RepositoryExample_Domain_Repository_SomeModelRepository',
44  'Tx_RepositoryExample_Domain_Model_SomeModel',
45  'Tx_RepositoryExample_Domain_Validator_SomeModelValidator'
46  ],
47  [
48  'Tx_RepositoryExample_Domain_Repository_RepositoryRepository',
49  'Tx_RepositoryExample_Domain_Model_Repository',
50  'Tx_RepositoryExample_Domain_Validator_RepositoryValidator'
51  ],
52  [
53  'Tx_Repository_Domain_Repository_RepositoryRepository',
54  'Tx_Repository_Domain_Model_Repository',
55  'Tx_Repository_Domain_Validator_RepositoryValidator'
56  ],
57  [
58  'Tx_ModelCollection_Domain_Repository_ModelRepository',
59  'Tx_ModelCollection_Domain_Model_Model',
60  'Tx_ModelCollection_Domain_Validator_ModelValidator'
61  ],
62  [
63  'Tx_Model_Domain_Repository_ModelRepository',
64  'Tx_Model_Domain_Model_Model',
65  'Tx_Model_Domain_Validator_ModelValidator'
66  ],
67  [
68  'VENDOR\\EXT\\Domain\\Repository\\BlogRepository',
69  'VENDOR\\EXT\\Domain\\Model\\Blog',
70  'VENDOR\\EXT\\Domain\\Validator\\BlogValidator'
71  ],
72  [
73  'VENDOR\\EXT\\Domain\\Repository\\_PageRepository',
74  'VENDOR\\EXT\\Domain\\Model\\_Page',
75  'VENDOR\\EXT\\Domain\\Validator\\_PageValidator'
76  ],
77  [
78  'VENDOR\\Repository\\Domain\\Repository\\SomeModelRepository',
79  'VENDOR\\Repository\\Domain\\Model\\SomeModel',
80  'VENDOR\\Repository\\Domain\\Validator\\SomeModelValidator'
81  ],
82  [
83  'VENDOR\\EXT\\Domain\\Repository\\RepositoryRepository',
84  'VENDOR\\EXT\\Domain\\Model\\Repository',
85  'VENDOR\\EXT\\Domain\\Validator\\RepositoryValidator'
86  ],
87  [
88  'VENDOR\\Repository\\Domain\\Repository\\RepositoryRepository',
89  'VENDOR\\Repository\\Domain\\Model\\Repository',
90  'VENDOR\\Repository\\Domain\\Validator\\RepositoryValidator'
91  ],
92  [
93  'VENDOR\\ModelCollection\\Domain\\Repository\\ModelRepository',
94  'VENDOR\\ModelCollection\\Domain\\Model\\Model',
95  'VENDOR\\ModelCollection\\Domain\\Validator\\ModelValidator'
96  ],
97  [
98  'VENDOR\\Model\\Domain\\Repository\\ModelRepository',
99  'VENDOR\\Model\\Domain\\Model\\Model',
100  'VENDOR\\Model\\Domain\\Validator\\ModelValidator'
101  ],
102  ];
103  }
104 
112  public function translateModelNameToRepositoryName($expectedRepositoryName, $modelName, $dummyValidatorName)
113  {
115  $this->assertSame($expectedRepositoryName, $translatedRepositoryName);
116  }
117 
125  public function translateRepositoryNameToModelName($repositoryName, $expectedModelName, $dummyValidatorName)
126  {
128  $this->assertSame($expectedModelName, $translatedModelName);
129  }
130 
138  public function translateModelNameToValidatorName($repositoryName, $modelName, $expectedValidatorName)
139  {
141  $this->assertSame($expectedValidatorName, $translatedModelName);
142  }
143 
150  {
151  return [
152  [
153  'TYPO3\\CMS\\Ext\\Controller\\FooController',
154  [
155  'vendorName' => 'TYPO3\\CMS',
156  'extensionName' => 'Ext',
157  'subpackageKey' => '',
158  'controllerName' => 'Foo',
159  ]
160  ],
161  [
162  'TYPO3\\CMS\\Ext\\Command\\FooCommandController',
163  [
164  'vendorName' => 'TYPO3\\CMS',
165  'extensionName' => 'Ext',
166  'subpackageKey' => '',
167  'controllerName' => 'FooCommand',
168  ]
169  ],
170  [
171  \TYPO3\CMS\Fluid\ViewHelpers\Widget\Controller\PaginateController::class,
172  [
173  'vendorName' => 'TYPO3\\CMS',
174  'extensionName' => 'Fluid',
175  'subpackageKey' => 'ViewHelpers\\Widget',
176  'controllerName' => 'Paginate',
177  ]
178  ],
179  [
180  'VENDOR\\Ext\\Controller\\FooController',
181  [
182  'vendorName' => 'VENDOR',
183  'extensionName' => 'Ext',
184  'subpackageKey' => '',
185  'controllerName' => 'Foo',
186  ]
187  ],
188  [
189  'VENDOR\\Ext\\Command\\FooCommandController',
190  [
191  'vendorName' => 'VENDOR',
192  'extensionName' => 'Ext',
193  'subpackageKey' => '',
194  'controllerName' => 'FooCommand',
195  ]
196  ],
197  [
198  'VENDOR\\Ext\\ViewHelpers\\Widget\\Controller\\FooController',
199  [
200  'vendorName' => 'VENDOR',
201  'extensionName' => 'Ext',
202  'subpackageKey' => 'ViewHelpers\\Widget',
203  'controllerName' => 'Foo',
204  ]
205  ],
206  // Oldschool
207  [
208  'Tx_Ext_Controller_FooController',
209  [
210  'vendorName' => null,
211  'extensionName' => 'Ext',
212  'subpackageKey' => '',
213  'controllerName' => 'Foo',
214  ]
215  ],
216  [
217  'Tx_Ext_Command_FooCommandController',
218  [
219  'vendorName' => null,
220  'extensionName' => 'Ext',
221  'subpackageKey' => '',
222  'controllerName' => 'FooCommand',
223  ]
224  ],
225  [
226  'Tx_Fluid_ViewHelpers_Widget_Controller_PaginateController',
227  [
228  'vendorName' => null,
229  'extensionName' => 'Fluid',
230  'subpackageKey' => 'ViewHelpers_Widget',
231  'controllerName' => 'Paginate',
232  ]
233  ],
234  ];
235  }
236 
244  public function explodeObjectControllerName($controllerObjectName, $expectedMatches)
245  {
247 
248  $actualMatches = [
249  'vendorName' => $matches['vendorName'],
250  'extensionName' => $matches['extensionName'],
251  'subpackageKey' => $matches['subpackageKey'],
252  'controllerName' => $matches['controllerName'],
253  ];
254 
255  $this->assertSame($expectedMatches, $actualMatches);
256  }
257 }
translateRepositoryNameToModelName($repositoryName, $expectedModelName, $dummyValidatorName)
static explodeObjectControllerName($controllerObjectName)
static translateRepositoryNameToModelName($repositoryName)
explodeObjectControllerName($controllerObjectName, $expectedMatches)
translateModelNameToRepositoryName($expectedRepositoryName, $modelName, $dummyValidatorName)
translateModelNameToValidatorName($repositoryName, $modelName, $expectedValidatorName)