Skip to content

Commit

Permalink
Merge pull request #29568 from xuanquynh/fix_exception_message
Browse files Browse the repository at this point in the history
[5.8] Fix exception message
  • Loading branch information
taylorotwell authored Aug 14, 2019
2 parents 8431652 + 7b0b2e8 commit 43e7387
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Illuminate/Foundation/ProviderRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions tests/Foundation/FoundationProviderRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Foundation;

use Exception;
use Mockery as m;
use PHPUnit\Framework\TestCase;
use Illuminate\Filesystem\Filesystem;
Expand Down Expand Up @@ -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']);
}
}

0 comments on commit 43e7387

Please sign in to comment.