@@ -294,6 +294,91 @@ public function it_does_get_metadata()
294
294
295
295
$ meta = $ this ->adapter ->getMetadata ($ publicId );
296
296
297
+ $ this ->assertMetadataResponse ($ meta , $ publicId );
298
+ $ this ->adapter ->delete ($ publicId ); // cleanup
299
+ }
300
+
301
+ /** @test */
302
+ public function it_does_not_get_metadata_if_file_is_not_found ()
303
+ {
304
+ $ publicId = 'file-does-not-exist ' ;
305
+
306
+ $ bool = $ this ->adapter ->getMetadata ($ publicId );
307
+
308
+ $ this ->assertFalse ($ bool );
309
+ }
310
+
311
+ /** @test */
312
+ public function it_does_get_size ()
313
+ {
314
+ $ publicId = 'file-get-size- ' . rand ();
315
+ $ fakeImage = File::image ('black.jpg ' )->getContent ();
316
+ $ this ->adapter ->write ($ publicId , $ fakeImage , new Config ());
317
+
318
+ $ meta = $ this ->adapter ->getSize ($ publicId );
319
+
320
+ $ this ->assertMetadataResponse ($ meta , $ publicId );
321
+ $ this ->adapter ->delete ($ publicId ); // cleanup
322
+ }
323
+
324
+ /** @test */
325
+ public function it_does_not_get_size_if_file_is_not_found ()
326
+ {
327
+ $ publicId = 'file-does-not-exist ' ;
328
+
329
+ $ bool = $ this ->adapter ->getSize ($ publicId );
330
+
331
+ $ this ->assertFalse ($ bool );
332
+ }
333
+
334
+ /** @test */
335
+ public function it_does_get_mimetype ()
336
+ {
337
+ $ publicId = 'file-get-mimetype- ' . rand ();
338
+ $ fakeImage = File::image ('black.jpg ' )->getContent ();
339
+ $ this ->adapter ->write ($ publicId , $ fakeImage , new Config ());
340
+
341
+ $ meta = $ this ->adapter ->getMimetype ($ publicId );
342
+
343
+ $ this ->assertMetadataResponse ($ meta , $ publicId );
344
+ $ this ->adapter ->delete ($ publicId ); // cleanup
345
+ }
346
+
347
+ /** @test */
348
+ public function it_does_not_get_mimetype_if_file_is_not_found ()
349
+ {
350
+ $ publicId = 'file-does-not-exist ' ;
351
+
352
+ $ bool = $ this ->adapter ->getMimetype ($ publicId );
353
+
354
+ $ this ->assertFalse ($ bool );
355
+ }
356
+
357
+ /** @test */
358
+ public function it_does_get_timestamp ()
359
+ {
360
+ $ publicId = 'file-get-mimetype- ' . rand ();
361
+ $ fakeImage = File::image ('black.jpg ' )->getContent ();
362
+ $ this ->adapter ->write ($ publicId , $ fakeImage , new Config ());
363
+
364
+ $ meta = $ this ->adapter ->getTimestamp ($ publicId );
365
+
366
+ $ this ->assertMetadataResponse ($ meta , $ publicId );
367
+ $ this ->adapter ->delete ($ publicId ); // cleanup
368
+ }
369
+
370
+ /** @test */
371
+ public function it_does_not_get_timestamp_if_file_is_not_found ()
372
+ {
373
+ $ publicId = 'file-does-not-exist ' ;
374
+
375
+ $ bool = $ this ->adapter ->getTimestamp ($ publicId );
376
+
377
+ $ this ->assertFalse ($ bool );
378
+ }
379
+
380
+ protected function assertMetadataResponse (array $ meta , string $ publicId ): void
381
+ {
297
382
$ this ->assertIsString ($ meta ['contents ' ]);
298
383
$ this ->assertNull ($ meta ['etag ' ]);
299
384
$ this ->assertSame ('image/jpeg ' , $ meta ['mimetype ' ]);
@@ -304,6 +389,18 @@ public function it_does_get_metadata()
304
389
$ this ->assertIsInt ($ meta ['version ' ]);
305
390
$ this ->assertIsString ($ meta ['versionid ' ]);
306
391
$ this ->assertSame ('public ' , $ meta ['visibility ' ]);
392
+ }
393
+
394
+ /** @test */
395
+ public function it_does_get_url ()
396
+ {
397
+ $ publicId = 'file-get-url- ' . rand ();
398
+ $ fakeImage = File::image ('black.jpg ' )->getContent ();
399
+ $ this ->adapter ->write ($ publicId , $ fakeImage , new Config ());
400
+
401
+ $ url = $ this ->adapter ->getUrl ($ publicId );
402
+
403
+ $ this ->assertStringContainsString ($ publicId , $ url );
307
404
$ this ->adapter ->delete ($ publicId ); // cleanup
308
405
}
309
406
}
0 commit comments