1 | <?php |
||
20 | class FieldTest extends Unit |
||
21 | { |
||
22 | /** |
||
23 | * @var Field |
||
24 | */ |
||
25 | private $converter; |
||
26 | |||
27 | /** |
||
28 | * Set the converter. |
||
29 | * |
||
30 | * @SuppressWarnings(PHPMD.CamelCaseMethodName) |
||
31 | * phpcs:disable PSR2.Methods.MethodDeclaration.Underscore |
||
32 | */ |
||
33 | protected function _before() |
||
37 | |||
38 | //============================================================================================================== |
||
39 | //================================================= TESTS ==================================================== |
||
40 | //============================================================================================================== |
||
41 | |||
42 | /** |
||
43 | * @dataProvider provideFields |
||
44 | * |
||
45 | * @param FieldModel $field |
||
46 | * @param array $definition |
||
47 | */ |
||
48 | public function testGetRecordDefinition(FieldModel $field, array $definition) |
||
63 | |||
64 | /** |
||
65 | * @dataProvider provideFields |
||
66 | * |
||
67 | * @param FieldModel $field |
||
68 | * @param array $definition |
||
69 | * @param string $groupStatus existing|new|invalid |
||
70 | */ |
||
71 | public function testSaveRecord(FieldModel $field, array $definition, string $groupStatus) |
||
90 | |||
91 | /** |
||
92 | * @dataProvider provideFields |
||
93 | * |
||
94 | * @param FieldModel $field |
||
95 | */ |
||
96 | public function testDeleteRecord(FieldModel $field) |
||
104 | |||
105 | /** |
||
106 | * @dataProvider provideFields |
||
107 | * |
||
108 | * @param FieldModel $field |
||
109 | * @param array $definition |
||
110 | */ |
||
111 | public function testSetRecordAttributes(FieldModel $field, array $definition) |
||
134 | |||
135 | //============================================================================================================== |
||
136 | //============================================== PROVIDERS =================================================== |
||
137 | //============================================================================================================== |
||
138 | |||
139 | /** |
||
140 | * @return array |
||
141 | */ |
||
142 | public function provideFields() |
||
171 | |||
172 | //============================================================================================================== |
||
173 | //================================================ HELPERS =================================================== |
||
174 | //============================================================================================================== |
||
175 | |||
176 | /** |
||
177 | * @param FieldModel $mockField |
||
178 | * |
||
179 | * @return array |
||
180 | */ |
||
181 | private function getMockFieldDefinition(FieldModel $mockField) |
||
199 | |||
200 | /** |
||
201 | * @param CategoriesField $mockField |
||
202 | * |
||
203 | * @return array |
||
204 | */ |
||
205 | private function getMockCategoriesFieldDefinition(CategoriesField $mockField) |
||
224 | |||
225 | /** |
||
226 | * @param int $fieldId |
||
227 | * @param int $groupId |
||
228 | * |
||
229 | * @return Mock|FieldModel |
||
230 | */ |
||
231 | private function getMockField(int $fieldId, int $groupId) |
||
242 | |||
243 | /** |
||
244 | * @param int $fieldId |
||
245 | * @param int $groupId |
||
246 | * |
||
247 | * @return Mock|Categories |
||
248 | */ |
||
249 | private function getMockCategoriesField(int $fieldId, int $groupId) |
||
262 | |||
263 | /** |
||
264 | * @param Mock|FieldModel $mockField |
||
265 | * @param int $fieldId |
||
266 | * @param int $groupId |
||
267 | */ |
||
268 | private function setMockFieldAttributes(FieldModel &$mockField, int $fieldId, int $groupId) |
||
279 | |||
280 | /** |
||
281 | * Get a mock field group. |
||
282 | * |
||
283 | * @param int $groupId |
||
284 | * |
||
285 | * @return Mock|FieldGroup |
||
286 | */ |
||
287 | private function getMockFieldGroup(int $groupId) |
||
298 | |||
299 | /** |
||
300 | * @param int $groupId |
||
301 | * |
||
302 | * @return Mock|CategoryGroup |
||
303 | */ |
||
304 | private function getMockCategoryGroup(int $groupId) |
||
320 | } |
||
321 |
This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.
Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.