@@ -620,23 +620,36 @@ public function test_routes_are_cached()
620620 public function test_routes_are_not_cached_by_instance_falls_back_to_file ()
621621 {
622622 $ app = new Application ();
623- $ files = new class
624- {
625- public string $ pathRequested ;
626-
627- public function exists (string $ path ): bool
628- {
629- $ this ->pathRequested = $ path ;
630-
631- return false ;
632- }
633- };
623+ $ files = new FileExistsFake ;
634624 $ app ->instance ('files ' , $ files );
635625
636626 $ this ->assertFalse ($ app ->routesAreCached ());
637627 $ this ->assertStringContainsString ('routes-v7.php ' , $ files ->pathRequested );
638628 }
639629
630+ public function test_events_are_cached_uses_container_instance ()
631+ {
632+ $ app = new Application ();
633+ $ app ->instance ('events.cached ' , true );
634+ $ files = new FileExistsFake ;
635+ $ app ->instance ('files ' , $ files );
636+
637+ $ this ->assertTrue ($ app ->eventsAreCached ());
638+ $ this ->assertFalse (isset ($ files ->pathRequested ));
639+ }
640+
641+ public function test_events_are_cached_checks_filesystem_if_not_set ()
642+ {
643+ $ app = new Application ();
644+ $ files = new FileExistsFake ;
645+ $ app ->instance ('files ' , $ files );
646+
647+ $ this ->assertFalse ($ app ->eventsAreCached ());
648+ $ this ->assertStringContainsString ('events.php ' , $ files ->pathRequested );
649+ $ this ->assertTrue ($ app ->bound ('events.cached ' ));
650+ $ this ->assertFalse ($ app ->make ('events.cached ' ));
651+ }
652+
640653 public function testCoreContainerAliasesAreRegisteredByDefault (): void
641654 {
642655 $ app = new Application ();
@@ -782,3 +795,15 @@ public function terminate()
782795 return self ::$ counter ++;
783796 }
784797}
798+
799+ class FileExistsFake
800+ {
801+ public string $ pathRequested ;
802+
803+ public function exists (string $ path ): bool
804+ {
805+ $ this ->pathRequested = $ path ;
806+
807+ return false ;
808+ }
809+ }
0 commit comments