Commit e7e47f88 authored by Steven Jones's avatar Steven Jones
Browse files

Revert "Get the unit test actually working."

This reverts commit 2081b50f.
parent 2081b50f
......@@ -2,8 +2,8 @@
namespace Drupal\Tests\imageapi_optimize\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\imageapi_optimize\Plugin\ImageAPIOptimizeProcessor\AdvDef;
use Drupal\Tests\UnitTestCase;
/**
* Tests AdvDef image optimize plugin.
......@@ -14,41 +14,26 @@ class AdvDefTest extends UnitTestCase {
function testCase() {
$this->assertTrue(TRUE);
// Make some mocks.
$config = [];
$loggerMock = $this->getMock('\Psr\Log\LoggerInterface');
$imageFactoryMock = $this->getMockBuilder('\Drupal\Core\Image\ImageFactory')
$advdefMock = $this->getMockBuilder('\Drupal\imageapi_optimize\Plugin\ImageAPIOptimizeProcessor\AdvDef')
->setMethods(['getFullPathToBinary', 'execShellCommand', 'getMimeType', 'sanitizeFilename'])
->disableOriginalConstructor()
->disableOriginalClone()
->disableArgumentCloning()
->getMock();
$fileSystemMock = $this->getMock('\Drupal\Core\File\FileSystemInterface');
$shellOperationsMock = $this->getMockBuilder('\Drupal\iamgeapi_optimize\ImageAPIOptimizeShellOperationsInterface')
->setMethods(['findExecutablePath', 'execShellCommand'])
->getMock();
// Load up the plugin.
$advdef = new AdvDef($config, 'advdef', [], $loggerMock, $imageFactoryMock, $fileSystemMock, $shellOperationsMock);
$this->assertArrayHasKey('recompress', $advdef->defaultConfiguration());
$this->assertArrayHasKey('mode', $advdef->defaultConfiguration());
$shellOperationsMock->method('findExecutablePath')->will($this->returnArgument(0));
$fileSystemMock->method('realpath')->will($this->returnArgument(0));
$advdefMock->method('getFullPathToBinary')
->willReturn('/bin/advdef');
$advdefMock->method('sanitizeFilename')
->will($this->returnArgument(0));
$imagePNGMock = $this->getMock('\Drupal\Core\Image\ImageInterface');
$imagePNGMock->method('getMimeType')->willReturn('image/png');
$imageFactoryMock->method('get')->willReturn($imagePNGMock);
$this->assertEquals('/bin/advdef', $advdefMock->getFullPathToBinary());
$this->assertEquals('some filename', $advdefMock->sanitizeFilename('some filename'));
$shellOperationsMock->expects($this->once())
$advdefMock->expects($this->once())
->method('execShellCommand')
->with(
$this->equalTo('advdef'),
$this->identicalTo(['--quiet', '--recompress', '-3']),
$this->identicalTo(['public://test_image.png'])
);
->with($this->equalTo('something'));
$advdef->applyToImage('public://test_image.png');
$advdefMock->applyToImage('public://test_image.png');
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment