Skip to content
This repository has been archived by the owner on Sep 15, 2023. It is now read-only.

Commit

Permalink
Work
Browse files Browse the repository at this point in the history
  • Loading branch information
svenluijten committed Aug 11, 2023
1 parent b64678a commit e613a1c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/Exceptions/ViewAlreadyExists.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@

class ViewAlreadyExists extends InvalidArgumentException
{
public static function at(string $file): self
{
return new self('A view already exists at "'.$file.'".');
}
}
2 changes: 1 addition & 1 deletion src/ViewManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function create(string $view): bool
);

if ($this->filesystem->exists($file)) {
throw new ViewAlreadyExists('A view already exists at "'.$file.'".');
throw ViewAlreadyExists::at($file);
}

$contents = BlockBuilder::make()->build($this->config);
Expand Down
3 changes: 1 addition & 2 deletions tests/Feature/CreateViewsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,9 @@ public function it_does_not_overwrite_an_existing_view_if_it_exists(): void
$this->assertViewEquals("@extends('layouts.app')".PHP_EOL.PHP_EOL, 'testing');

$expectedPath = realpath(__DIR__.'/../resources/views/testing.blade.php');
$expectedPath = realpath($expectedPath);

$this->expectException(ViewAlreadyExists::class);
$this->expectExceptionMessage('A view already exists at "'.$expectedPath.'".');
$this->expectExceptionMessageMatches('/^A view already exists at "'.preg_quote($expectedPath, '/').'"\.$/');

/** @var \Illuminate\Testing\PendingCommand $command */
$command = $this->artisan(MakeView::class, ['name' => 'testing']);
Expand Down

0 comments on commit e613a1c

Please sign in to comment.