1 | <?php |
||
38 | class ConfigurationTraitTest extends TestCase |
||
39 | { |
||
40 | /** |
||
41 | * Class under test |
||
42 | * |
||
43 | * @var string |
||
44 | */ |
||
45 | protected $cut = 'Interop\Config\ConfigurationTrait'; |
||
46 | |||
47 | /** |
||
48 | * Tests options() should throw exception if config parameter is not an array |
||
49 | * |
||
50 | * @covers \Interop\Config\ConfigurationTrait::options |
||
51 | */ |
||
52 | public function testOptionsThrowsInvalidArgumentExceptionIfConfigIsNotAnArray(): void |
||
60 | |||
61 | /** |
||
62 | * Tests canRetrieveOptions() : void |
||
63 | * |
||
64 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
65 | */ |
||
66 | public function testCanRetrieveOptions(): void |
||
86 | |||
87 | /** |
||
88 | * Tests canRetrieveOptions() : void |
||
89 | * |
||
90 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
91 | */ |
||
92 | public function testCanRetrieveOptionsWithContainerId(): void |
||
119 | |||
120 | /** |
||
121 | * Tests options() should throw exception if config id is provided but RequiresConfigId interface is not implemented |
||
122 | * |
||
123 | * @covers \Interop\Config\ConfigurationTrait::options |
||
124 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
125 | */ |
||
126 | public function testOptionsThrowsInvalidArgumentExIfConfigIdIsProvidedButRequiresConfigIdIsNotImplemented(): void |
||
136 | |||
137 | /** |
||
138 | * Tests options() should throw exception if config id is missing but RequiresConfigId interface is implemented |
||
139 | * |
||
140 | * @dataProvider providerConfig |
||
141 | * @covers \Interop\Config\ConfigurationTrait::options |
||
142 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
143 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
144 | */ |
||
145 | public function testOptionsThrowsOptionNotFoundExceptionIfConfigIdIsMissingWithRequiresConfigId($config): void |
||
155 | |||
156 | /** |
||
157 | * Tests options() should throw exception if no vendor config is available |
||
158 | * |
||
159 | * @covers \Interop\Config\ConfigurationTrait::options |
||
160 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
161 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
162 | */ |
||
163 | public function testOptionsThrowsOptionNotFoundExceptionIfNoVendorConfigIsAvailable(): void |
||
175 | |||
176 | /** |
||
177 | * Tests options() should throw exception if no package option is available |
||
178 | * |
||
179 | * @covers \Interop\Config\ConfigurationTrait::options |
||
180 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
181 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
182 | */ |
||
183 | public function testOptionsThrowsOptionNotFoundExceptionIfNoPackageOptionIsAvailable(): void |
||
198 | |||
199 | /** |
||
200 | * Tests options() should throw exception if no container id option is available |
||
201 | * |
||
202 | * @covers \Interop\Config\ConfigurationTrait::options |
||
203 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
204 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
205 | */ |
||
206 | public function testOptionsThrowsOptionNotFoundExceptionIfNoContainerIdOptionIsAvailable(): void |
||
218 | |||
219 | /** |
||
220 | * Tests options() should throw exception if a dimension is not available |
||
221 | * |
||
222 | * @covers \Interop\Config\ConfigurationTrait::options |
||
223 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
224 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
225 | */ |
||
226 | public function testOptionsThrowsOptionNotFoundExceptionIfDimensionIsNotAvailable(): void |
||
238 | |||
239 | /** |
||
240 | * Tests if options() works with dimensions, default options and mandatory options if no config is available |
||
241 | * |
||
242 | * @covers \Interop\Config\ConfigurationTrait::options |
||
243 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
244 | */ |
||
245 | public function testOptionsThrowsExceptionIfMandatoryOptionsWithDefaultOptionsSetAndNoConfigurationIsSet(): void |
||
255 | |||
256 | /** |
||
257 | * Tests options() should throw exception if retrieved options not an array or \ArrayAccess |
||
258 | * |
||
259 | * @covers \Interop\Config\ConfigurationTrait::options |
||
260 | * @covers \Interop\Config\Exception\UnexpectedValueException::invalidOptions |
||
261 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
262 | */ |
||
263 | public function testOptionsThrowsUnexpectedValueExceptionIfRetrievedOptionsNotAnArrayOrArrayAccess(): void |
||
275 | |||
276 | /** |
||
277 | * Tests if options() works with container id |
||
278 | * |
||
279 | * @dataProvider providerConfig |
||
280 | * @covers \Interop\Config\ConfigurationTrait::options |
||
281 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
282 | */ |
||
283 | public function testOptionsReturnsDataWithContainerId($config): void |
||
294 | |||
295 | /** |
||
296 | * Tests if options() works without container id |
||
297 | * |
||
298 | * @dataProvider providerConfig |
||
299 | * @covers \Interop\Config\ConfigurationTrait::options |
||
300 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
301 | */ |
||
302 | public function testOptionsReturnsData($config): void |
||
312 | |||
313 | /** |
||
314 | * Tests if options() works with flexible dimensions |
||
315 | * |
||
316 | * @dataProvider providerConfig |
||
317 | * @covers \Interop\Config\ConfigurationTrait::options |
||
318 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
319 | */ |
||
320 | public function testOptionsReturnsDataWithFlexibleDimensions($config): void |
||
331 | |||
332 | /** |
||
333 | * Tests if options() works with no dimensions |
||
334 | * |
||
335 | * @dataProvider providerConfig |
||
336 | * @covers \Interop\Config\ConfigurationTrait::options |
||
337 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
338 | */ |
||
339 | public function testOptionsReturnsDataWithNoDimensions($config): void |
||
350 | |||
351 | /** |
||
352 | * Tests if options() works with default options |
||
353 | * |
||
354 | * @dataProvider providerConfig |
||
355 | * @covers \Interop\Config\ConfigurationTrait::options |
||
356 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
357 | */ |
||
358 | public function testOptionsReturnsDataWithDefaultOptions($config): void |
||
391 | |||
392 | /** |
||
393 | * Tests if options() works with dimensions and default options if no config is available |
||
394 | * |
||
395 | * @covers \Interop\Config\ConfigurationTrait::options |
||
396 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
397 | */ |
||
398 | public function testOptionsReturnsPackageDataWithDefaultOptionsIfNoConfigurationIsSet(): void |
||
414 | |||
415 | /** |
||
416 | * Tests if options() works default options and default options not override provided options |
||
417 | * |
||
418 | * @dataProvider providerConfig |
||
419 | * @covers \Interop\Config\ConfigurationTrait::options |
||
420 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
421 | */ |
||
422 | public function testOptionsThatDefaultOptionsNotOverrideProvidedOptions($config): void |
||
444 | |||
445 | /** |
||
446 | * Tests if options() works with mandatory options interface |
||
447 | * |
||
448 | * @dataProvider providerConfig |
||
449 | * @covers \Interop\Config\ConfigurationTrait::options |
||
450 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
451 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
452 | */ |
||
453 | public function testOptionsChecksMandatoryOptions($config): void |
||
463 | |||
464 | /** |
||
465 | * Tests if options() works with mandatory options interface |
||
466 | * |
||
467 | * @dataProvider providerConfig |
||
468 | * @covers \Interop\Config\ConfigurationTrait::options |
||
469 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
470 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
471 | */ |
||
472 | public function testOptionsChecksMandatoryOptionsWithContainerId($config): void |
||
483 | |||
484 | /** |
||
485 | * Tests if options() throws a runtime exception if mandatory option is missing |
||
486 | * |
||
487 | * @dataProvider providerConfig |
||
488 | * @covers \Interop\Config\ConfigurationTrait::options |
||
489 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
490 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
491 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
492 | */ |
||
493 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfMandatoryOptionIsMissing($config): void |
||
504 | |||
505 | /** |
||
506 | * Tests if options() throws a runtime exception if a recursive mandatory option is missing |
||
507 | * |
||
508 | * @dataProvider providerConfig |
||
509 | * @covers \Interop\Config\ConfigurationTrait::options |
||
510 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
511 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
512 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
513 | */ |
||
514 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfMandatoryOptionRecursiveIsMissing($config): void |
||
525 | |||
526 | /** |
||
527 | * Tests options() with recursive mandatory options check |
||
528 | * |
||
529 | * @dataProvider providerConfig |
||
530 | * @covers \Interop\Config\ConfigurationTrait::options |
||
531 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
532 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
533 | */ |
||
534 | public function testOptionsWithRecursiveMandatoryOptionCheck($config): void |
||
541 | |||
542 | /** |
||
543 | * Tests options() with recursive mandatory options as array iterator |
||
544 | * |
||
545 | * @dataProvider providerConfig |
||
546 | * @covers \Interop\Config\ConfigurationTrait::options |
||
547 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
548 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
549 | */ |
||
550 | public function testOptionsWithRecursiveArrayIteratorMandatoryOptionCheck($config): void |
||
557 | |||
558 | /** |
||
559 | * Tests if optionsWithFallback() |
||
560 | * |
||
561 | * @dataProvider providerConfig |
||
562 | * @covers \Interop\Config\ConfigurationTrait::optionsWithFallback |
||
563 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
564 | */ |
||
565 | public function testOptionsWithFallback($config): void |
||
580 | |||
581 | /** |
||
582 | * Tests if options() throws a runtime exception if a recursive mandatory option is missing |
||
583 | * |
||
584 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
585 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
586 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
587 | */ |
||
588 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfOptionsAreEmpty(): void |
||
600 | |||
601 | /** |
||
602 | * Tests if options() works with an empty \ArrayAccess object and default options. |
||
603 | * |
||
604 | * @covers \Interop\Config\ConfigurationTrait::options |
||
605 | */ |
||
606 | public function testEmptyArrayAccessWithDefaultOptions() |
||
626 | |||
627 | /** |
||
628 | * Tests if options() works with iterable objects like \ArrayIterator or \ArrayObject |
||
629 | * |
||
630 | * @dataProvider providerConfigObjects |
||
631 | * @covers \Interop\Config\ConfigurationTrait::options |
||
632 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
633 | */ |
||
634 | public function testOptionsWithObjects($config, $type): void |
||
667 | |||
668 | public function providerConfig(): array |
||
676 | |||
677 | public function providerConfigObjects(): array |
||
697 | |||
698 | /** |
||
699 | * Returns test config |
||
700 | * |
||
701 | * @return array |
||
702 | */ |
||
703 | private function getTestConfig(): array |
||
714 | |||
715 | /** |
||
716 | * @param $exception |
||
717 | * @param $message |
||
718 | */ |
||
719 | private function assertException($exception, $message): void |
||
724 | } |
||
725 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: