public function AdvDefTest::testOnlyApplyToPNG in Image Optimize Binaries 8
Test that the AdvDef plugin does not run on JPGs
File
- tests/
src/ Unit/ AdvDefTest.php, line 33
Class
- AdvDefTest
- Tests AdvDef image optimize plugin.
Namespace
Drupal\Tests\imageapi_optimize_binaries\UnitCode
public function testOnlyApplyToPNG() {
$config = [];
$loggerMock = $this
->getLoggerMock();
$imageFactoryMock = $this
->getImageFactoryMock();
$fileSystemMock = $this
->getFileSystemMock();
$shellOperationsMock = $this
->getShellOperationsMock();
$advdef = new AdvDef($config, 'advdef', [], $loggerMock, $imageFactoryMock, $fileSystemMock, $shellOperationsMock);
$imagePNGMock = $this
->createMock('\\Drupal\\Core\\Image\\ImageInterface');
$imagePNGMock
->method('getMimeType')
->willReturn('image/jpeg');
$imageFactoryMock
->method('get')
->willReturn($imagePNGMock);
// Assert no call is made through to the shell commands.
$shellOperationsMock
->expects($this
->never())
->method('execShellCommand');
// And assert that a 'jpg' isn't processed.
$this
->assertFalse($advdef
->applyToImage('public://test_image.jpg'));
}