1 | <?php |
||
33 | class ConfigurationTraitTest extends TestCase |
||
34 | { |
||
35 | /** |
||
36 | * Class under test |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | protected $cut = 'Interop\Config\ConfigurationTrait'; |
||
41 | |||
42 | /** |
||
43 | * Tests options() should throw exception if config parameter is not an array |
||
44 | * |
||
45 | * @covers \Interop\Config\ConfigurationTrait::options |
||
46 | */ |
||
47 | public function testOptionsThrowsInvalidArgumentExceptionIfConfigIsNotAnArray() |
||
55 | |||
56 | /** |
||
57 | * Tests canRetrieveOptions() |
||
58 | * |
||
59 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
60 | */ |
||
61 | public function testCanRetrieveOptions() |
||
81 | |||
82 | /** |
||
83 | * Tests canRetrieveOptions() |
||
84 | * |
||
85 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
86 | */ |
||
87 | public function testCanRetrieveOptionsWithContainerId() |
||
114 | |||
115 | /** |
||
116 | * Tests options() should throw exception if config id is provided but RequiresConfigId interface is not implemented |
||
117 | * |
||
118 | * @covers \Interop\Config\ConfigurationTrait::options |
||
119 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
120 | */ |
||
121 | public function testOptionsThrowsInvalidArgumentExceptionIfConfigIdIsProvidedButRequiresConfigIdIsNotImplemented() |
||
131 | |||
132 | /** |
||
133 | * Tests options() should throw exception if config id is missing but RequiresConfigId interface is implemented |
||
134 | * |
||
135 | * @covers \Interop\Config\ConfigurationTrait::options |
||
136 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
137 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
138 | */ |
||
139 | public function testOptionsThrowsOptionNotFoundExceptionIfConfigIdIsMissingButRequiresConfigIdIsImplemented() |
||
151 | |||
152 | /** |
||
153 | * Tests options() should throw exception if no vendor config is available |
||
154 | * |
||
155 | * @covers \Interop\Config\ConfigurationTrait::options |
||
156 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
157 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
158 | */ |
||
159 | public function testOptionsThrowsOptionNotFoundExceptionIfNoVendorConfigIsAvailable() |
||
171 | |||
172 | /** |
||
173 | * Tests options() should throw exception if no package option is available |
||
174 | * |
||
175 | * @covers \Interop\Config\ConfigurationTrait::options |
||
176 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
177 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
178 | */ |
||
179 | public function testOptionsThrowsOptionNotFoundExceptionIfNoPackageOptionIsAvailable() |
||
194 | |||
195 | /** |
||
196 | * Tests options() should throw exception if no container id option is available |
||
197 | * |
||
198 | * @covers \Interop\Config\ConfigurationTrait::options |
||
199 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
200 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
201 | */ |
||
202 | public function testOptionsThrowsOptionNotFoundExceptionIfNoContainerIdOptionIsAvailable() |
||
214 | |||
215 | /** |
||
216 | * Tests options() should throw exception if a dimension is not available |
||
217 | * |
||
218 | * @covers \Interop\Config\ConfigurationTrait::options |
||
219 | * @covers \Interop\Config\Exception\OptionNotFoundException::missingOptions |
||
220 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
221 | */ |
||
222 | public function testOptionsThrowsOptionNotFoundExceptionIfDimensionIsNotAvailable() |
||
234 | |||
235 | /** |
||
236 | * Tests if options() works with dimensions, default options and mandatory options if no config is available |
||
237 | * |
||
238 | * @covers \Interop\Config\ConfigurationTrait::options |
||
239 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
240 | */ |
||
241 | public function testOptionsThrowsExceptionIfMandatoryOptionsWithDefaultOptionsSetAndNoConfigurationIsSet() |
||
251 | |||
252 | /** |
||
253 | * Tests options() should throw exception if retrieved options not an array or \ArrayAccess |
||
254 | * |
||
255 | * @covers \Interop\Config\ConfigurationTrait::options |
||
256 | * @covers \Interop\Config\Exception\UnexpectedValueException::invalidOptions |
||
257 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
258 | */ |
||
259 | public function testOptionsThrowsUnexpectedValueExceptionIfRetrievedOptionsNotAnArrayOrArrayAccess() |
||
271 | |||
272 | /** |
||
273 | * Tests if options() works with container id |
||
274 | * |
||
275 | * @covers \Interop\Config\ConfigurationTrait::options |
||
276 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
277 | */ |
||
278 | public function testOptionsReturnsDataWithContainerId() |
||
291 | |||
292 | /** |
||
293 | * Tests if options() works without container id |
||
294 | * |
||
295 | * @covers \Interop\Config\ConfigurationTrait::options |
||
296 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
297 | */ |
||
298 | public function testOptionsReturnsData() |
||
310 | |||
311 | /** |
||
312 | * Tests if options() works with flexible dimensions |
||
313 | * |
||
314 | * @covers \Interop\Config\ConfigurationTrait::options |
||
315 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
316 | */ |
||
317 | public function testOptionsReturnsDataWithFlexibleDimensions() |
||
330 | |||
331 | /** |
||
332 | * Tests if options() works with no dimensions |
||
333 | * |
||
334 | * @covers \Interop\Config\ConfigurationTrait::options |
||
335 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
336 | */ |
||
337 | public function testOptionsReturnsDataWithNoDimensions() |
||
350 | |||
351 | /** |
||
352 | * Tests if options() works with default options |
||
353 | * |
||
354 | * @covers \Interop\Config\ConfigurationTrait::options |
||
355 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
356 | */ |
||
357 | public function testOptionsReturnsDataWithDefaultOptions() |
||
389 | |||
390 | /** |
||
391 | * Tests if options() works with dimensions and default options if no config is available |
||
392 | * |
||
393 | * @covers \Interop\Config\ConfigurationTrait::options |
||
394 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
395 | */ |
||
396 | public function testOptionsReturnsPackageDataWithDefaultOptionsIfNoConfigurationIsSet() |
||
411 | |||
412 | /** |
||
413 | * Tests if options() works default options and default options not override provided options |
||
414 | * |
||
415 | * @covers \Interop\Config\ConfigurationTrait::options |
||
416 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
417 | */ |
||
418 | public function testOptionsThatDefaultOptionsNotOverrideProvidedOptions() |
||
441 | |||
442 | /** |
||
443 | * Tests if options() works with mandatory options interface |
||
444 | * |
||
445 | * @covers \Interop\Config\ConfigurationTrait::options |
||
446 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
447 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
448 | */ |
||
449 | public function testOptionsChecksMandatoryOptions() |
||
460 | |||
461 | /** |
||
462 | * Tests if options() works with mandatory options interface |
||
463 | * |
||
464 | * @covers \Interop\Config\ConfigurationTrait::options |
||
465 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
466 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
467 | */ |
||
468 | public function testOptionsChecksMandatoryOptionsWithContainerId() |
||
480 | |||
481 | /** |
||
482 | * Tests if options() throws a runtime exception if mandatory option is missing |
||
483 | * |
||
484 | * @covers \Interop\Config\ConfigurationTrait::options |
||
485 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
486 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
487 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
488 | */ |
||
489 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfMandatoryOptionIsMissing() |
||
501 | |||
502 | /** |
||
503 | * Tests if options() throws a runtime exception if a recursive mandatory option is missing |
||
504 | * |
||
505 | * @covers \Interop\Config\ConfigurationTrait::options |
||
506 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
507 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
508 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
509 | */ |
||
510 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfMandatoryOptionRecursiveIsMissing() |
||
523 | |||
524 | /** |
||
525 | * Tests options() with recursive mandatory options check |
||
526 | * |
||
527 | * @covers \Interop\Config\ConfigurationTrait::options |
||
528 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
529 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
530 | */ |
||
531 | public function testOptionsWithRecursiveMandatoryOptionCheck() |
||
540 | |||
541 | /** |
||
542 | * Tests if options() throws a runtime exception if a recursive mandatory option is missing |
||
543 | * |
||
544 | * @covers \Interop\Config\ConfigurationTrait::optionsWithFallback |
||
545 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
546 | */ |
||
547 | public function testOptionsWithFallback() |
||
562 | |||
563 | /** |
||
564 | * Tests if options() throws a runtime exception if a recursive mandatory option is missing |
||
565 | * |
||
566 | * @covers \Interop\Config\ConfigurationTrait::checkMandatoryOptions |
||
567 | * @covers \Interop\Config\Exception\MandatoryOptionNotFoundException::missingOption |
||
568 | * @covers \Interop\Config\ConfigurationTrait::canRetrieveOptions |
||
569 | */ |
||
570 | public function testOptionsThrowsMandatoryOptionNotFoundExceptionIfOptionsAreEmpty() |
||
582 | |||
583 | /** |
||
584 | * Returns test config |
||
585 | * |
||
586 | * @return array |
||
587 | */ |
||
588 | private function getTestConfig() |
||
599 | |||
600 | /** |
||
601 | * @param $exception |
||
602 | * @param $message |
||
603 | */ |
||
604 | private function assertException($exception, $message) |
||
613 | } |
||
614 |
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: