77use Josegonzalez \Upload \File \Writer \DefaultWriter ;
88use Laminas \Diactoros \UploadedFile ;
99use League \Flysystem \InMemory \InMemoryFilesystemAdapter ;
10+ use VirtualFileSystem \FileSystem as Vfs ;
1011
1112class DefaultWriterTest extends TestCase
1213{
@@ -38,6 +39,10 @@ public function setUp(): void
3839 $ this ->field ,
3940 $ this ->settings
4041 );
42+
43+ $ this ->vfs = new Vfs ();
44+ mkdir ($ this ->vfs ->path ('/tmp ' ));
45+ file_put_contents ($ this ->vfs ->path ('/tmp/tempfile ' ), 'content ' );
4146 }
4247
4348 public function testIsWriterInterface ()
@@ -49,11 +54,11 @@ public function testInvoke()
4954 {
5055 $ this ->assertEquals ([], $ this ->writer ->write ([]));
5156 $ this ->assertEquals ([true ], $ this ->writer ->write ([
52- '/tmp/tempfile ' => 'file.txt ' ,
57+ $ this -> vfs -> path ( '/tmp/tempfile ' ) => 'file.txt ' ,
5358 ], 'field ' , []));
5459
5560 $ this ->assertEquals ([false ], $ this ->writer ->write ([
56- '/tmp/invalid.txt ' => 'file.txt ' ,
61+ $ this -> vfs -> path ( '/tmp/invalid.txt ' ) => 'file.txt ' ,
5762 ], 'field ' , []));
5863 }
5964
@@ -70,11 +75,11 @@ public function testDelete()
7075
7176 $ this ->assertEquals ([], $ writer ->delete ([]));
7277 $ this ->assertEquals ([true ], $ writer ->delete ([
73- '/tmp/tempfile ' ,
78+ $ this -> vfs -> path ( '/tmp/tempfile ' ) ,
7479 ]));
7580
7681 $ this ->assertEquals ([false ], $ writer ->delete ([
77- '/tmp/invalid.txt ' ,
82+ $ this -> vfs -> path ( '/tmp/invalid.txt ' ) ,
7883 ]));
7984 }
8085
@@ -84,19 +89,19 @@ public function testWriteFile()
8489 $ filesystem ->expects ($ this ->once ())->method ('writeStream ' )->will ($ this ->returnValue (true ));
8590 $ filesystem ->expects ($ this ->exactly (3 ))->method ('delete ' )->will ($ this ->returnValue (true ));
8691 $ filesystem ->expects ($ this ->once ())->method ('move ' )->will ($ this ->returnValue (true ));
87- $ this ->assertTrue ($ this ->writer ->writeFile ($ filesystem , '/tmp/tempfile ' , 'path ' ));
92+ $ this ->assertTrue ($ this ->writer ->writeFile ($ filesystem , $ this -> vfs -> path ( '/tmp/tempfile ' ) , 'path ' ));
8893
8994 $ filesystem = $ this ->getMockBuilder ('League\Flysystem\FilesystemOperator ' )->getMock ();
9095 $ filesystem ->expects ($ this ->once ())->method ('writeStream ' )->will ($ this ->returnValue (false ));
9196 $ filesystem ->expects ($ this ->exactly (2 ))->method ('delete ' )->will ($ this ->returnValue (true ));
9297 $ filesystem ->expects ($ this ->never ())->method ('move ' );
93- $ this ->assertFalse ($ this ->writer ->writeFile ($ filesystem , '/tmp/tempfile ' , 'path ' ));
98+ $ this ->assertFalse ($ this ->writer ->writeFile ($ filesystem , $ this -> vfs -> path ( '/tmp/tempfile ' ) , 'path ' ));
9499
95100 $ filesystem = $ this ->getMockBuilder ('League\Flysystem\FilesystemOperator ' )->getMock ();
96101 $ filesystem ->expects ($ this ->once ())->method ('writeStream ' )->will ($ this ->returnValue (true ));
97102 $ filesystem ->expects ($ this ->exactly (3 ))->method ('delete ' )->will ($ this ->returnValue (true ));
98103 $ filesystem ->expects ($ this ->once ())->method ('move ' )->will ($ this ->returnValue (false ));
99- $ this ->assertFalse ($ this ->writer ->writeFile ($ filesystem , '/tmp/tempfile ' , 'path ' ));
104+ $ this ->assertFalse ($ this ->writer ->writeFile ($ filesystem , $ this -> vfs -> path ( '/tmp/tempfile ' ) , 'path ' ));
100105 }
101106
102107 public function testDeletePath ()
0 commit comments