@@ -449,52 +449,91 @@ public function testMethodWithMixedSequentialAndNamedArgumentsSkippingMiddleOne(
449449 rmdir (Hyde::path ('foo ' ));
450450 }
451451
452- public function testFindMimeType ()
452+ public function testFindMimeTypeWithUnknownExtension ()
453453 {
454- // Test fileinfo fallback for existing files where the extension is not in the lookup table
455454 $ this ->file ('text.unknown ' , 'text ' );
456455 $ this ->assertSame ('text/plain ' , Filesystem::findMimeType ('text.unknown ' ));
456+ }
457457
458+ public function testFindMimeTypeWithBlankFile ()
459+ {
458460 $ this ->file ('blank.unknown ' , '' );
459461 $ this ->assertSame ('application/x-empty ' , Filesystem::findMimeType ('blank.unknown ' ));
462+ }
460463
464+ public function testFindMimeTypeWithEmptyFile ()
465+ {
461466 $ this ->file ('empty.unknown ' );
462467 $ this ->assertSame ('application/x-empty ' , Filesystem::findMimeType ('empty.unknown ' ));
468+ }
463469
470+ public function testFindMimeTypeWithJsonFile ()
471+ {
464472 $ this ->file ('json.unknown ' , '{"key": "value"} ' );
465473 $ this ->assertSame ('application/json ' , Filesystem::findMimeType ('json.unknown ' ));
474+ }
466475
476+ public function testFindMimeTypeWithXmlFile ()
477+ {
467478 $ this ->file ('xml.unknown ' , '<?xml version="1.0" encoding="UTF-8"?><root></root> ' );
468479 $ this ->assertSame ('text/xml ' , Filesystem::findMimeType ('xml.unknown ' ));
480+ }
469481
482+ public function testFindMimeTypeWithHtmlFile ()
483+ {
470484 $ this ->file ('html.unknown ' , '<!DOCTYPE html><html><head><title>Test</title></head><body></body></html> ' );
471485 $ this ->assertSame ('text/html ' , Filesystem::findMimeType ('html.unknown ' ));
486+ }
472487
488+ public function testFindMimeTypeWithYamlFile ()
489+ {
473490 $ this ->file ('yaml.unknown ' , 'key: value ' );
474491 $ this ->assertSame ('text/plain ' , Filesystem::findMimeType ('yaml.unknown ' )); // YAML is not detected by fileinfo
492+ }
475493
494+ public function testFindMimeTypeWithCssFile ()
495+ {
476496 $ this ->file ('css.unknown ' , 'body { color: red; } ' );
477497 $ this ->assertSame ('text/plain ' , Filesystem::findMimeType ('css.unknown ' )); // CSS is not detected by fileinfo
498+ }
478499
500+ public function testFindMimeTypeWithJsFile ()
501+ {
479502 $ this ->file ('js.unknown ' , 'console.log("Hello, World!"); ' );
480503 $ this ->assertSame ('text/plain ' , Filesystem::findMimeType ('js.unknown ' )); // JavaScript is not detected by fileinfo
504+ }
481505
506+ public function testFindMimeTypeWithBinaryFile ()
507+ {
482508 $ this ->file ('binary.unknown ' , "\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F" ); // 16 bytes of binary data
483509 $ this ->assertSame ('application/octet-stream ' , Filesystem::findMimeType ('binary.unknown ' ));
510+ }
484511
512+ public function testFindMimeTypeWithPngFile ()
513+ {
485514 $ this ->file ('png.unknown ' , base64_decode ('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkAAIAAAoAAvM1P4AAAAASUVORK5CYII= ' )); // 1x1 transparent PNG
486515 $ this ->assertSame ('image/png ' , Filesystem::findMimeType ('png.unknown ' ));
516+ }
487517
518+ public function testFindMimeTypeWithJpegFile ()
519+ {
488520 $ this ->file ('jpeg.unknown ' , base64_decode ('/9j/4AAQSkZJRgABAQEAYABgAAD/4QA6RXhpZgAATU0AKgAAAAgAA1IBAAABAAAAngIBAAABAAAAnwICAAABAAAAnQ== ' )); // 1x1 JPEG
489521 $ this ->assertSame ('image/jpeg ' , Filesystem::findMimeType ('jpeg.unknown ' ));
522+ }
490523
524+ public function testFindMimeTypeWithGifFile ()
525+ {
491526 $ this ->file ('gif.unknown ' , base64_decode ('R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs= ' )); // 1x1 GIF
492527 $ this ->assertSame ('image/gif ' , Filesystem::findMimeType ('gif.unknown ' ));
528+ }
493529
494- // Test non-existing file
530+ public function testFindMimeTypeWithNonExistingFile ()
531+ {
495532 $ this ->assertSame ('text/plain ' , Filesystem::findMimeType ('non_existing_file.txt ' ));
533+ }
496534
497- // Test it uses lookup before fileinfo (so lookup overrides fileinfo)
535+ public function testFindMimeTypeUsesLookupBeforeFileinfo ()
536+ {
498537 $ this ->file ('file.png ' , 'Not PNG content ' );
499538 $ this ->assertSame ('image/png ' , Filesystem::findMimeType ('file.png ' ));
500539
0 commit comments