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