assertInstanceOf($outputClassname, $handler->handle($input)); } else { $this->expectException($outputClassname); $handler->handle($input); } } public static function handleProvider(): Generator { $base = [ [null, DecoderException::class], ['', DecoderException::class], ['fff', ColorInterface::class], ['rgba(0, 0, 0, 0)', ColorInterface::class], ['cmyk(0, 0, 0, 0)', ColorInterface::class], ['hsv(0, 0, 0)', ColorInterface::class], ['hsl(0, 0, 0)', ColorInterface::class], ['transparent', ColorInterface::class], ['steelblue', ColorInterface::class], [self::getTestResourcePath(), ImageInterface::class], [file_get_contents(self::getTestResourcePath()), ImageInterface::class], ]; $drivers = [GdDriver::class, ImagickDriver::class]; foreach ($drivers as $driver) { foreach ($base as $line) { array_unshift($line, $driver); // prepend driver yield $line; } } } public function testResolveWithoutDriver(): void { $handler = new InputHandler([new HexColorDecoder()]); $result = $handler->handle('fff'); $this->assertInstanceOf(ColorInterface::class, $result); $handler = new InputHandler([HexColorDecoder::class]); $result = $handler->handle('fff'); $this->assertInstanceOf(ColorInterface::class, $result); } }