diff --git a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithViews.php b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithViews.php index 9dfbff5a38d2..574effe21260 100644 --- a/src/Illuminate/Foundation/Testing/Concerns/InteractsWithViews.php +++ b/src/Illuminate/Foundation/Testing/Concerns/InteractsWithViews.php @@ -4,7 +4,6 @@ use Illuminate\Support\Facades\View as ViewFacade; use Illuminate\Support\MessageBag; -use Illuminate\Support\Str; use Illuminate\Support\ViewErrorBag; use Illuminate\Testing\TestView; use Illuminate\View\View; @@ -38,11 +37,13 @@ protected function blade(string $template, array $data = []) ViewFacade::addLocation(sys_get_temp_dir()); } - $tempFile = tempnam($tempDirectory, 'laravel-blade').'.blade.php'; + $tempFileInfo = pathinfo(tempnam($tempDirectory, 'laravel-blade')); + + $tempFile = $tempFileInfo['dirname'].'/'.$tempFileInfo['filename'].'.blade.php'; file_put_contents($tempFile, $template); - return new TestView(view(Str::before(basename($tempFile), '.blade.php'), $data)); + return new TestView(view($tempFileInfo['filename'], $data)); } /** diff --git a/tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php b/tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php new file mode 100644 index 000000000000..42bc6c2ec28d --- /dev/null +++ b/tests/Foundation/Testing/Concerns/InteractsWithViewsTest.php @@ -0,0 +1,18 @@ +blade('@if(true)test @endif'); + + $this->assertEquals('test ', $string); + } +}