36 $this->loggerMock = $this->getMockBuilder(\Psr\Log\LoggerInterface::class)->getMock();
37 $this->writeMock = $this->getMockBuilder(
40 $this->filesystemMock = $this->createPartialMock(\
Magento\Framework\Filesystem::class, [
'getDirectoryWrite']);
42 ->expects($this->once())
43 ->method(
'getDirectoryWrite')
44 ->willReturn($this->writeMock);
49 [
'filesystem' => $this->filesystemMock,
50 'logger' => $this->loggerMock]
61 $this->expectException(
'LogicException');
62 $this->expectExceptionMessage($expectedMessage);
63 $this->imageMagic->watermark($imagePath);
72 [
'', \Magento\Framework\Image\Adapter\ImageMagick::ERROR_WATERMARK_IMAGE_ABSENT],
73 [
__DIR__ .
'/not_exists', \Magento\Framework\Image\Adapter\ImageMagick::ERROR_WATERMARK_IMAGE_ABSENT],
75 __DIR__ .
'/_files/invalid_image.jpg',
76 \Magento\Framework\Image\Adapter\ImageMagick::ERROR_WRONG_IMAGE
88 new \
Magento\Framework\
Phrase(
'Unable to write file into directory product/cache. Access forbidden.')
90 $this->writeMock->method(
'create')->will($this->throwException($exception));
91 $this->loggerMock->expects($this->once())->method(
'critical')->with($exception);
92 $this->imageMagic->save(
'product/cache',
'sample.jpg');
defined('TESTS_BP')||define('TESTS_BP' __DIR__
testWatermark($imagePath, $expectedMessage)