From 6acd82e986a2ecee89e2e68adfc30a1936d1ab7c Mon Sep 17 00:00:00 2001 From: WebPajooh Date: Thu, 30 Jun 2022 22:56:59 +0430 Subject: [PATCH] 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 --- src/SolutionProviders/ViewNotFoundSolutionProvider.php | 7 +++++++ tests/Solutions/ViewNotFoundSolutionProviderTest.php | 9 +++++++++ tests/stubs/views/foo.bar.blade.php | 1 + 3 files changed, 17 insertions(+) create mode 100644 tests/stubs/views/foo.bar.blade.php diff --git a/src/SolutionProviders/ViewNotFoundSolutionProvider.php b/src/SolutionProviders/ViewNotFoundSolutionProvider.php index 54d087ad..cd24e855 100644 --- a/src/SolutionProviders/ViewNotFoundSolutionProvider.php +++ b/src/SolutionProviders/ViewNotFoundSolutionProvider.php @@ -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.") diff --git a/tests/Solutions/ViewNotFoundSolutionProviderTest.php b/tests/Solutions/ViewNotFoundSolutionProviderTest.php index 78d6fb44..8876d70b 100644 --- a/tests/Solutions/ViewNotFoundSolutionProviderTest.php +++ b/tests/Solutions/ViewNotFoundSolutionProviderTest.php @@ -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() { diff --git a/tests/stubs/views/foo.bar.blade.php b/tests/stubs/views/foo.bar.blade.php new file mode 100644 index 00000000..07034f0a --- /dev/null +++ b/tests/stubs/views/foo.bar.blade.php @@ -0,0 +1 @@ +

This is a blade view

\ No newline at end of file