Adding tests for securing private variable inclussion on templates.
[akelos.git] / test / unit / lib / AkImage.php
blobee33e9bc727fe3be38492f52fa4e375f40e39d0d
1 <?php
3 require_once(dirname(__FILE__).'/../../fixtures/config/config.php');
5 require_once(AK_LIB_DIR.DS.'AkImage.php');
7 class Test_of_AkImage extends AkUnitTest
8 {
9 function setUp()
11 $this->image_path = AK_TEST_DIR.DS.'fixtures'.DS.'public'.DS.'images'.DS.'akelos_framework_logo.png';
13 function test_image_save_as()
15 $PngImage = new AkImage($this->image_path);
16 $this->assertEqual($PngImage->getExtension(), 'png');
18 $PngImage->save($this->image_path.'.jpg');
19 $JpgImage = new AkImage($this->image_path.'.jpg');
20 $this->assertEqual($JpgImage->getExtension(), 'jpg');
22 $PngImage = new AkImage($this->image_path);
23 $PngImage->save($this->image_path.'.gif');
24 $GifImage = new AkImage($this->image_path.'.gif');
25 $this->assertEqual($GifImage->getExtension(), 'gif');
28 function test_image_resize()
30 $Image = new AkImage();
31 $Image->load($this->image_path);
33 $this->assertEqual($Image->getWidth(), 170);
34 $this->assertEqual($Image->getHeight(), 75);
36 $Image->transform('resize',array('size'=>'50x'));
37 $Image->save($this->image_path.'_50x22.jpg');
39 $Image = new AkImage($this->image_path.'_50x22.jpg');
40 $this->assertEqual($Image->getWidth(), 50);
41 $this->assertEqual($Image->getHeight(), 22);
44 $Image = new AkImage($this->image_path);
45 $Image->transform('resize',array('size'=>'50%'));
46 $Image->save($this->image_path.'_85x37.png');
48 $Image = new AkImage($this->image_path.'_85x37.png');
49 $this->assertEqual($Image->getWidth(), 85);
50 $this->assertEqual($Image->getHeight(), 37);
53 $Image = new AkImage($this->image_path);
54 $Image->transform('resize', array('mode'=>'force','size'=>'300x300'));
55 $Image->save($this->image_path.'_300x300.png');
57 $Image = new AkImage($this->image_path.'_300x300.png');
58 $this->assertEqual($Image->getWidth(), 300);
59 $this->assertEqual($Image->getHeight(), 300);
62 $Image = new AkImage($this->image_path);
63 $Image->transform('resize', array('mode'=>'expand','size'=>'x300'));
64 $Image->save($this->image_path.'_x300.png');
66 $Image = new AkImage($this->image_path.'_x300.png');
67 $this->assertEqual($Image->getWidth(), 680);
68 $this->assertEqual($Image->getHeight(), 300);
72 $Image = new AkImage($this->image_path);
73 $Image->transform('resize', array('mode'=>'expand','size'=>'300x300'));
74 $Image->save($this->image_path.'_680x300.png');
76 $Image = new AkImage($this->image_path.'_680x300.png');
77 $this->assertEqual($Image->getWidth(), 680);
78 $this->assertEqual($Image->getHeight(), 300);
81 $Image = new AkImage($this->image_path);
82 $Image->transform('resize', array('mode'=>'expand','size'=>'200%'));
83 $Image->save($this->image_path.'_340x150.png');
85 $Image = new AkImage($this->image_path.'_340x150.png');
86 $this->assertEqual($Image->getWidth(), 340);
87 $this->assertEqual($Image->getHeight(), 150);
92 ak_test('Test_of_AkImage');