|
6 | 6 | use Illuminate\Support\Facades\Blade;
|
7 | 7 | use Illuminate\Support\Facades\Config;
|
8 | 8 | use Illuminate\View\Compilers\BladeCompiler;
|
9 |
| -use Illuminate\View\Engines\PhpEngine; |
10 |
| -use Illuminate\View\Factory; |
11 |
| -use Illuminate\View\View; |
12 | 9 | use Inertia\Directive;
|
13 | 10 | use Inertia\Ssr\Gateway;
|
14 | 11 | use Inertia\Tests\Stubs\FakeGateway;
|
15 | 12 | use Mockery as m;
|
16 |
| -use Throwable; |
17 | 13 |
|
18 | 14 | class DirectiveTest extends TestCase
|
19 | 15 | {
|
@@ -47,42 +43,7 @@ protected function tearDown(): void
|
47 | 43 |
|
48 | 44 | protected function renderView($contents, $data = [])
|
49 | 45 | {
|
50 |
| - // Laravel 8+ only: https://github.com/laravel/framework/pull/40425 |
51 |
| - if (method_exists(BladeCompiler::class, 'render')) { |
52 |
| - return Blade::render($contents, $data, true); |
53 |
| - } |
54 |
| - |
55 |
| - // First, we'll create a temporary file, and use compileString to 'emulate' compilation of our view. |
56 |
| - // This skips caching, and a bunch of other logic that's not relevant for what we need here. |
57 |
| - $path = tempnam(sys_get_temp_dir(), 'inertia_tests_render_'); |
58 |
| - file_put_contents($path, $this->compiler->compileString($contents)); |
59 |
| - |
60 |
| - // Next, we'll 'render' out compiled view. |
61 |
| - $view = new View( |
62 |
| - m::mock(Factory::class), |
63 |
| - new PhpEngine(new Filesystem), |
64 |
| - 'fake-view', |
65 |
| - $path, |
66 |
| - $data |
67 |
| - ); |
68 |
| - |
69 |
| - // Then, we'll just hack and slash our way to success.. |
70 |
| - $view->getFactory()->allows('incrementRender')->once(); |
71 |
| - $view->getFactory()->allows('callComposer')->once(); |
72 |
| - $view->getFactory()->allows('getShared')->once()->andReturn([]); |
73 |
| - $view->getFactory()->allows('decrementRender')->once(); |
74 |
| - $view->getFactory()->allows('flushStateIfDoneRendering')->once(); |
75 |
| - $view->getFactory()->allows('flushState'); |
76 |
| - |
77 |
| - try { |
78 |
| - $output = $view->render(); |
79 |
| - @unlink($path); |
80 |
| - } catch (Throwable $e) { |
81 |
| - @unlink($path); |
82 |
| - throw $e; |
83 |
| - } |
84 |
| - |
85 |
| - return $output; |
| 46 | + return Blade::render($contents, $data, true); |
86 | 47 | }
|
87 | 48 |
|
88 | 49 | public function test_inertia_directive_renders_the_root_element(): void
|
|
0 commit comments