Skip to content

Commit

Permalink
Adapted tests to last updates, and remove useless ones
Browse files Browse the repository at this point in the history
  • Loading branch information
Pierstoval committed Feb 2, 2017
1 parent c9ae69a commit 9d49b5c
Show file tree
Hide file tree
Showing 3 changed files with 757 additions and 778 deletions.
21 changes: 11 additions & 10 deletions Tests/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public function testWrongConvertDirs($path, $expectedMessage, $expectedException
$exception = '';
$exceptionClass = '';

$ds = DIRECTORY_SEPARATOR;
$path = str_replace(array('/', '\\'), array($ds, $ds), $path);
$expectedMessage = str_replace(array('/', '\\'), array($ds, $ds), $expectedMessage);
$path = str_replace('\\', '/', $path);
$expectedMessage = str_replace('\\', '/', $expectedMessage);
try {
new Command($path);
} catch (\Exception $e) {
Expand All @@ -39,9 +38,8 @@ public function testWrongConvertDirs($path, $expectedMessage, $expectedException
public function provideWrongConvertDirs()
{
return array(
array('/this/is/a/dummy/dir', 'The specified path (/this/is/a/dummy/dir/) is not a directory', 'InvalidArgumentException'),
array('./', 'The specified path (./) does not seem to contain ImageMagick binaries, or it is not readable', 'InvalidArgumentException'),
array(TEST_RESOURCES_DIR.'/', 'ImageMagick does not seem to work well, the test command resulted in an error', 'InvalidArgumentException'),
array('/this/is/a/dummy/dir', 'The specified path (/this/is/a/dummy/dir) is not a directory', 'InvalidArgumentException'),
array('./', 'The specified path (.) does not seem to contain ImageMagick binaries, or it is not readable', 'InvalidArgumentException'),
);
}

Expand All @@ -60,6 +58,8 @@ public function testResizeImage()
->run()
;

$this->assertFalse($response->hasFailed(), "Errors when testing:\n".$response->getProcess()->getOutput()."\t".$response->getProcess()->getErrorOutput());

$this->assertFileExists($this->resourcesDir . '/outputs/moon.jpg');

$this->assertFalse($response->hasFailed());
Expand All @@ -81,8 +81,7 @@ public function testConvertIdentifyImage($imageToIdentify, $expectedFormat, $exp

$this->assertFalse($response->hasFailed());

$content = $response->getContent();
$content = implode("\n", $content);
$content = $response->getOutput();

$this->assertContains(sprintf(
'%s %s %s %s %s',
Expand Down Expand Up @@ -113,7 +112,7 @@ public function testMogrifyResizeImage()
unlink($imageOutput);
}

file_put_contents($imageOutput, file_get_contents($sourceImage));
copy($sourceImage, $imageOutput);

if (!file_exists($imageOutput)) {
throw new \RuntimeException('File could not be copied from resources dir to output dir.');
Expand Down Expand Up @@ -151,12 +150,14 @@ public function testCommandString($source, $output, $geometry, $quality)
->getCommand()
;

$expected = ' "'.$command->getExecutable('convert').'"'.
$expected = ' '.$command->getExecutable('convert').
' "'.$source.'"'.
' -thumbnail "'.$geometry.'"'.
' -quality '.$quality.
' "'.$output.'" ';

$expected = str_replace('\\', '/', $expected);

$this->assertEquals($expected, $commandString);
}

Expand Down
Loading

0 comments on commit 9d49b5c

Please sign in to comment.