diff --git a/src/Drivers/Abstract/Encoders/AbstractEncoder.php b/src/Drivers/Abstract/Encoders/AbstractEncoder.php deleted file mode 100644 index 36a0c073..00000000 --- a/src/Drivers/Abstract/Encoders/AbstractEncoder.php +++ /dev/null @@ -1,38 +0,0 @@ -quality = $quality; - - return $this; - } - - public function getQuality(): int - { - return $this->quality; - } -} diff --git a/tests/Drivers/Abstract/Encoders/AbstractEncoderTest.php b/tests/Drivers/Abstract/Encoders/AbstractEncoderTest.php deleted file mode 100644 index 09626609..00000000 --- a/tests/Drivers/Abstract/Encoders/AbstractEncoderTest.php +++ /dev/null @@ -1,48 +0,0 @@ -getAbstractEncoder()->getBuffered($callback)); - } - - public function testSetGetQuality(): void - { - $encoder = $this->getAbstractEncoder(); - $encoder->setQuality(55); - - static::assertSame(55, $encoder->getQuality()); - } - - private function getAbstractEncoder(): AbstractEncoder - { - return new class () extends AbstractEncoder implements EncoderInterface { - public function getBuffered(callable $callback): string - { - return parent::getBuffered($callback); - } - - public function encode(ImageInterface $image): EncodedImage - { - } - }; - } -} diff --git a/tests/Drivers/Abstract/Modifiers/AbstractPadModifierTest.php b/tests/Drivers/Abstract/Modifiers/AbstractPadModifierTest.php deleted file mode 100644 index 78c06e2b..00000000 --- a/tests/Drivers/Abstract/Modifiers/AbstractPadModifierTest.php +++ /dev/null @@ -1,67 +0,0 @@ - [150, 100, 100, 67, 0, 67]; - yield '100x150' => [100, 150, 100, 150, 0, 25]; - } - - /** @dataProvider providerCropSize */ - public function testGetCropSize(int $width, int $height, int $expectedWidth, int $expectedHeight, int $expectedX, int $expectedY): void - { - $modifier = $this->getModifier(100, 200, 'ffffff', 'center'); - - $image = (new Factory())->newImage($width, $height); - $size = $modifier->getCropSize($image); - - static::assertSame($expectedWidth, $size->width()); - static::assertSame($expectedHeight, $size->height()); - static::assertSame($expectedX, $size->getPivot()->x()); - static::assertSame($expectedY, $size->getPivot()->y()); - } - - public function testGetResizeSize(): void - { - $modifier = $this->getModifier(200, 100, 'ffffff', 'center'); - - $image = (new Factory())->newImage(300, 200); - $resize = $modifier->getResizeSize($image); - - static::assertSame(200, $resize->width()); - static::assertSame(100, $resize->height()); - static::assertSame(0, $resize->getPivot()->x()); - static::assertSame(0, $resize->getPivot()->y()); - } - - private function getModifier(int $width, int $height, $background, string $position): AbstractPadModifier - { - return new class($width, $height, $background, $position) extends AbstractPadModifier { - public function getCropSize(ImageInterface $image): SizeInterface - { - return parent::getCropSize($image); - } - - public function getResizeSize(ImageInterface $image): SizeInterface - { - return parent::getResizeSize($image); - } - }; - } -} diff --git a/tests/Drivers/Abstract/Decoders/AbstractDecoderTest.php b/tests/Drivers/AbstractDecoderTest.php similarity index 88% rename from tests/Drivers/Abstract/Decoders/AbstractDecoderTest.php rename to tests/Drivers/AbstractDecoderTest.php index b6d7f261..6ad61e87 100644 --- a/tests/Drivers/Abstract/Decoders/AbstractDecoderTest.php +++ b/tests/Drivers/AbstractDecoderTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Intervention\Image\Tests\Drivers\Abstract\Decoders; +namespace Intervention\Image\Tests\Drivers; -use Intervention\Image\Drivers\Abstract\Decoders\AbstractDecoder; +use Intervention\Image\Drivers\AbstractDecoder; use Intervention\Image\Exceptions\DecoderException; use Intervention\Image\Interfaces\ColorInterface; use Intervention\Image\Tests\TestCase; use Mockery; /** - * @covers \Intervention\Image\Drivers\Abstract\Decoders\AbstractDecoder + * @covers \Intervention\Image\Drivers\AbstractDecoder */ class AbstractDecoderTest extends TestCase { diff --git a/tests/Drivers/AbstractDriverTest.php b/tests/Drivers/AbstractDriverTest.php new file mode 100644 index 00000000..5a55e675 --- /dev/null +++ b/tests/Drivers/AbstractDriverTest.php @@ -0,0 +1,28 @@ +makePartial(); + $encoder = new GenericEncoder(); + $this->assertInstanceOf(GenericEncoder::class, $encoder); + $result = $driver->resolve(new GenericEncoder()); + $this->assertInstanceOf(SpecializedEncoder::class, $result); + } +} diff --git a/tests/Drivers/Abstract/AbstractImageTest.php b/tests/Drivers/AbstractImageTest.php similarity index 100% rename from tests/Drivers/Abstract/AbstractImageTest.php rename to tests/Drivers/AbstractImageTest.php diff --git a/tests/Drivers/Abstract/AbstractInputHandlerTest.php b/tests/Drivers/AbstractInputHandlerTest.php similarity index 81% rename from tests/Drivers/Abstract/AbstractInputHandlerTest.php rename to tests/Drivers/AbstractInputHandlerTest.php index 3f2ea472..86b4496c 100644 --- a/tests/Drivers/Abstract/AbstractInputHandlerTest.php +++ b/tests/Drivers/AbstractInputHandlerTest.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace Intervention\Image\Tests\Drivers\Abstract; +namespace Intervention\Image\Tests\Drivers; -use Intervention\Image\Drivers\Abstract\AbstractInputHandler; -use Intervention\Image\Drivers\Abstract\Decoders\AbstractDecoder; +use Intervention\Image\Drivers\AbstractDecoder; +use Intervention\Image\Drivers\AbstractInputHandler; use Intervention\Image\Interfaces\ImageInterface; use Intervention\Image\Tests\TestCase; use Mockery; /** - * @covers \Intervention\Image\Drivers\Abstract\AbstractInputHandler + * @covers \Intervention\Image\Drivers\AbstractInputHandler */ final class AbstractInputHandlerTest extends TestCase { diff --git a/tests/Drivers/DriverEncoderTest.php b/tests/Drivers/DriverEncoderTest.php new file mode 100644 index 00000000..cd7fc687 --- /dev/null +++ b/tests/Drivers/DriverEncoderTest.php @@ -0,0 +1,38 @@ +makePartial(); + $result = $encoder->getBuffered(function () { + echo 'result'; + }); + $this->assertEquals('result', $result); + } + + public function testGetAttributes(): void + { + $encoder = Mockery::mock(DriverEncoder::class, [ + new PngEncoder(color_limit: 123), + Mockery::mock(DriverInterface::class), + ])->makePartial(); + + $this->assertEquals(123, $encoder->color_limit); + } +}