Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
// Call Image_TextTest::main() if this source file is executed directly.
3
if (!defined("PHPUnit_MAIN_METHOD")) {
4
    define("PHPUnit_MAIN_METHOD", "imageisthesameTest::main");
5
}
6
 
7
require_once "PHPUnit/Framework/TestCase.php";
8
require_once "PHPUnit/Framework/TestSuite.php";
9
 
10
require_once 'imageisthesame.php';
11
 
12
/**
13
 * Test class for Image_Text.
14
 * Generated by PHPUnit_Util_Skeleton on 2007-04-15 at 15:14:46.
15
 */
16
class imageisthesameTest extends PHPUnit_Framework_TestCase {
17
    /**
18
     * Runs the test methods of this class.
19
     *
20
     * @access public
21
     * @static
22
     */
23
    public static function main() {
24
        require_once "PHPUnit/TextUI/TestRunner.php";
25
 
26
        $suite  = new PHPUnit_Framework_TestSuite("imageisthesameTest");
27
        $result = PHPUnit_TextUI_TestRunner::run($suite);
28
    }
29
 
30
    /**
31
     * Sets up the fixture, for example, open a network connection.
32
     * This method is called before a test is executed.
33
     *
34
     * @access protected
35
     */
36
    protected function setUp() {
37
        $this->dir = dirname(__FILE__) . '/testimages/';
38
    }
39
 
40
    /**
41
     * Tears down the fixture, for example, close a network connection.
42
     * This method is called after a test is executed.
43
     *
44
     * @access protected
45
     */
46
    protected function tearDown() {
47
    }
48
 
49
    /**
50
     *
51
     */
52
    public function testSame() {
53
        //same image
54
        $this->assertTrue(imageisthesame(
55
            $this->dir . '10x5-red.png',
56
            $this->dir . '10x5-red.png'
57
        ));
58
        //same image
59
        $this->assertTrue(imageisthesame(
60
            imagecreatefrompng($this->dir . '10x5-red.png'),
61
            imagecreatefrompng($this->dir . '10x5-red.png')
62
        ));
63
    }
64
 
65
 
66
    public function testSize() {
67
        //wrong size
68
        $this->assertFalse(imageisthesame(
69
            $this->dir . '10x5-red.png',
70
            $this->dir . '5x10-red.png'
71
        ));
72
        $this->assertFalse(imageisthesame(
73
            imagecreatefrompng($this->dir . '10x5-red.png'),
74
            imagecreatefrompng($this->dir . '5x10-red.png')
75
        ));
76
    }
77
 
78
    public function testWrongColor() {
79
        //wrong color
80
        $this->assertFalse(imageisthesame(
81
            $this->dir . '10x5-red.png',
82
            $this->dir . '10x5-white.png'
83
        ));
84
    }
85
 
86
    public function testIndexed() {
87
        //same, but indexed
88
        $this->assertTrue(imageisthesame(
89
            $this->dir . '10x5-white.png',
90
            $this->dir . '10x5-white-index.png'
91
        ));
92
 
93
        //wrong color, but indexed
94
        $this->assertFalse(imageisthesame(
95
            $this->dir . '10x5-red.png',
96
            $this->dir . '10x5-white-index.png'
97
        ));
98
    }
99
 
100
    public function testGreyscale() {
101
       //same, but greyscale
102
        $this->assertTrue(imageisthesame(
103
            $this->dir . '10x5-white.png',
104
            $this->dir . '10x5-white-grey.png'
105
        ));
106
        //wrong color, greyscale
107
        $this->assertFalse(imageisthesame(
108
            $this->dir . '10x5-red.png',
109
            $this->dir . '10x5-white-grey.png'
110
        ));
111
    }
112
 
113
    public function testImagetypes() {
114
        //same color, different image type, one color
115
        $this->assertTrue(imageisthesame(
116
            $this->dir . '5x10-red-254.jpg',
117
            $this->dir . '5x10-red-254.png'
118
        ));
119
        //same color, different type, gradient
120
        $this->assertTrue(imageisthesame(
121
            $this->dir . '5x10-gradient.jpg',
122
            $this->dir . '5x10-gradient.png'
123
        ));
124
    }
125
 
126
}
127
 
128
// Call Image_TextTest::main() if this source file is executed directly.
129
if (PHPUnit_MAIN_METHOD == "imageisthesameTest::main") {
130
    imageisthesameTest::main();
131
}
132
?>