File tree 2 files changed +4
-32
lines changed
2 files changed +4
-32
lines changed Original file line number Diff line number Diff line change @@ -145,20 +145,15 @@ public function close()
145
145
*/
146
146
public function getContents ()
147
147
{
148
- return $ this ->open ('r ' )->then (function ($ stream ) {
149
- return Stream \buffer ($ stream );
150
- });
148
+ return $ this ->adapter ->getContents ($ this ->path );
151
149
}
152
150
153
151
/**
154
152
* {@inheritDoc}
155
153
*/
156
154
public function putContents ($ contents )
157
155
{
158
- return $ this ->open ('cw ' )->then (function (WritableStreamInterface $ stream ) use ($ contents ) {
159
- $ stream ->write ($ contents );
160
- return $ this ->close ();
161
- });
156
+ return $ this ->adapter ->putContents ($ this ->path , $ contents );
162
157
}
163
158
164
159
/**
Original file line number Diff line number Diff line change @@ -280,36 +280,13 @@ public function testGetContents()
280
280
281
281
$ filesystem = $ this ->mockAdapter ();
282
282
283
- $ filesystem
284
- ->expects ($ this ->any ())
285
- ->method ('stat ' )
286
- ->with ($ path )
287
- ->will ($ this ->returnValue (new FulfilledPromise ([
288
- 'size ' => 1 ,
289
- ])))
290
- ;
291
-
292
- $ filesystem
293
- ->expects ($ this ->once ())
294
- ->method ('open ' )
295
- ->with ($ path , 'r ' )
296
- ->will ($ this ->returnValue (new FulfilledPromise ($ fd )))
297
- ;
298
-
299
283
$ filesystem
300
284
->expects ($ this ->once ())
301
- ->method ('read ' )
302
- ->with ($ fd , 1 , 0 )
285
+ ->method ('getContents ' )
286
+ ->with ($ path )
303
287
->will ($ this ->returnValue (new FulfilledPromise ('a ' )))
304
288
;
305
289
306
- $ filesystem
307
- ->expects ($ this ->once ())
308
- ->method ('close ' )
309
- ->with ($ fd )
310
- ->will ($ this ->returnValue (new FulfilledPromise ()))
311
- ;
312
-
313
290
$ getContentsPromise = (new File ($ path , Filesystem::createFromAdapter ($ filesystem )))->getContents ();
314
291
$ this ->assertInstanceOf ('React\Promise\PromiseInterface ' , $ getContentsPromise );
315
292
}
You can’t perform that action at this time.
0 commit comments