forked from Intervention/image
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFillCommandTest.php
More file actions
92 lines (84 loc) · 3.86 KB
/
FillCommandTest.php
File metadata and controls
92 lines (84 loc) · 3.86 KB
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
<?php
use Intervention\Image\Gd\Commands\FillCommand as FillGd;
use Intervention\Image\Imagick\Commands\FillCommand as FillImagick;
class FillCommandTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
Mockery::close();
}
public function testGdFill()
{
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($resource);
$image->shouldReceive('getWidth')->once()->andReturn(800);
$image->shouldReceive('getHeight')->once()->andReturn(600);
$command = new FillGd(array('666666'));
$result = $command->execute($image);
$this->assertTrue($result);
}
public function testGdFillArray()
{
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($resource);
$image->shouldReceive('getWidth')->once()->andReturn(800);
$image->shouldReceive('getHeight')->once()->andReturn(600);
$command = new FillGd(array(array(50, 50, 50)));
$result = $command->execute($image);
$this->assertTrue($result);
}
public function testGdFillArrayWithAlpha()
{
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($resource);
$image->shouldReceive('getWidth')->once()->andReturn(800);
$image->shouldReceive('getHeight')->once()->andReturn(600);
$command = new FillGd(array(array(50, 50, 50, .50)));
$result = $command->execute($image);
$this->assertTrue($result);
}
public function testGdFillWithCoordinates()
{
$driver = Mockery::mock('\Intervention\Image\Gd\Driver');
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getDriver')->once()->andReturn($driver);
$image->shouldReceive('getCore')->times(2)->andReturn($resource);
$image->shouldReceive('getWidth')->once()->andReturn(800);
$image->shouldReceive('getHeight')->once()->andReturn(600);
$image->shouldReceive('setCore')->once();
$driver->shouldReceive('newImage')->with(800, 600)->once()->andReturn($image);
$command = new FillGd(array('#666666', 0, 0));
$result = $command->execute($image);
$this->assertTrue($result);
}
public function testImagickFill()
{
$imagick = Mockery::mock('Imagick');
$imagick->shouldReceive('drawimage')->once()->andReturn(true);
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getWidth')->once()->andReturn(800);
$image->shouldReceive('getHeight')->once()->andReturn(600);
$image->shouldReceive('getCore')->andReturn($imagick);
$command = new FillImagick(array('666666'));
$result = $command->execute($image);
$this->assertTrue($result);
}
public function testImagickFillWithCoordinates()
{
$imagick = Mockery::mock('Imagick');
$imagick->shouldReceive('getimagepixelcolor')->once()->andReturn('#000000');
$imagick->shouldReceive('transparentpaintimage')->once()->andReturn(true);
$imagick->shouldReceive('compositeimage')->times(3)->andReturn(true);
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->andReturn($imagick);
$image->shouldReceive('getWidth')->andReturn(800);
$image->shouldReceive('getHeight')->andReturn(600);
$command = new FillImagick(array('666666', 0, 0));
$result = $command->execute($image);
$this->assertTrue($result);
}
}