1 | <?php |
||
36 | class ConfigurationTraitTest extends TestCase |
||
37 | { |
||
38 | /** |
||
39 | * Class under test |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | protected $cut = 'Interop\Config\ConfigurationTrait'; |
||
44 | |||
45 | /** |
||
46 | * Tests options() should throw exception if config parameter is not an array |
||
47 | * |
||
48 | * @covers \Interop\Config\ConfigurationTrait::options |
||
49 | */ |
||
50 | public function testOptionsThrowsInvalidArgumentExceptionIfConfigIsNotAnArray(): void |
||
58 | |||
59 | /** |
||
60 | * Tests canRetrieveOptions() : void |
||
61 | * |
||
62 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
63 | */ |
||
64 | public function testCanRetrieveOptions(): void |
||
84 | |||
85 | /** |
||
86 | * Tests canRetrieveOptions() : void |
||
87 | * |
||
88 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
89 | */ |
||
90 | public function testCanRetrieveOptionsWithContainerId(): void |
||
117 | |||
118 | /** |
||
119 | * Tests options() should throw exception if config id is provided but RequiresConfigId interface is not implemented |
||
120 | * |
||
121 | * @covers \Interop\Config\ConfigurationTrait::options |
||
122 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
123 | */ |
||
124 | public function testOptionsThrowsInvalidArgumentExIfConfigIdIsProvidedButRequiresConfigIdIsNotImplemented(): void |
||
134 | |||
135 | /** |
||
136 | * Tests options() should throw exception if config id is missing but RequiresConfigId interface is implemented |
||
137 | * |
||
138 | * @dataProvider providerConfig |
||
139 | * @covers \Interop\Config\ConfigurationTrait::options |
||
140 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
141 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
142 | */ |
||
143 | public function testOptionsThrowsOptionNotFoundExceptionIfConfigIdIsMissingWithRequiresConfigId($config): void |
||
153 | |||
154 | /** |
||
155 | * Tests options() should throw exception if no vendor config is available |
||
156 | * |
||
157 | * @covers \Interop\Config\ConfigurationTrait::options |
||
158 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
159 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
160 | */ |
||
161 | public function testOptionsThrowsOptionNotFoundExceptionIfNoVendorConfigIsAvailable(): void |
||
173 | |||
174 | /** |
||
175 | * Tests options() should throw exception if no package option is available |
||
176 | * |
||
177 | * @covers \Interop\Config\ConfigurationTrait::options |
||
178 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
179 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
180 | */ |
||
181 | public function testOptionsThrowsOptionNotFoundExceptionIfNoPackageOptionIsAvailable(): void |
||
196 | |||
197 | /** |
||
198 | * Tests options() should throw exception if no container id option is available |
||
199 | * |
||
200 | * @covers \Interop\Config\ConfigurationTrait::options |
||
201 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
202 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
203 | */ |
||
204 | public function testOptionsThrowsOptionNotFoundExceptionIfNoContainerIdOptionIsAvailable(): void |
||
216 | |||
217 | /** |
||
218 | * Tests options() should throw exception if a dimension is not available |
||
219 | * |
||
220 | * @covers \Interop\Config\ConfigurationTrait::options |
||
221 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
222 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
223 | */ |
||
224 | public function testOptionsThrowsOptionNotFoundExceptionIfDimensionIsNotAvailable(): void |
||
236 | |||
237 | /** |
||
238 | * Tests if options() works with dimensions, default options and mandatory options if no config is available |
||
239 | * |
||
240 | * @covers \Interop\Config\ConfigurationTrait::options |
||
241 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
242 | */ |
||
243 | public function testOptionsThrowsExceptionIfMandatoryOptionsWithDefaultOptionsSetAndNoConfigurationIsSet(): void |
||
253 | |||
254 | /** |
||
255 | * Tests options() should throw exception if retrieved options not an array or \ArrayAccess |
||
256 | * |
||
257 | * @covers \Interop\Config\ConfigurationTrait::options |
||
258 | * @covers \Interop\Config\Exception\UnexpectedValueException::invalidOptions |
||
259 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
260 | */ |
||
261 | public function testOptionsThrowsUnexpectedValueExceptionIfRetrievedOptionsNotAnArrayOrArrayAccess(): void |
||
273 | |||
274 | /** |
||
275 | * Tests if options() works with container id |
||
276 | * |
||
277 | * @dataProvider providerConfig |
||
278 | * @covers \Interop\Config\ConfigurationTrait::options |
||
279 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
280 | */ |
||
281 | public function testOptionsReturnsDataWithContainerId($config): void |
||
292 | |||
293 | /** |
||
294 | * Tests if options() works without container id |
||
295 | * |
||
296 | * @dataProvider providerConfig |
||
297 | * @covers \Interop\Config\ConfigurationTrait::options |
||
298 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
299 | */ |
||
300 | public function testOptionsReturnsData($config): void |
||
310 | |||
311 | /** |
||
312 | * Tests if options() works with flexible dimensions |
||
313 | * |
||
314 | * @dataProvider providerConfig |
||
315 | * @covers \Interop\Config\ConfigurationTrait::options |
||
316 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
317 | */ |
||
318 | public function testOptionsReturnsDataWithFlexibleDimensions($config): void |
||
329 | |||
330 | /** |
||
331 | * Tests if options() works with no dimensions |
||
332 | * |
||
333 | * @dataProvider providerConfig |
||
334 | * @covers \Interop\Config\ConfigurationTrait::options |
||
335 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
336 | */ |
||
337 | public function testOptionsReturnsDataWithNoDimensions($config): void |
||
348 | |||
349 | /** |
||
350 | * Tests if options() works with default options |
||
351 | * |
||
352 | * @dataProvider providerConfig |
||
353 | * @covers \Interop\Config\ConfigurationTrait::options |
||
354 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
355 | */ |
||
356 | public function testOptionsReturnsDataWithDefaultOptions($config): void |
||
387 | |||
388 | /** |
||
389 | * Tests if options() works with dimensions and default options if no config is available |
||
390 | * |
||
391 | * @covers \Interop\Config\ConfigurationTrait::options |
||
392 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
393 | */ |
||
394 | public function testOptionsReturnsPackageDataWithDefaultOptionsIfNoConfigurationIsSet(): void |
||
409 | |||
410 | /** |
||
411 | * Tests if options() works default options and default options not override provided options |
||
412 | * |
||
413 | * @dataProvider providerConfig |
||
414 | * @covers \Interop\Config\ConfigurationTrait::options |
||
415 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
416 | */ |
||
417 | public function testOptionsThatDefaultOptionsNotOverrideProvidedOptions($config): void |
||
438 | |||
439 | /** |
||
440 | * Tests if options() works with mandatory options interface |
||
441 | * |
||
442 | * @dataProvider providerConfig |
||
443 | * @covers \Interop\Config\ConfigurationTrait::options |
||
444 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
445 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
446 | */ |
||
447 | public function testOptionsChecksMandatoryOptions($config): void |
||
456 | |||
457 | /** |
||
458 | * Tests if options() works with mandatory options interface |
||
459 | * |
||
460 | * @dataProvider providerConfig |
||
461 | * @covers \Interop\Config\ConfigurationTrait::options |
||
462 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
463 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
464 | */ |
||
465 | public function testOptionsChecksMandatoryOptionsWithContainerId($config): void |
||
475 | |||
476 | /** |
||
477 | * Tests if options() throws a runtime exception if mandatory option is missing |
||
478 | * |
||
479 | * @dataProvider providerConfig |
||
480 | * @covers \Interop\Config\ConfigurationTrait::options |
||
481 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
482 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
483 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
484 | */ |
||
485 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfMandatoryOptionIsMissing($config): void |
||
496 | |||
497 | /** |
||
498 | * Tests if options() throws a runtime exception if a recursive mandatory option is missing |
||
499 | * |
||
500 | * @dataProvider providerConfig |
||
501 | * @covers \Interop\Config\ConfigurationTrait::options |
||
502 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
503 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
504 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
505 | */ |
||
506 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfMandatoryOptionRecursiveIsMissing($config): void |
||
517 | |||
518 | /** |
||
519 | * Tests options() with recursive mandatory options check |
||
520 | * |
||
521 | * @dataProvider providerConfig |
||
522 | * @covers \Interop\Config\ConfigurationTrait::options |
||
523 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
524 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
525 | */ |
||
526 | public function testOptionsWithRecursiveMandatoryOptionCheck($config): void |
||
533 | |||
534 | /** |
||
535 | * Tests options() with recursive mandatory options as array iterator |
||
536 | * |
||
537 | * @dataProvider providerConfig |
||
538 | * @covers \Interop\Config\ConfigurationTrait::options |
||
539 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
540 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
541 | */ |
||
542 | public function testOptionsWithRecursiveArrayIteratorMandatoryOptionCheck($config): void |
||
549 | |||
550 | /** |
||
551 | * Tests if options() throws a runtime exception if a recursive mandatory option is missing |
||
552 | * |
||
553 | * @dataProvider providerConfig |
||
554 | * @covers \Interop\Config\ConfigurationTrait::optionsWithFallback |
||
555 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
556 | */ |
||
557 | public function testOptionsWithFallback($config): void |
||
572 | |||
573 | /** |
||
574 | * Tests if options() throws a runtime exception if a recursive mandatory option is missing |
||
575 | * |
||
576 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
577 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
578 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
579 | */ |
||
580 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfOptionsAreEmpty(): void |
||
592 | |||
593 | public function providerConfig(): array |
||
600 | |||
601 | /** |
||
602 | * Returns test config |
||
603 | * |
||
604 | * @return array |
||
605 | */ |
||
606 | private function getTestConfig(): array |
||
617 | |||
618 | /** |
||
619 | * @param $exception |
||
620 | * @param $message |
||
621 | */ |
||
622 | private function assertException($exception, $message): void |
||
627 | } |
||
628 |
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: