mock(Filesystem::class, function ($mock) { $mock->shouldReceive('exists')->andReturn(false); $mock->shouldReceive('delete')->with(storage_path('options/cache.php'))->once(); $mock->shouldReceive('put') ->withArgs(function ($path, $content) { $this->assertEquals(storage_path('options/cache.php'), $path); $this->assertTrue(Str::startsWith($content, 'assertTrue(Str::endsWith($content, ';')); return true; }) ->once(); }); $this->artisan('options:cache')->expectsOutput('Options cached successfully.'); } }