@@ -33,7 +33,13 @@ public function setup()
33
33
}
34
34
]
35
35
];
36
- $ this ->writer = new DefaultWriter ($ this ->table , $ this ->entity , $ this ->data , $ this ->field , $ this ->settings );
36
+ $ this ->writer = new DefaultWriter (
37
+ $ this ->table ,
38
+ $ this ->entity ,
39
+ $ this ->data ,
40
+ $ this ->field ,
41
+ $ this ->settings
42
+ );
37
43
38
44
$ this ->vfs = new Vfs ;
39
45
mkdir ($ this ->vfs ->path ('/tmp ' ));
@@ -59,16 +65,19 @@ public function testInvoke()
59
65
60
66
public function testDelete ()
61
67
{
62
- $ writer = $ this ->getMock ('Josegonzalez\Upload\File\Writer\DefaultWriter ' , ['delete ' ], [$ this ->table , $ this ->entity , $ this ->data , $ this ->field , $ this ->settings ]);
63
- $ writer ->expects ($ this ->any ())->method ('delete ' )->will ($ this ->returnValue ([true ]));
68
+ $ filesystem = $ this ->getMock ('League\Flysystem\FilesystemInterface ' );
69
+ $ filesystem ->expects ($ this ->at (0 ))->method ('delete ' )->will ($ this ->returnValue (true ));
70
+ $ filesystem ->expects ($ this ->at (1 ))->method ('delete ' )->will ($ this ->returnValue (false ));
71
+ $ writer = $ this ->getMock ('Josegonzalez\Upload\File\Writer\DefaultWriter ' , ['getFilesystem ' ], [$ this ->table , $ this ->entity , $ this ->data , $ this ->field , $ this ->settings ]);
72
+ $ writer ->expects ($ this ->any ())->method ('getFilesystem ' )->will ($ this ->returnValue ($ filesystem ));
73
+
74
+ $ this ->assertEquals ([], $ writer ->delete ([]));
64
75
$ this ->assertEquals ([true ], $ writer ->delete ([
65
- $ this ->vfs ->path ('existing-file.txt ' )
76
+ $ this ->vfs ->path ('/tmp/tempfile ' )
66
77
]));
67
78
68
- $ writer = $ this ->getMock ('Josegonzalez\Upload\File\Writer\DefaultWriter ' , ['delete ' ], [$ this ->table , $ this ->entity , $ this ->data , $ this ->field , $ this ->settings ]);
69
- $ writer ->expects ($ this ->any ())->method ('delete ' )->will ($ this ->returnValue ([false ]));
70
79
$ this ->assertEquals ([false ], $ writer ->delete ([
71
- $ this ->vfs ->path ('unexisting-file .txt ' )
80
+ $ this ->vfs ->path ('/tmp/invalid .txt ' )
72
81
]));
73
82
}
74
83
0 commit comments