Nextrek
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
|
<?php
use Intervention\Image\Gd\Commands\PickColorCommand as PickColorGd;
use Intervention\Image\Imagick\Commands\PickColorCommand as PickColorImagick;
class PickColorCommandTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
Mockery::close();
}
public function testGdWithCoordinates()
{
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->times(2)->andReturn($resource);
$command = new PickColorGd(array(1, 2));
$result = $command->execute($image);
$this->assertTrue($result);
$this->assertTrue($command->hasOutput());
$this->assertInternalType('array', $command->getOutput());
$this->assertEquals(4, count($command->getOutput()));
}
public function testGdWithFormat()
{
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->times(2)->andReturn($resource);
$command = new PickColorGd(array(1, 2, 'hex'));
$result = $command->execute($image);
$this->assertTrue($result);
$this->assertTrue($command->hasOutput());
$this->assertInternalType('string', $command->getOutput());
$this->assertEquals('#ffffff', $command->getOutput());
}
public function testImagickWithCoordinates()
{
$imagick = Mockery::mock('Imagick');
$imagick->shouldReceive('getimagepixelcolor')->with(1, 2)->andReturn(new ImagickPixel);
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($imagick);
$command = new PickColorImagick(array(1, 2));
$result = $command->execute($image);
$this->assertTrue($result);
$this->assertTrue($command->hasOutput());
$this->assertInternalType('array', $command->getOutput());
$this->assertEquals(4, count($command->getOutput()));
}
public function testImagickWithFormat()
{
$imagick = Mockery::mock('Imagick');
$imagick->shouldReceive('getimagepixelcolor')->with(1, 2)->andReturn(new ImagickPixel('#ff0000'));
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($imagick);
$command = new PickColorImagick(array(1, 2, 'hex'));
$result = $command->execute($image);
$this->assertTrue($result);
$this->assertTrue($command->hasOutput());
$this->assertInternalType('string', $command->getOutput());
$this->assertEquals('#ff0000', $command->getOutput());
}
}
|
Revision |
Author |
Commited |
Message |
1464
|
MOliva
|
Tue 13 Oct, 2020 11:16:56 +0000 |
|