diff --git a/src/Illuminate/Foundation/ProviderRepository.php b/src/Illuminate/Foundation/ProviderRepository.php index 080479c9c28f..903908f3dac0 100755 --- a/src/Illuminate/Foundation/ProviderRepository.php +++ b/src/Illuminate/Foundation/ProviderRepository.php @@ -186,8 +186,8 @@ protected function freshManifest(array $providers) */ public function writeManifest($manifest) { - if (! is_writable(dirname($this->manifestPath))) { - throw new Exception('The bootstrap/cache directory must be present and writable.'); + if (! is_writable($dirname = dirname($this->manifestPath))) { + throw new Exception("The {$dirname} directory must be present and writable."); } $this->files->replace( diff --git a/tests/Foundation/FoundationProviderRepositoryTest.php b/tests/Foundation/FoundationProviderRepositoryTest.php index 7c701cdb3db2..9832a9678b0c 100755 --- a/tests/Foundation/FoundationProviderRepositoryTest.php +++ b/tests/Foundation/FoundationProviderRepositoryTest.php @@ -2,6 +2,7 @@ namespace Illuminate\Tests\Foundation; +use Exception; use Mockery as m; use PHPUnit\Framework\TestCase; use Illuminate\Filesystem\Filesystem; @@ -87,4 +88,15 @@ public function testWriteManifestStoresToProperLocation() $this->assertEquals(['foo', 'when' => []], $result); } + + public function testWriteManifestThrowsExceptionIfManifestDirDoesntExist() + { + $this->expectException(Exception::class); + $this->expectExceptionMessageRegExp('/^The (.*) directory must be present and writable.$/'); + + $repo = new ProviderRepository(m::mock(ApplicationContract::class), $files = m::mock(Filesystem::class), __DIR__.'/cache/services.php'); + $files->shouldReceive('replace')->never(); + + $repo->writeManifest(['foo']); + } }