25
25
use League \Flysystem \FilesystemWriter ;
26
26
use Nyholm \Psr7 \Request ;
27
27
use Nyholm \Psr7 \Response ;
28
- use PHPUnit \Framework \MockObject \MockObject ;
29
28
use PHPUnit \Framework \TestCase ;
30
29
use Psr \Http \Message \RequestInterface ;
31
30
use Psr \Http \Message \StreamInterface ;
38
37
final class FlysystemWritePluginTest extends TestCase
39
38
{
40
39
/**
41
- * @param ( FilesystemInterface| FilesystemWriter)&MockObject $filesystem
40
+ * @param class-string< FilesystemInterface>|class-string< FilesystemWriter> $class
42
41
*
43
42
* @dataProvider flysystemProvider
44
43
*/
45
- public function testHandleRequestWithFlysytemV1 ($ filesystem ): void
44
+ public function testHandleRequestWithFlysytemV1 (string $ class ): void
46
45
{
47
46
$ path = sys_get_temp_dir ();
48
47
$ body = $ this ->createMock (StreamInterface::class);
@@ -57,7 +56,8 @@ public function testHandleRequestWithFlysytemV1($filesystem): void
57
56
->method ('detach ' )
58
57
->willReturn ($ resource );
59
58
60
- $ filesystem ->expects (self ::once ())
59
+ $ filesystem = $ this ->createMock ($ class );
60
+ $ filesystem ->expects (self ::atLeastOnce ())
61
61
->method ('writeStream ' )
62
62
->with ($ path , $ resource );
63
63
@@ -89,11 +89,11 @@ public function testHandleRequestWithFlysytemV1($filesystem): void
89
89
}
90
90
91
91
/**
92
- * @param ( FilesystemInterface| FilesystemWriter)&MockObject $filesystem
92
+ * @param class-string< FilesystemInterface>|class-string< FilesystemWriter> $class
93
93
*
94
94
* @dataProvider flysystemProvider
95
95
*/
96
- public function testHandleRequestWithFlysytemV1AndSeekableStream ($ filesystem ): void
96
+ public function testHandleRequestWithFlysytemV1AndSeekableStream (string $ class ): void
97
97
{
98
98
$ path = sys_get_temp_dir ();
99
99
$ body = $ this ->createMock (StreamInterface::class);
@@ -115,6 +115,7 @@ public function testHandleRequestWithFlysytemV1AndSeekableStream($filesystem): v
115
115
->method ('isSeekable ' )
116
116
->willReturn (true );
117
117
118
+ $ filesystem = $ this ->createMock ($ class );
118
119
$ filesystem ->expects (self ::once ())
119
120
->method ('writeStream ' )
120
121
->with ($ path , $ resource );
@@ -149,11 +150,11 @@ public function testHandleRequestWithFlysytemV1AndSeekableStream($filesystem): v
149
150
}
150
151
151
152
/**
152
- * @param ( FilesystemInterface| FilesystemWriter)&MockObject $filesystem
153
+ * @param class-string< FilesystemInterface>|class-string< FilesystemWriter> $class
153
154
*
154
155
* @dataProvider flysystemProvider
155
156
*/
156
- public function testHandleRequestWithFlysytemV1AndInvalidResource ($ filesystem ): void
157
+ public function testHandleRequestWithFlysytemV1AndInvalidResource (string $ class ): void
157
158
{
158
159
$ path = sys_get_temp_dir ();
159
160
$ body = $ this ->createMock (StreamInterface::class);
@@ -162,6 +163,7 @@ public function testHandleRequestWithFlysytemV1AndInvalidResource($filesystem):
162
163
->method ('detach ' )
163
164
->willReturn ('' );
164
165
166
+ $ filesystem = $ this ->createMock ($ class );
165
167
$ filesystem ->expects (self ::never ())
166
168
->method ('writeStream ' );
167
169
@@ -190,11 +192,11 @@ public function testHandleRequestWithFlysytemV1AndInvalidResource($filesystem):
190
192
public function flysystemProvider (): Generator
191
193
{
192
194
if (interface_exists (FilesystemInterface::class)) {
193
- yield [$ this -> createMock ( FilesystemInterface::class) ];
195
+ yield [FilesystemInterface::class];
194
196
}
195
197
196
198
if (interface_exists (FilesystemWriter::class)) {
197
- yield [$ this -> createMock ( FilesystemWriter::class) ];
199
+ yield [FilesystemWriter::class];
198
200
}
199
201
}
200
202
}
0 commit comments