summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsybio <clement.guillemain@gmail.com>2013-06-18 10:52:52 +0200
committersybio <clement.guillemain@gmail.com>2013-06-18 10:52:52 +0200
commit0a7ed036f2638da185831891d518bbc4206eb82e (patch)
tree704c3147739d617354206d9a4db1120a64898a13
parentb4e6299d58b79cd1b99f881379fa3c5f74ab5f93 (diff)
downloadImageWorkshop-0a7ed036f2638da185831891d518bbc4206eb82e.zip
ImageWorkshop-0a7ed036f2638da185831891d518bbc4206eb82e.tar.gz
ImageWorkshop-0a7ed036f2638da185831891d518bbc4206eb82e.tar.bz2
Add unit tests for rotate method
-rw-r--r--src/PHPImageWorkshop/ImageWorkshop.php2
-rw-r--r--tests/Core/ImageWorkshopLayerTest.php48
2 files changed, 49 insertions, 1 deletions
diff --git a/src/PHPImageWorkshop/ImageWorkshop.php b/src/PHPImageWorkshop/ImageWorkshop.php
index 02b1ed1..6af60e1 100644
--- a/src/PHPImageWorkshop/ImageWorkshop.php
+++ b/src/PHPImageWorkshop/ImageWorkshop.php
@@ -15,7 +15,7 @@ use PHPImageWorkshop\Exception\ImageWorkshopException as ImageWorkshopException;
*
* Use this class as a factory to initialize ImageWorkshop layers
*
- * @version 2.0.2
+ * @version 2.0.3
* @link http://phpimageworkshop.com
* @author Sybio (Clément Guillemain / @Sybio01)
* @license http://en.wikipedia.org/wiki/MIT_License
diff --git a/tests/Core/ImageWorkshopLayerTest.php b/tests/Core/ImageWorkshopLayerTest.php
index 98de6f2..b75d1cc 100644
--- a/tests/Core/ImageWorkshopLayerTest.php
+++ b/tests/Core/ImageWorkshopLayerTest.php
@@ -1205,6 +1205,54 @@ class ImageWorkshopLayerTest extends \PHPUnit_Framework_TestCase
$this->assertTrue($layer->getHeight() == 75, 'Expect $layer to have a height of 75px');
}
+ /**
+ * Test rotate
+ */
+ public function testRotate()
+ {
+ $layer = $this->initializeLayer(1);
+
+ $layer->rotate(0);
+ $this->assertTrue($layer->getWidth() == 100, 'Expect $layer to have a width of 100px');
+ $this->assertTrue($layer->getHeight() == 75, 'Expect $layer to have a height of 75px');
+
+ $layer = $this->initializeLayer(1);
+
+ $layer->rotate(90);
+ $this->assertTrue($layer->getWidth() == 75, 'Expect $layer to have a width of 75px');
+ $this->assertTrue($layer->getHeight() == 100, 'Expect $layer to have a height of 100px');
+
+ $layer = $this->initializeLayer(1);
+
+ $layer->rotate(-90);
+ $this->assertTrue($layer->getWidth() == 75, 'Expect $layer to have a width of 75px');
+ $this->assertTrue($layer->getHeight() == 100, 'Expect $layer to have a height of 100px');
+
+ $layer = $this->initializeLayer(1);
+
+ $layer->rotate(180);
+ $this->assertTrue($layer->getWidth() == 100, 'Expect $layer to have a width of 100px');
+ $this->assertTrue($layer->getHeight() == 75, 'Expect $layer to have a height of 75px');
+
+ $layer = $this->initializeLayer(1);
+
+ $layer->rotate(40);
+ $this->assertTrue($layer->getWidth() <= 126 && $layer->getWidth() >= 124, 'Expect $layer to have a width around 125px');
+ $this->assertTrue($layer->getHeight() <= 124 && $layer->getHeight() >= 122, 'Expect $layer to have a height around 123px');
+
+ $layer = $this->initializeLayer(1);
+
+ $layer->rotate(20);
+ $this->assertTrue($layer->getWidth() <= 121 && $layer->getWidth() >= 119, 'Expect $layer to have a width around 120px');
+ $this->assertTrue($layer->getHeight() <= 107 && $layer->getHeight() >= 105, 'Expect $layer to have a height around 106px');
+
+ $layer = $this->initializeLayer(1);
+
+ $layer->rotate(-20);
+ $this->assertTrue($layer->getWidth() <= 121 && $layer->getWidth() >= 119, 'Expect $layer to have a width around 120px');
+ $this->assertTrue($layer->getHeight() <= 107 && $layer->getHeight() >= 105, 'Expect $layer to have a height around 106px');
+ }
+
// Internals
// ===================================================================================