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\InsertCommand as InsertGd;
use Intervention\Image\Imagick\Commands\InsertCommand as InsertImagick;
class InsertCommandTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
Mockery::close();
}
public function testGd()
{
$position = Mockery::mock('\Intervention\Image\Point', array(0, 0));
$image_size = Mockery::mock('\Intervention\Image\Size', array(800, 600));
$image_size->shouldReceive('align')->with('center', 10, 20)->once()->andReturn($image_size);
$watermark_size = Mockery::mock('\Intervention\Image\Size', array(800, 600));
$watermark_size->shouldReceive('align')->with('center')->once()->andReturn($watermark_size);
$image_size->shouldReceive('relativePosition')->with($watermark_size)->once()->andReturn($position);
$path = __DIR__.'/images/test.jpg';
$resource = imagecreatefromjpeg($path);
$watermark = Mockery::mock('Intervention\Image\Image');
$driver = Mockery::mock('Intervention\Image\Gd\Driver');
$driver->shouldReceive('init')->with($path)->once()->andReturn($watermark);
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getDriver')->once()->andReturn($driver);
$image->shouldReceive('getCore')->times(2)->andReturn($resource);
$image->shouldReceive('getSize')->once()->andReturn($image_size);
$watermark->shouldReceive('getSize')->once()->andReturn($watermark_size);
$watermark->shouldReceive('getCore')->once()->andReturn($resource);
$command = new InsertGd(array($path, 'center', 10, 20));
$result = $command->execute($image);
$this->assertTrue($result);
}
public function testImagick()
{
$position = Mockery::mock('\Intervention\Image\Point', array(10, 20));
$image_size = Mockery::mock('\Intervention\Image\Size', array(800, 600));
$image_size->shouldReceive('align')->with('center', 10, 20)->once()->andReturn($image_size);
$watermark_size = Mockery::mock('\Intervention\Image\Size', array(800, 600));
$watermark_size->shouldReceive('align')->with('center')->once()->andReturn($watermark_size);
$image_size->shouldReceive('relativePosition')->with($watermark_size)->once()->andReturn($position);
$path = __DIR__.'/images/test.jpg';
$watermark = Mockery::mock('Intervention\Image\Image');
$driver = Mockery::mock('Intervention\Image\Imagick\Driver');
$driver->shouldReceive('init')->with($path)->once()->andReturn($watermark);
$imagick = Mockery::mock('Imagick');
$imagick->shouldReceive('compositeimage')->with($imagick, \Imagick::COMPOSITE_DEFAULT, 10, 20)->andReturn(true);
$image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($imagick);
$image->shouldReceive('getDriver')->once()->andReturn($driver);
$image->shouldReceive('getSize')->once()->andReturn($image_size);
$watermark->shouldReceive('getSize')->once()->andReturn($watermark_size);
$watermark->shouldReceive('getCore')->once()->andReturn($imagick);
$command = new InsertImagick(array($path, 'center', 10, 20));
$result = $command->execute($image);
$this->assertTrue($result);
}
}
|
Revision |
Author |
Commited |
Message |
1464
|
MOliva
|
Tue 13 Oct, 2020 11:16:56 +0000 |
|