diff --git a/src/Knp/Snappy/AbstractGenerator.php b/src/Knp/Snappy/AbstractGenerator.php index fec44b15..dcfcf767 100644 --- a/src/Knp/Snappy/AbstractGenerator.php +++ b/src/Knp/Snappy/AbstractGenerator.php @@ -433,6 +433,8 @@ protected function buildCommand($binary, $input, $output, array $options = array // Dont't add '--' if option is "cover" or "toc". if (in_array($key, array('toc', 'cover'))) { $command .= ' '.$key.' '.escapeshellarg($option); + } elseif (in_array($key, ['image-dpi', 'image-quality'])) { + $command .= ' --'.$key.' '. (int) $option; } else { $command .= ' --'.$key.' '.escapeshellarg($option); } diff --git a/test/Knp/Snappy/AbstractGeneratorTest.php b/test/Knp/Snappy/AbstractGeneratorTest.php index 96403033..c0c8c3b3 100644 --- a/test/Knp/Snappy/AbstractGeneratorTest.php +++ b/test/Knp/Snappy/AbstractGeneratorTest.php @@ -527,6 +527,16 @@ public function dataForBuildCommand() ), $theBinary . ' --allow ' . escapeshellarg('/path1') . ' --allow ' . escapeshellarg('/path2') . ' --no-background ' . escapeshellarg('1') . ' ' . escapeshellarg('http://the.url/') . ' ' . escapeshellarg('/the/path') ), + [ + $theBinary, + 'http://the.url/', + '/the/path', + [ + 'image-dpi' => 100, + 'image-quality' => 50, + ], + $theBinary . ' ' . '--image-dpi 100 --image-quality 50 ' . escapeshellarg('http://the.url/') . ' ' . escapeshellarg('/the/path') + ], ); } @@ -756,7 +766,7 @@ public function dataForIsAssociativeArray() ), ); } - + public function testCleanupEmptyTemporaryFiles() { $generator = $this->getMock( @@ -772,20 +782,20 @@ public function testCleanupEmptyTemporaryFiles() $generator ->expects($this->once()) ->method('unlink'); - + $create = new \ReflectionMethod($generator, 'createTemporaryFile'); $create->setAccessible(true); $create->invoke($generator, null, null); - + $files = new \ReflectionProperty($generator, 'temporaryFiles'); $files->setAccessible(true); $this->assertCount(1, $files->getValue($generator)); - + $remove = new \ReflectionMethod($generator, 'removeTemporaryFiles'); $remove->setAccessible(true); $remove->invoke($generator); } - + public function testleanupTemporaryFiles() { $generator = $this->getMock( @@ -801,15 +811,15 @@ public function testleanupTemporaryFiles() $generator ->expects($this->once()) ->method('unlink'); - + $create = new \ReflectionMethod($generator, 'createTemporaryFile'); $create->setAccessible(true); $create->invoke($generator, '', 'html'); - + $files = new \ReflectionProperty($generator, 'temporaryFiles'); $files->setAccessible(true); $this->assertCount(1, $files->getValue($generator)); - + $remove = new \ReflectionMethod($generator, 'removeTemporaryFiles'); $remove->setAccessible(true); $remove->invoke($generator);