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", "Image_TextTest::main");
5
}
6
 
7
require_once "PHPUnit/Framework/TestCase.php";
8
require_once "PHPUnit/Framework/TestSuite.php";
9
 
10
require_once 'Image/Text.php';
11
require_once dirname(__FILE__) . '/imageisthesame.php';
12
 
13
/**
14
 * Test class for Image_Text.
15
 * Generated by PHPUnit_Util_Skeleton on 2007-04-15 at 15:14:46.
16
 */
17
class Image_TextTest extends PHPUnit_Framework_TestCase {
18
    /**
19
     * Runs the test methods of this class.
20
     *
21
     * @access public
22
     * @static
23
     */
24
    public static function main() {
25
        require_once "PHPUnit/TextUI/TestRunner.php";
26
 
27
        $suite  = new PHPUnit_Framework_TestSuite("Image_TextTest");
28
        $result = PHPUnit_TextUI_TestRunner::run($suite);
29
    }
30
 
31
    /**
32
     * Sets up the fixture, for example, open a network connection.
33
     * This method is called before a test is executed.
34
     *
35
     * @access protected
36
     */
37
    protected function setUp() {
38
        $this->dir = dirname(__FILE__) . '/testimages/';
39
    }
40
 
41
    protected function initInstance($text)
42
    {
43
        $i = new Image_Text($text);
44
        $i->set(array(
45
            'font_path' => dirname(__FILE__) . '/',
46
            'font_file' => 'Vera.ttf',
47
            'font_size' => 12,
48
            'canvas'    => array('width'=> 200,'height'=> 100),
49
            'width'     => 200,
50
            'height'    => 200,
51
            'color'     => array('#FFFFFF')
52
        ));
53
        return $i;
54
    }
55
 
56
    /**
57
     * Tears down the fixture, for example, close a network connection.
58
     * This method is called after a test is executed.
59
     *
60
     * @access protected
61
     */
62
    protected function tearDown() {
63
    }
64
 
65
    /**
66
     *
67
     */
68
    public function testConstruct() {
69
return;
70
        $i = $this->initInstance('test');
71
        $this->assertType('Image_Text', $i);
72
        $this->assertTrue($i->init());
73
        $this->assertTrue($i->render());
74
        $this->assertTrue(imageisthesame(
75
            $this->dir . 'test-construct.png',
76
            $i->getImg()
77
        ));
78
 
79
        $i = $this->initInstance('text');
80
        $this->assertType('Image_Text', $i);
81
        $this->assertTrue($i->init());
82
        $this->assertTrue($i->render());
83
        $this->assertFalse(imageisthesame(
84
            $this->dir . 'test-construct.png',
85
            $i->getImg()
86
        ));
87
    }
88
 
89
    public function testBackgroundColor() {
90
        //default background is black
91
        $i = $this->initInstance('test');
92
        $this->assertType('Image_Text', $i);
93
        $this->assertTrue($i->init());
94
        $this->assertTrue($i->render());
95
        $this->assertTrue(imageisthesame(
96
            $this->dir . 'test-construct.png',
97
            $i->getImg()
98
        ));
99
 
100
        //red background
101
        $i = $this->initInstance('text');
102
        $this->assertType('Image_Text', $i);
103
        $i->set(array('background_color' => '#FF0000'));
104
        $this->assertTrue($i->init());
105
        $this->assertTrue($i->render());
106
        $this->assertTrue(imageisthesame(
107
            $this->dir . 'test-background-red.png',
108
            $i->getImg()
109
        ));
110
 
111
        //transparent background
112
        $i = $this->initInstance('text');
113
        $this->assertType('Image_Text', $i);
114
        $i->set(array('background_color' => null));
115
        $this->assertTrue($i->init());
116
        $this->assertTrue($i->render());
117
        $this->assertTrue(imageisthesame(
118
            $this->dir . 'test-background-transparent.png',
119
            $i->getImg()
120
        ));
121
    }
122
 
123
    /**
124
     * @todo Implement testSet().
125
     */
126
    public function testSet() {
127
        // Remove the following line when you implement this test.
128
        $this->markTestIncomplete(
129
          "This test has not been implemented yet."
130
        );
131
    }
132
 
133
    /**
134
     * @todo Implement testSetColors().
135
     */
136
    public function testSetColors() {
137
        // Remove the following line when you implement this test.
138
        $this->markTestIncomplete(
139
          "This test has not been implemented yet."
140
        );
141
    }
142
 
143
    /**
144
     * @todo Implement testSetColor().
145
     */
146
    public function testSetColor() {
147
        // Remove the following line when you implement this test.
148
        $this->markTestIncomplete(
149
          "This test has not been implemented yet."
150
        );
151
    }
152
 
153
    /**
154
     * @todo Implement testInit().
155
     */
156
    public function testInit() {
157
        // Remove the following line when you implement this test.
158
        $this->markTestIncomplete(
159
          "This test has not been implemented yet."
160
        );
161
    }
162
 
163
    /**
164
     * @todo Implement testAutoMeasurize().
165
     */
166
    public function testAutoMeasurize() {
167
        // Remove the following line when you implement this test.
168
        $this->markTestIncomplete(
169
          "This test has not been implemented yet."
170
        );
171
    }
172
 
173
    /**
174
     * @todo Implement testMeasurize().
175
     */
176
    public function testMeasurize() {
177
        // Remove the following line when you implement this test.
178
        $this->markTestIncomplete(
179
          "This test has not been implemented yet."
180
        );
181
    }
182
 
183
    /**
184
     * @todo Implement testRender().
185
     */
186
    public function testRender() {
187
        // Remove the following line when you implement this test.
188
        $this->markTestIncomplete(
189
          "This test has not been implemented yet."
190
        );
191
    }
192
 
193
    /**
194
     * @todo Implement testGetImg().
195
     */
196
    public function testGetImg() {
197
        // Remove the following line when you implement this test.
198
        $this->markTestIncomplete(
199
          "This test has not been implemented yet."
200
        );
201
    }
202
 
203
    /**
204
     * @todo Implement testDisplay().
205
     */
206
    public function testDisplay() {
207
        // Remove the following line when you implement this test.
208
        $this->markTestIncomplete(
209
          "This test has not been implemented yet."
210
        );
211
    }
212
 
213
    /**
214
     * @todo Implement testSave().
215
     */
216
    public function testSave() {
217
        // Remove the following line when you implement this test.
218
        $this->markTestIncomplete(
219
          "This test has not been implemented yet."
220
        );
221
    }
222
 
223
    /**
224
     * @todo Implement test_getOffset().
225
     */
226
    public function test_getOffset() {
227
        // Remove the following line when you implement this test.
228
        $this->markTestIncomplete(
229
          "This test has not been implemented yet."
230
        );
231
    }
232
 
233
    /**
234
     *
235
     */
236
    public function test_convertString2RGB() {
237
        $this->assertEquals(
238
            array('r'=> 255,'g'=> 255,'b'=> 255,'a'=> 0),
239
            Image_Text::_convertString2RGB('#FFFFFF')
240
        );
241
        $this->assertEquals(
242
            array('r'=> 255,'g'=> 255,'b'=> 255,'a'=> 0),
243
            Image_Text::_convertString2RGB('#00FFFFFF')
244
        );
245
        $this->assertEquals(
246
            array('r'=> 0,'g'=> 0,'b'=> 0,'a'=> 0),
247
            Image_Text::_convertString2RGB('#000000')
248
        );
249
        $this->assertEquals(
250
            array('r'=> 0,'g'=> 0,'b'=> 0,'a'=> 255),
251
            Image_Text::_convertString2RGB('#FF000000')
252
        );
253
    }
254
 
255
    /**
256
     * @todo Implement test_processText().
257
     */
258
    public function test_processText() {
259
        // Remove the following line when you implement this test.
260
        $this->markTestIncomplete(
261
          "This test has not been implemented yet."
262
        );
263
    }
264
}
265
 
266
// Call Image_TextTest::main() if this source file is executed directly.
267
if (PHPUnit_MAIN_METHOD == "Image_TextTest::main") {
268
    Image_TextTest::main();
269
}
270
?>