Skip to content

Commit ac0b163

Browse files
committed
Fix tests
1 parent d4ddc86 commit ac0b163

File tree

2 files changed

+23
-59
lines changed

2 files changed

+23
-59
lines changed

tests/TestCase/Processor/Image/ImageVariantTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,19 +78,19 @@ public function testVariant(): void
7878
'x' => null,
7979
'y' => null,
8080
],
81-
'fit' => [
82-
'width' => 200,
83-
'height' => 200,
84-
'callback' => null,
85-
'preventUpscale' => false,
86-
'position' => 'center',
87-
],
8881
'rotate' => [
8982
'angle' => 90,
9083
],
9184
'sharpen' => [
9285
'amount' => 90,
9386
],
87+
'cover' => [
88+
'width' => 200,
89+
'height' => 200,
90+
'callback' => null,
91+
'preventUpscale' => false,
92+
'position' => 'center',
93+
],
9494
],
9595
'path' => '/',
9696
'url' => '',

tests/TestCase/Processor/Image/OperationsTest.php

Lines changed: 16 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@
1414

1515
namespace PhpCollective\Test\TestCase\Processor\Image;
1616

17+
use Intervention\Image\Interfaces\ImageInterface;
1718
use PhpCollective\Infrastructure\Storage\Processor\Image\Operations;
1819
use PhpCollective\Test\TestCase\TestCase;
19-
use TestApp\Image;
2020

2121
/**
2222
* OperationsTest
@@ -28,19 +28,13 @@ class OperationsTest extends TestCase
2828
*/
2929
public function testOperations(): void
3030
{
31-
$imageMock = $this->getMockBuilder(Image::class)
32-
->disableOriginalConstructor()
33-
->onlyMethods([
34-
'resize',
35-
])
36-
->getMock();
37-
38-
$operations = new Operations($imageMock);
31+
$imageMock = $this->createMock(ImageInterface::class);
3932

4033
$imageMock->expects($this->once())
4134
->method('resize')
4235
->with(100, 100);
4336

37+
$operations = new Operations($imageMock);
4438
$operations->resize(['height' => 100, 'width' => 100]);
4539
}
4640

@@ -49,19 +43,13 @@ public function testOperations(): void
4943
*/
5044
public function testScale(): void
5145
{
52-
$imageMock = $this->getMockBuilder(Image::class)
53-
->disableOriginalConstructor()
54-
->onlyMethods([
55-
'scale',
56-
])
57-
->getMock();
58-
59-
$operations = new Operations($imageMock);
46+
$imageMock = $this->createMock(ImageInterface::class);
6047

6148
$imageMock->expects($this->once())
6249
->method('scale')
6350
->with(100, 200);
6451

52+
$operations = new Operations($imageMock);
6553
$operations->scale(['height' => 200, 'width' => 100]);
6654
}
6755

@@ -70,19 +58,13 @@ public function testScale(): void
7058
*/
7159
public function testRotate(): void
7260
{
73-
$imageMock = $this->getMockBuilder(Image::class)
74-
->disableOriginalConstructor()
75-
->onlyMethods([
76-
'rotate',
77-
])
78-
->getMock();
79-
80-
$operations = new Operations($imageMock);
61+
$imageMock = $this->createMock(ImageInterface::class);
8162

8263
$imageMock->expects($this->once())
8364
->method('rotate')
8465
->with(90);
8566

67+
$operations = new Operations($imageMock);
8668
$operations->rotate(['angle' => 90]);
8769

8870
$this->expectException(\InvalidArgumentException::class);
@@ -95,19 +77,13 @@ public function testRotate(): void
9577
*/
9678
public function testSharpen(): void
9779
{
98-
$imageMock = $this->getMockBuilder(Image::class)
99-
->disableOriginalConstructor()
100-
->onlyMethods([
101-
'sharpen',
102-
])
103-
->getMock();
104-
105-
$operations = new Operations($imageMock);
80+
$imageMock = $this->createMock(ImageInterface::class);
10681

10782
$imageMock->expects($this->once())
10883
->method('sharpen')
10984
->with(90);
11085

86+
$operations = new Operations($imageMock);
11187
$operations->sharpen(['amount' => 90]);
11288

11389
$this->expectException(\InvalidArgumentException::class);
@@ -120,23 +96,17 @@ public function testSharpen(): void
12096
*/
12197
public function testCover(): void
12298
{
123-
$imageMock = $this->getMockBuilder(Image::class)
124-
->disableOriginalConstructor()
125-
->onlyMethods([
126-
'cover',
127-
])
128-
->getMock();
129-
130-
$operations = new Operations($imageMock);
99+
$imageMock = $this->createMock(ImageInterface::class);
131100

132101
$imageMock->expects($this->once())
133102
->method('cover')
134-
->with(100, 100);
103+
->with(100, 100, 'center');
135104

105+
$operations = new Operations($imageMock);
136106
$operations->cover(['width' => 100, 'height' => 100]);
137107

138108
$this->expectException(\InvalidArgumentException::class);
139-
$this->expectExceptionMessage('Missing width');
109+
$this->expectExceptionMessage('Missing width or height');
140110
$operations->cover([]);
141111
}
142112

@@ -145,19 +115,13 @@ public function testCover(): void
145115
*/
146116
public function testCrop(): void
147117
{
148-
$imageMock = $this->getMockBuilder(Image::class)
149-
->disableOriginalConstructor()
150-
->onlyMethods([
151-
'crop',
152-
])
153-
->getMock();
154-
155-
$operations = new Operations($imageMock);
118+
$imageMock = $this->createMock(ImageInterface::class);
156119

157120
$imageMock->expects($this->once())
158121
->method('crop')
159-
->with(100, 200);
122+
->with(100, 200, 0, 0, 'center');
160123

124+
$operations = new Operations($imageMock);
161125
$operations->crop(['width' => 100, 'height' => 200]);
162126

163127
$this->expectException(\InvalidArgumentException::class);

0 commit comments

Comments
 (0)