forked from Intervention/image
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRectangleShapeTest.php
54 lines (48 loc) · 2.02 KB
/
RectangleShapeTest.php
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
<?php
use Intervention\Image\Gd\Shapes\RectangleShape as RectangleGd;
use Intervention\Image\Imagick\Shapes\RectangleShape as RectangleImagick;
use PHPUnit\Framework\TestCase;
class RectangleShapeTest extends TestCase
{
public function tearDown()
{
Mockery::close();
}
public function testConstructor()
{
// gd
$rectangle = new RectangleGd(10, 15, 100, 150);
$this->assertInstanceOf('Intervention\Image\Gd\Shapes\RectangleShape', $rectangle);
$this->assertEquals(10, $rectangle->x1);
$this->assertEquals(15, $rectangle->y1);
$this->assertEquals(100, $rectangle->x2);
$this->assertEquals(150, $rectangle->y2);
// imagick
$rectangle = new RectangleImagick(10, 15, 100, 150);
$this->assertInstanceOf('Intervention\Image\Imagick\Shapes\RectangleShape', $rectangle);
$this->assertEquals(10, $rectangle->x1);
$this->assertEquals(15, $rectangle->y1);
$this->assertEquals(100, $rectangle->x2);
$this->assertEquals(150, $rectangle->y2);
}
public function testApplyToImage()
{
// gd
$core = imagecreatetruecolor(300, 200);
$image = Mockery::mock('\Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($core);
$rectangle = new RectangleGd(10, 15, 100, 150);
$result = $rectangle->applyToImage($image, 10, 20);
$this->assertInstanceOf('Intervention\Image\Gd\Shapes\RectangleShape', $rectangle);
$this->assertTrue($result);
// imagick
$core = Mockery::mock('\Imagick');
$core->shouldReceive('drawimage')->once();
$image = Mockery::mock('\Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($core);
$rectangle = new RectangleImagick(10, 15, 100, 150);
$result = $rectangle->applyToImage($image, 10, 20);
$this->assertInstanceOf('Intervention\Image\Imagick\Shapes\RectangleShape', $rectangle);
$this->assertTrue($result);
}
}