Skip to content
Browse files

Add tests, Update Gmagick extension used for tests to version 1.1.0-RC3

  • Loading branch information...
1 parent b05a434 commit ff80412458b7214a3a257fa0c4f5e61f07600f3f @romainneutron romainneutron committed
View
6 Rakefile
@@ -61,9 +61,9 @@ task :test do
system "sudo apt-get install -y graphicsmagick libgraphicsmagick1-dev"
- system "wget http://pecl.php.net/get/gmagick-1.1.0RC2.tgz"
- system "tar -xzf gmagick-1.1.0RC2.tgz"
- system "sh -c \"cd gmagick-1.1.0RC2 && phpize && ./configure --with-gmagick=/usr/local && make && sudo make install\""
+ system "wget http://pecl.php.net/get/gmagick-1.1.0RC3.tgz"
+ system "tar -xzf gmagick-1.1.0RC3.tgz"
+ system "sh -c \"cd gmagick-1.1.0RC3 && phpize && ./configure --with-gmagick=/usr/local && make && sudo make install\""
end
ini_file = Hash[`php --ini`.split("\n").map {|l| l.split(/:\s+/)}]["Loaded Configuration File"]
View
9 lib/Imagine/Gmagick/Effects.php
@@ -29,7 +29,7 @@ public function __construct(\Gmagick $gmagick)
public function gamma($correction)
{
try {
- $this->gmagick->gammaimage($correction, \Gmagick::CHANNEL_ALL);
+ $this->gmagick->gammaimage($correction);
} catch (\GmagickException $e) {
throw new RuntimeException('Gamma correction failed');
}
@@ -42,8 +42,13 @@ public function gamma($correction)
*/
public function negative()
{
+ if (!method_exists($this->gmagick, 'negateimage')) {
+ throw new RuntimeException('Gmagick version 1.1.0 RC3 is required'
+ . ' for negative effect');
+ }
+
try {
- $this->gmagick->negateimage(true, \Gmagick::CHANNEL_ALL);
+ $this->gmagick->negateimage(false, \Gmagick::CHANNEL_ALL);
} catch (\GmagickException $e) {
throw new RuntimeException('Failed to negate image');
}
View
2 lib/Imagine/Imagick/Effects.php
@@ -42,7 +42,7 @@ public function gamma($correction)
public function negative()
{
try {
- $this->imagick->negateImage(true, \Imagick::CHANNEL_ALL);
+ $this->imagick->negateImage(false, \Imagick::CHANNEL_ALL);
} catch (\ImagickException $e) {
throw new RuntimeException('Failed to negate image');
}
View
7 tests/Imagine/Draw/AbstractDrawerTest.php
@@ -16,6 +16,7 @@
use Imagine\Image\Font;
use Imagine\Image\Point;
use Imagine\Image\Point\Center;
+use Imagine\Image\ImagineInterface;
use Imagine\Test\ImagineTestCase;
abstract class AbstractDrawerTest extends ImagineTestCase
@@ -174,7 +175,7 @@ public function testDrawText()
if (!$this->isFontTestSupported()) {
$this->markTestSkipped('This install does not support font tests');
}
-
+
$path = 'tests/Imagine/Fixtures/font/Arial.ttf';
$black = new Color('000');
$file36 = 'tests/Imagine/Fixtures/bulat36.png';
@@ -241,9 +242,9 @@ public function testDrawText()
}
/**
- * @return Imagine\Image\ImagineInterface
+ * @return ImagineInterface
*/
abstract protected function getImagine();
-
+
abstract protected function isFontTestSupported();
}
View
52 tests/Imagine/Effects/AbstractEffectsTest.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Imagine\Effects;
+
+use Imagine\Image\Box;
+use Imagine\Image\Color;
+use Imagine\Image\Point;
+use Imagine\Image\ImagineInterface;
+
+abstract class AbstractEffectsTest extends \PHPUnit_Framework_TestCase
+{
+
+ public function testNegate()
+ {
+ $imagine = $this->getImagine();
+
+ $image = $imagine->create(new Box(20, 20), new Color('ff0'));
+ $image->effects()
+ ->negative();
+
+ $this->assertEquals('#0000ff', (string) $image->getColorAt(new Point(10, 10)));
+
+ $image->effects()
+ ->negative();
+
+ $this->assertEquals('#ffff00', (string) $image->getColorAt(new Point(10, 10)));
+ }
+
+ public function testGamma()
+ {
+ $imagine = $this->getImagine();
+
+ $r = 20;
+ $g = 90;
+ $b = 240;
+
+ $image = $imagine->create(new Box(20, 20), new Color(array($r, $g, $b)));
+ $image->effects()
+ ->gamma(1.2);
+
+ $pixel = $image->getColorAt(new Point(10, 10));
+
+ $this->assertNotEquals($r, $pixel->getRed());
+ $this->assertNotEquals($g, $pixel->getGreen());
+ $this->assertNotEquals($b, $pixel->getBlue());
+ }
+
+ /**
+ * @return ImagineInterface
+ */
+ abstract protected function getImagine();
+}
View
31 tests/Imagine/Gd/EffectsTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of the Imagine package.
+ *
+ * (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Imagine\Gd;
+
+use Imagine\Effects\AbstractEffectsTest;
+
+class EffectsTest extends AbstractEffectsTest
+{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ if (!function_exists('gd_info')) {
+ $this->markTestSkipped('Gd not installed');
+ }
+ }
+
+ protected function getImagine()
+ {
+ return new Imagine();
+ }
+}
View
31 tests/Imagine/Gmagick/EffectsTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of the Imagine package.
+ *
+ * (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Imagine\Gmagick;
+
+use Imagine\Effects\AbstractEffectsTest;
+
+class EffectsTest extends AbstractEffectsTest
+{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ if (!class_exists('Gmagick')) {
+ $this->markTestSkipped('Gmagick is not installed');
+ }
+ }
+
+ protected function getImagine()
+ {
+ return new Imagine();
+ }
+}
View
31 tests/Imagine/Imagick/EffectsTest.php
@@ -0,0 +1,31 @@
+<?php
+
+/*
+ * This file is part of the Imagine package.
+ *
+ * (c) Bulat Shakirzyanov <mallluhuct@gmail.com>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Imagine\Imagick;
+
+use Imagine\Effects\AbstractEffectsTest;
+
+class EffectsTest extends AbstractEffectsTest
+{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ if (!class_exists('Imagick')) {
+ $this->markTestSkipped('Imagick is not installed');
+ }
+ }
+
+ protected function getImagine()
+ {
+ return new Imagine();
+ }
+}

0 comments on commit ff80412

Please sign in to comment.
Something went wrong with that request. Please try again.