dir = dirname(__FILE__) . '/testimages/'; } /** * Tears down the fixture, for example, close a network connection. * This method is called after a test is executed. * * @access protected */ protected function tearDown() { } /** * */ public function testSame() { //same image $this->assertTrue(imageisthesame( $this->dir . '10x5-red.png', $this->dir . '10x5-red.png' )); //same image $this->assertTrue(imageisthesame( imagecreatefrompng($this->dir . '10x5-red.png'), imagecreatefrompng($this->dir . '10x5-red.png') )); } public function testSize() { //wrong size $this->assertFalse(imageisthesame( $this->dir . '10x5-red.png', $this->dir . '5x10-red.png' )); $this->assertFalse(imageisthesame( imagecreatefrompng($this->dir . '10x5-red.png'), imagecreatefrompng($this->dir . '5x10-red.png') )); } public function testWrongColor() { //wrong color $this->assertFalse(imageisthesame( $this->dir . '10x5-red.png', $this->dir . '10x5-white.png' )); } public function testIndexed() { //same, but indexed $this->assertTrue(imageisthesame( $this->dir . '10x5-white.png', $this->dir . '10x5-white-index.png' )); //wrong color, but indexed $this->assertFalse(imageisthesame( $this->dir . '10x5-red.png', $this->dir . '10x5-white-index.png' )); } public function testGreyscale() { //same, but greyscale $this->assertTrue(imageisthesame( $this->dir . '10x5-white.png', $this->dir . '10x5-white-grey.png' )); //wrong color, greyscale $this->assertFalse(imageisthesame( $this->dir . '10x5-red.png', $this->dir . '10x5-white-grey.png' )); } public function testImagetypes() { //same color, different image type, one color $this->assertTrue(imageisthesame( $this->dir . '5x10-red-254.jpg', $this->dir . '5x10-red-254.png' )); //same color, different type, gradient $this->assertTrue(imageisthesame( $this->dir . '5x10-gradient.jpg', $this->dir . '5x10-gradient.png' )); } } // Call Image_TextTest::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "imageisthesameTest::main") { imageisthesameTest::main(); } ?>