4
4
5
5
namespace League \Glide \Manipulators ;
6
6
7
- use Intervention \Image \Interfaces \DriverInterface ;
8
7
use Intervention \Image \Interfaces \ImageInterface ;
9
- use Intervention \Image \Origin ;
10
8
use PHPUnit \Framework \TestCase ;
11
9
12
10
class BackgroundTest extends TestCase
13
11
{
14
12
private $ manipulator ;
15
13
14
+ public function setUp (): void
15
+ {
16
+ $ this ->manipulator = new Background ();
17
+ }
18
+
16
19
public function tearDown (): void
17
20
{
18
21
\Mockery::close ();
@@ -26,27 +29,12 @@ public function testCreateInstance()
26
29
public function testRun ()
27
30
{
28
31
$ image = \Mockery::mock (ImageInterface::class, function ($ mock ) {
29
- $ originMock = \Mockery::mock (Origin::class, ['mediaType ' => 'image/jpeg ' ]);
30
-
31
- $ mock ->shouldReceive ('width ' )->andReturn (100 )->once ();
32
- $ mock ->shouldReceive ('height ' )->andReturn (100 )->once ();
33
- $ mock ->shouldReceive ('origin ' )->andReturn ($ originMock )->once ();
34
-
35
- $ mock ->shouldReceive ('driver ' )->andReturn (\Mockery::mock (DriverInterface::class, function ($ mock ) {
36
- $ mock ->shouldReceive ('createImage ' )->with (100 , 100 )->andReturn (\Mockery::mock (ImageInterface::class, function ($ mock ) {
37
- $ mock ->shouldReceive ('fill ' )->with ('rgba(0, 0, 0, 1) ' )->andReturn (\Mockery::mock (ImageInterface::class, function ($ mock ) {
38
- $ mock ->shouldReceive ('setOrigin ' )->withArgs (function ($ arg1 ) {
39
- return $ arg1 instanceof Origin;
40
- })->andReturn ($ mock )->once ();
41
- $ mock ->shouldReceive ('place ' )->andReturn ($ mock )->once ();
42
- }))->once ();
43
- }))->once ();
44
- }))->once ();
32
+ $ mock ->shouldReceive ('blendTransparency ' )->with ('rgba(0, 0, 0, 1) ' )->once ();
45
33
});
46
34
47
- $ border = new Background ();
48
-
49
- $ this ->assertInstanceOf (ImageInterface::class, $ border ->run ($ image ));
50
- $ this -> assertInstanceOf (ImageInterface::class, $ border -> setParams ([ ' bg ' => ' black ' ])-> run ( $ image ) );
35
+ $ this -> assertInstanceOf (
36
+ ImageInterface::class,
37
+ $ this ->manipulator -> setParams ([ ' bg ' => ' black ' ]) ->run ($ image )
38
+ );
51
39
}
52
40
}
0 commit comments