diff --git a/Test/Unit/Image/TargetImageFactoryTest.php b/Test/Unit/Image/TargetImageFactoryTest.php index 57ef813..bf94be8 100644 --- a/Test/Unit/Image/TargetImageFactoryTest.php +++ b/Test/Unit/Image/TargetImageFactoryTest.php @@ -3,6 +3,9 @@ namespace Yireo\NextGenImages\Test\Unit\Image; use Magento\Framework\App\Filesystem\DirectoryList; +use Magento\Framework\Filesystem; +use Magento\Framework\Filesystem\Directory\WriteInterface; +use Magento\Framework\Filesystem\DriverInterface; use Yireo\NextGenImages\Config\Config; use Yireo\NextGenImages\Config\Source\TargetDirectory; use Yireo\NextGenImages\Image\TargetImageFactory; @@ -19,11 +22,19 @@ public function testGetWithSameTargetDirectory() ->with($this->equalTo('/tmp/pub/example.webp')) ->willReturn(new Image('/tmp/pub/example.webp', '/example.webp')); + $driver = $this->getMagentoMock(DriverInterface::class); + $driver->method('getParentDirectory')->willReturn('/tmp'); + $writer = $this->getMagentoMock(WriteInterface::class); + $writer->method('getDriver')->willReturn($driver); + $filesystem = $this->getMagentoMock(Filesystem::class); + $filesystem->method('getDirectoryWrite')->willReturn($writer); + // @phpstan-ignore-next-line $targetImageFactory = new TargetImageFactory( $this->getMagentoMock(DirectoryList::class), $this->getMagentoMock(Config::class), - $imageFactory + $imageFactory, + $filesystem ); $jpgImage = new Image('/tmp/pub/example.jpg', '/example.jpg'); @@ -44,11 +55,19 @@ public function testGetWithCacheTargetDirectory() $imageFactory = $this->getMagentoMock(ImageFactory::class); $imageFactory->method('createFromPath')->willReturn(new Image('/tmp/pub/example.webp', '/example.webp')); + $driver = $this->getMagentoMock(DriverInterface::class); + $driver->method('getParentDirectory')->willReturn('/tmp'); + $writer = $this->getMagentoMock(WriteInterface::class); + $writer->method('getDriver')->willReturn($driver); + $filesystem = $this->getMagentoMock(Filesystem::class); + $filesystem->method('getDirectoryWrite')->willReturn($writer); + // @phpstan-ignore-next-line $targetImageFactory = new TargetImageFactory( $directoryList, $config, - $imageFactory + $imageFactory, + $filesystem ); $jpgImage = new Image('/tmp/pub/example.jpg', '/example.jpg');