From 51e9ef0349ebd66e8161c2c11b7b3d19972f534a Mon Sep 17 00:00:00 2001 From: Oliver Vogel Date: Sun, 11 May 2014 16:38:47 +0200 Subject: [PATCH] added checksumCommand --- .../Image/Commands/ChecksumCommand.php | 23 ++++++++++++++++ tests/ChecksumCommandTest.php | 26 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/Intervention/Image/Commands/ChecksumCommand.php create mode 100644 tests/ChecksumCommandTest.php diff --git a/src/Intervention/Image/Commands/ChecksumCommand.php b/src/Intervention/Image/Commands/ChecksumCommand.php new file mode 100644 index 00000000..ef2f1c89 --- /dev/null +++ b/src/Intervention/Image/Commands/ChecksumCommand.php @@ -0,0 +1,23 @@ +getSize(); + + for ($x=0; $x <= ($size->width-1); $x++) { + for ($y=0; $y <= ($size->height-1); $y++) { + $colors[] = $image->pickColor($x, $y, 'array'); + } + } + + $this->setOutput(md5(serialize($colors))); + + return true; + } +} diff --git a/tests/ChecksumCommandTest.php b/tests/ChecksumCommandTest.php new file mode 100644 index 00000000..e71151ba --- /dev/null +++ b/tests/ChecksumCommandTest.php @@ -0,0 +1,26 @@ +shouldReceive('getSize')->once()->andReturn($size); + $image->shouldReceive('pickColor')->times(9)->andReturn($color); + $command = new ChecksumCommand(array()); + $result = $command->execute($image); + $this->assertTrue($result); + $this->assertTrue($command->hasOutput()); + $this->assertEquals('ec9cbdb71be04e26b4a89333f20c273b', $command->getOutput()); + } +}