diff options
author | sybio <clement.guillemain@gmail.com> | 2012-05-04 22:01:51 +0200 |
---|---|---|
committer | sybio <clement.guillemain@gmail.com> | 2012-05-04 22:01:51 +0200 |
commit | a511b89b54c720d49622149d80da721d2acea7af (patch) | |
tree | a069b20a35839573694e2b9112d41f7ae4ce4ca0 /tests | |
parent | 286ae1ad6f73b5107755395cd52260264cbd9d50 (diff) | |
download | ImageWorkshop-a511b89b54c720d49622149d80da721d2acea7af.zip ImageWorkshop-a511b89b54c720d49622149d80da721d2acea7af.tar.gz ImageWorkshop-a511b89b54c720d49622149d80da721d2acea7af.tar.bz2 |
Added some tests
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ImageWorkshopTest.php | 234 |
1 files changed, 207 insertions, 27 deletions
diff --git a/tests/ImageWorkshopTest.php b/tests/ImageWorkshopTest.php index 9dbe9d2..6a33a8f 100644 --- a/tests/ImageWorkshopTest.php +++ b/tests/ImageWorkshopTest.php @@ -5,122 +5,302 @@ class ImageWorkshopTest extends PHPUnit_Framework_TestCase {
/**
* @todo
+ *
+ * Test pasteImage
+ *
*/
- public function testPasteImage()
+ /*public function testPasteImage()
{
$this->assertTrue(false);
- }
+ }*/
/**
* @todo
+ *
+ * Test addLayer
+ *
*/
- public function testAddLayer()
+ /*public function testAddLayer()
{
$this->assertTrue(false);
- }
+ }*/
/**
* @todo
+ *
+ * Test mergeDown
+ *
*/
- public function testMergeDown()
+ /*public function testMergeDown()
{
+ $layer = new ImageWorkshop(array(
+ "width" => 300,
+ "height" => 200,
+ ));
+
$this->assertTrue(false);
- }
+ }*/
/**
- * @todo
+ * Test mergeAll
*/
public function testMergeAll()
{
- $this->assertTrue(false);
+ $layer = $this->initializeLayer(2);
+
+ $layer->mergeAll();
+
+ $layerPositions = $layer->getLayersPositions();
+ $layersLevels = $layer->getLayersLevels();
+ $highestLayerLevel = $layer->getHighestLayerLevel();
+ $lastLayerId = $layer->getLastLayerId();
+
+ $array = array();
+
+ $this->assertEquals($layerPositions, $array, 'Expect $layerPositions to be an empty array');
+
+ $this->assertEquals($layerPositions, $array, 'Expect $layersLevels to be an empty array');
+
+ $this->assertTrue($highestLayerLevel === 0, 'Expect $highestLayerLevel to be 0');
+
+ $this->assertTrue($lastLayerId === 0, 'Expect $lastLayerId to be 0');
}
/**
- * @todo
+ * test moveTop
*/
public function testMoveTop()
{
- $this->assertTrue(false);
+ $layer = $this->initializeLayer(2);
+
+ $layer->moveTop(2);
+
+ $layersLevels = $layer->getLayersLevels();
+
+ $array = array(
+ 1 => 1,
+ 2 => 3,
+ 3 => 4,
+ 4 => 2,
+ );
+
+ $this->assertTrue($layersLevels == $array, 'Expect $layersLevels to be the array $array');
}
/**
- * @todo
+ * Test moveBottom
*/
public function testMoveBottom()
{
- $this->assertTrue(false);
+ $layer = $this->initializeLayer(2);
+
+ $layer->moveBottom(3);
+
+ $layersLevels = $layer->getLayersLevels();
+
+ $array = array(
+ 1 => 3,
+ 2 => 1,
+ 3 => 2,
+ 4 => 4,
+ );
+
+ $this->assertTrue($layersLevels == $array, 'Expect $layersLevels to be the array $array');
}
/**
* @todo
+ *
+ * Test moveTo
+ *
*/
- public function testMoveTo()
+ /*public function testMoveTo()
{
$this->assertTrue(false);
- }
+ }*/
/**
* @todo
+ *
+ * Test moveUp
+ *
*/
public function testMoveUp()
{
- $this->assertTrue(false);
+ // Test moveUp on a sublayer not positionned at the highest level
+
+ $layer = $this->initializeLayer(2);
+
+ $layer->moveUp(2);
+
+ $layersLevels = $layer->getLayersLevels();
+
+ $array = array(
+ 1 => 1,
+ 2 => 3,
+ 3 => 2,
+ 4 => 4,
+ );
+
+ $this->assertTrue($layersLevels == $array, 'Expect $layersLevels to be the array $array');
+
+ // Test moveUp on a the sublayer at the highest level
+
+ $layer = $this->initializeLayer(2);
+
+ $layer->moveUp(4);
+
+ $layersLevels = $layer->getLayersLevels();
+
+ $array = array(
+ 1 => 1,
+ 2 => 2,
+ 3 => 3,
+ 4 => 4,
+ );
+
+ $this->assertTrue($layersLevels == $array, 'Expect $layersLevels to be the array $array');
}
/**
* @todo
+ *
+ * Test moveDown
+ *
*/
public function testMoveDown()
{
- $this->assertTrue(false);
+ // Test moveBottom on a sublayer not positionned at the lowest level
+
+ $layer = $this->initializeLayer(2);
+
+ $layer->moveBottom(3);
+
+ $layersLevels = $layer->getLayersLevels();
+
+ $array = array(
+ 1 => 1,
+ 2 => 3,
+ 3 => 2,
+ 4 => 4,
+ );
+
+ $this->assertTrue($layersLevels == $array, 'Expect $layersLevels to be the array $array');
+
+ // Test moveBottom on a sublayer at the lowest level
+
+ $layer = $this->initializeLayer(2);
+
+ $layer->moveBottom(1);
+
+ $layersLevels = $layer->getLayersLevels();
+
+ $array = array(
+ 1 => 1,
+ 2 => 2,
+ 3 => 3,
+ 4 => 4,
+ );
+
+ $this->assertTrue($layersLevels == $array, 'Expect $layersLevels to be the array $array');
}
/**
* @todo
+ *
+ * Test remove
+ *
*/
- public function testRemove()
+ /*public function testRemove()
{
$this->assertTrue(false);
- }
+ }*/
/**
* @todo
+ *
+ * Test getLayerLevel
+ *
*/
- public function testGetLayerLevel()
+ /*public function testGetLayerLevel()
{
$this->assertTrue(false);
- }
+ }*/
/**
- * @todo
+ * Test isLayerInIndex
*/
public function testIsLayerInIndex()
{
- $this->assertTrue(false);
+ $layer = $this->initializeLayer(2);
+
+ $this->assertTrue($layer->isLayerInIndex(3) === true, 'Layer of id 3 must be in the stack');
+
+ $this->assertTrue($layer->isLayerInIndex(5) === false, 'Layer of id 5 would not exist in the stack');
}
/**
* @todo
+ *
+ * Test generateImage
+ *
*/
- public function testGenerateImage()
+ /*public function testGenerateImage()
{
$this->assertTrue(false);
- }
+ }*/
/**
* @todo
+ *
+ * Test resizeByPixel
+ *
*/
- public function testResizeByPixel()
+ /*public function testResizeByPixel()
{
$this->assertTrue(false);
- }
+ }*/
/**
* @todo
+ *
+ * Test resizeByPourcent
+ *
*/
- public function testResizeByPourcent()
+ /*public function testResizeByPourcent()
{
$this->assertTrue(false);
+ }*/
+
+ /**
+ * Initialize a layer
+ *
+ * @param integer $method
+ */
+ protected function initializeLayer($method = 1)
+ {
+ $layer = new ImageWorkshop(array(
+ "width" => 100,
+ "height" => 75,
+ ));
+
+ switch ($method) {
+
+ case 1:
+
+ ;
+
+ case 2: // Add 4 sublayers in $layer stack
+
+ $layer->addLayer(1, $layer);
+ $layer->addLayer(2, $layer);
+ $layer->addLayer(3, $layer);
+ $layer->addLayer(4, $layer);
+
+ ;
+ }
+
+ return $layer;
}
}
?>
\ No newline at end of file |