Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Illuminate/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,11 @@ public function getCachedRoutesPath()
*/
public function eventsAreCached()
{
return $this['files']->exists($this->getCachedEventsPath());
if ($this->bound('events.cached')) {
return (bool) $this->make('events.cached');
}

return $this->instance('events.cached', $this['files']->exists($this->getCachedEventsPath()));
}

/**
Expand Down
47 changes: 36 additions & 11 deletions tests/Foundation/FoundationApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -620,23 +620,36 @@ public function test_routes_are_cached()
public function test_routes_are_not_cached_by_instance_falls_back_to_file()
{
$app = new Application();
$files = new class
{
public string $pathRequested;

public function exists(string $path): bool
{
$this->pathRequested = $path;

return false;
}
};
$files = new FileExistsFake;
$app->instance('files', $files);

$this->assertFalse($app->routesAreCached());
$this->assertStringContainsString('routes-v7.php', $files->pathRequested);
}

public function test_events_are_cached_uses_container_instance()
{
$app = new Application();
$app->instance('events.cached', true);
$files = new FileExistsFake;
$app->instance('files', $files);

$this->assertTrue($app->eventsAreCached());
$this->assertFalse(isset($files->pathRequested));
}

public function test_events_are_cached_checks_filesystem_if_not_set()
{
$app = new Application();
$files = new FileExistsFake;
$app->instance('files', $files);

$this->assertFalse($app->eventsAreCached());
$this->assertStringContainsString('events.php', $files->pathRequested);
$this->assertTrue($app->bound('events.cached'));
$this->assertFalse($app->make('events.cached'));
}

public function testCoreContainerAliasesAreRegisteredByDefault(): void
{
$app = new Application();
Expand Down Expand Up @@ -782,3 +795,15 @@ public function terminate()
return self::$counter++;
}
}

class FileExistsFake
{
public string $pathRequested;

public function exists(string $path): bool
{
$this->pathRequested = $path;

return false;
}
}
Loading