File: imageisthesameTest.php

package info (click to toggle)
php-image-text 0.6.0beta-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 248 kB
  • ctags: 257
  • sloc: php: 739; xml: 193; makefile: 43; sh: 4
file content (132 lines) | stat: -rw-r--r-- 3,823 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
// Call Image_TextTest::main() if this source file is executed directly.
if (!defined("PHPUnit_MAIN_METHOD")) {
    define("PHPUnit_MAIN_METHOD", "imageisthesameTest::main");
}

require_once "PHPUnit/Framework/TestCase.php";
require_once "PHPUnit/Framework/TestSuite.php";

require_once 'imageisthesame.php';

/**
 * Test class for Image_Text.
 * Generated by PHPUnit_Util_Skeleton on 2007-04-15 at 15:14:46.
 */
class imageisthesameTest extends PHPUnit_Framework_TestCase {
    /**
     * Runs the test methods of this class.
     *
     * @access public
     * @static
     */
    public static function main() {
        require_once "PHPUnit/TextUI/TestRunner.php";

        $suite  = new PHPUnit_Framework_TestSuite("imageisthesameTest");
        $result = PHPUnit_TextUI_TestRunner::run($suite);
    }

    /**
     * Sets up the fixture, for example, open a network connection.
     * This method is called before a test is executed.
     *
     * @access protected
     */
    protected function setUp() {
        $this->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();
}
?>