1 | <?php |
||
21 | class CategoryGroupTest extends Unit |
||
22 | { |
||
23 | /** |
||
24 | * @var CategoryGroups |
||
25 | */ |
||
26 | private $converter; |
||
27 | |||
28 | /** |
||
29 | * Set the converter. |
||
30 | * |
||
31 | * @SuppressWarnings(PHPMD.CamelCaseMethodName) |
||
32 | */ |
||
33 | protected function _before() |
||
37 | |||
38 | //============================================================================================================== |
||
39 | //================================================= TESTS ==================================================== |
||
40 | //============================================================================================================== |
||
41 | |||
42 | /** |
||
43 | * @dataProvider provideCategoryGroups |
||
44 | * |
||
45 | * @param CategoryGroupModel $group |
||
46 | * @param array $definition |
||
47 | */ |
||
48 | public function testGetRecordDefinition(CategoryGroupModel $group, array $definition) |
||
54 | |||
55 | /** |
||
56 | * @dataProvider provideCategoryGroups |
||
57 | * |
||
58 | * @param CategoryGroupModel $group |
||
59 | * @param array $definition |
||
60 | * @param Site|null $site |
||
61 | */ |
||
62 | public function testSetRecordAttributes(CategoryGroupModel $group, array $definition, $site) |
||
80 | |||
81 | /** |
||
82 | * @dataProvider provideCategoryGroups |
||
83 | * |
||
84 | * @param CategoryGroupModel $group |
||
85 | * @param array $definition |
||
86 | */ |
||
87 | public function testSaveRecord(CategoryGroupModel $group, array $definition) |
||
98 | |||
99 | /** |
||
100 | * @dataProvider provideCategoryGroups |
||
101 | * |
||
102 | * @param CategoryGroupModel $group |
||
103 | */ |
||
104 | public function testDeleteRecord(CategoryGroupModel $group) |
||
112 | |||
113 | //============================================================================================================== |
||
114 | //============================================== PROVIDERS =================================================== |
||
115 | //============================================================================================================== |
||
116 | |||
117 | /** |
||
118 | * @return array |
||
119 | */ |
||
120 | public function provideCategoryGroups() |
||
137 | |||
138 | //============================================================================================================== |
||
139 | //================================================ HELPERS =================================================== |
||
140 | //============================================================================================================== |
||
141 | |||
142 | /** |
||
143 | * @param CategoryGroupModel $mockCategoryGroup |
||
144 | * |
||
145 | * @return array |
||
146 | */ |
||
147 | private function getMockCategoryGroupDefinition(CategoryGroupModel $mockCategoryGroup) |
||
171 | |||
172 | /** |
||
173 | * @param int $groupId |
||
174 | * |
||
175 | * @return Mock|CategoryGroupModel |
||
176 | */ |
||
177 | private function getMockCategoryGroup(int $groupId) |
||
204 | |||
205 | /** |
||
206 | * Get mock siteSettings. |
||
207 | * |
||
208 | * @param string $class |
||
209 | * |
||
210 | * @return Mock|CategoryGroup_SiteSettings |
||
211 | */ |
||
212 | private function getMockSiteSettings() |
||
224 | |||
225 | /** |
||
226 | * Get a mock site. |
||
227 | * |
||
228 | * @return Mock|Site |
||
229 | */ |
||
230 | private function getMockSite() |
||
234 | } |
||
235 |
Let’s assume that you have a directory layout like this:
and let’s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: