4
4
5
5
namespace League \Glide \Manipulators ;
6
6
7
+ use Intervention \Image \Interfaces \DriverInterface ;
7
8
use Intervention \Image \Interfaces \ImageInterface ;
9
+ use Intervention \Image \Origin ;
8
10
use PHPUnit \Framework \TestCase ;
9
11
10
12
class BackgroundTest extends TestCase
11
13
{
12
14
private $ manipulator ;
13
15
14
- public function setUp (): void
15
- {
16
- $ this ->manipulator = new Background ();
17
- }
18
-
19
16
public function tearDown (): void
20
17
{
21
18
\Mockery::close ();
@@ -29,12 +26,27 @@ public function testCreateInstance()
29
26
public function testRun ()
30
27
{
31
28
$ image = \Mockery::mock (ImageInterface::class, function ($ mock ) {
32
- $ mock ->shouldReceive ('blendTransparency ' )->with ('rgba(0, 0, 0, 1) ' )->once ();
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 ();
33
45
});
34
46
35
- $ this -> assertInstanceOf (
36
- ImageInterface::class,
37
- $ this ->manipulator -> setParams ([ ' bg ' => ' black ' ]) ->run ($ image )
38
- );
47
+ $ border = new Background ();
48
+
49
+ $ this ->assertInstanceOf (ImageInterface::class, $ border ->run ($ image ));
50
+ $ this -> assertInstanceOf (ImageInterface::class, $ border -> setParams ([ ' bg ' => ' black ' ])-> run ( $ image ) );
39
51
}
40
52
}
0 commit comments