Skip to content

Commit

Permalink
notice if dots have been used in the view name (#457)
Browse files Browse the repository at this point in the history
* notice if dots have been used in the view name

* a test for the case we have dots in the view name
  • Loading branch information
muhammadmp97 authored Jun 30, 2022
1 parent 67bd545 commit 6acd82e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/SolutionProviders/ViewNotFoundSolutionProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ public function getSolutions(Throwable $throwable): array

$suggestedView = $this->findRelatedView($missingView);

if ($suggestedView == $missingView) {
return [
BaseSolution::create("{$missingView} was not found.")
->setSolutionDescription('View names should not contain the . character!'),
];
}

if ($suggestedView) {
return [
BaseSolution::create("{$missingView} was not found.")
Expand Down
9 changes: 9 additions & 0 deletions tests/Solutions/ViewNotFoundSolutionProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ public function it_can_recommend_changing_a_typo_in_the_view_name()
$this->assertTrue(Str::contains($solution->getSolutionDescription(), 'Did you mean `php-exception`?'));
}

/** @test */
public function it_can_notice_if_the_view_name_contains_dots()
{
/** @var \Facade\IgnitionContracts\Solution $solution */
$solution = app(ViewNotFoundSolutionProvider::class)->getSolutions($this->getViewNotFoundException('foo.bar'))[0];

$this->assertTrue(Str::contains($solution->getSolutionDescription(), 'the . character'));
}

/** @test */
public function it_wont_recommend_another_controller_class_if_the_names_are_too_different()
{
Expand Down
1 change: 1 addition & 0 deletions tests/stubs/views/foo.bar.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<h1>This is a blade view</h1>

0 comments on commit 6acd82e

Please sign in to comment.