Skip to content

Commit 6acd82e

Browse files
authored
notice if dots have been used in the view name (#457)
* notice if dots have been used in the view name * a test for the case we have dots in the view name
1 parent 67bd545 commit 6acd82e

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/SolutionProviders/ViewNotFoundSolutionProvider.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@ public function getSolutions(Throwable $throwable): array
3434

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

37+
if ($suggestedView == $missingView) {
38+
return [
39+
BaseSolution::create("{$missingView} was not found.")
40+
->setSolutionDescription('View names should not contain the . character!'),
41+
];
42+
}
43+
3744
if ($suggestedView) {
3845
return [
3946
BaseSolution::create("{$missingView} was not found.")

tests/Solutions/ViewNotFoundSolutionProviderTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,15 @@ public function it_can_recommend_changing_a_typo_in_the_view_name()
3434
$this->assertTrue(Str::contains($solution->getSolutionDescription(), 'Did you mean `php-exception`?'));
3535
}
3636

37+
/** @test */
38+
public function it_can_notice_if_the_view_name_contains_dots()
39+
{
40+
/** @var \Facade\IgnitionContracts\Solution $solution */
41+
$solution = app(ViewNotFoundSolutionProvider::class)->getSolutions($this->getViewNotFoundException('foo.bar'))[0];
42+
43+
$this->assertTrue(Str::contains($solution->getSolutionDescription(), 'the . character'));
44+
}
45+
3746
/** @test */
3847
public function it_wont_recommend_another_controller_class_if_the_names_are_too_different()
3948
{

tests/stubs/views/foo.bar.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<h1>This is a blade view</h1>

0 commit comments

Comments
 (0)