Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 1 addition & 40 deletions tests/DirectiveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,10 @@
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Config;
use Illuminate\View\Compilers\BladeCompiler;
use Illuminate\View\Engines\PhpEngine;
use Illuminate\View\Factory;
use Illuminate\View\View;
use Inertia\Directive;
use Inertia\Ssr\Gateway;
use Inertia\Tests\Stubs\FakeGateway;
use Mockery as m;
use Throwable;

class DirectiveTest extends TestCase
{
Expand Down Expand Up @@ -47,42 +43,7 @@ protected function tearDown(): void

protected function renderView($contents, $data = [])
{
// Laravel 8+ only: https://github.com/laravel/framework/pull/40425
if (method_exists(BladeCompiler::class, 'render')) {
return Blade::render($contents, $data, true);
}

// First, we'll create a temporary file, and use compileString to 'emulate' compilation of our view.
// This skips caching, and a bunch of other logic that's not relevant for what we need here.
$path = tempnam(sys_get_temp_dir(), 'inertia_tests_render_');
file_put_contents($path, $this->compiler->compileString($contents));

// Next, we'll 'render' out compiled view.
$view = new View(
m::mock(Factory::class),
new PhpEngine(new Filesystem),
'fake-view',
$path,
$data
);

// Then, we'll just hack and slash our way to success..
$view->getFactory()->allows('incrementRender')->once();
$view->getFactory()->allows('callComposer')->once();
$view->getFactory()->allows('getShared')->once()->andReturn([]);
$view->getFactory()->allows('decrementRender')->once();
$view->getFactory()->allows('flushStateIfDoneRendering')->once();
$view->getFactory()->allows('flushState');

try {
$output = $view->render();
@unlink($path);
} catch (Throwable $e) {
@unlink($path);
throw $e;
}

return $output;
return Blade::render($contents, $data, true);
}

public function test_inertia_directive_renders_the_root_element(): void
Expand Down
4 changes: 0 additions & 4 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -893,10 +893,6 @@ public function test_responsable_with_invalid_key(): void

public function test_the_page_url_is_prefixed_with_the_proxy_prefix(): void
{
if (version_compare(app()->version(), '7', '<')) {
$this->markTestSkipped('This test requires Laravel 7 or higher.');
}

Request::setTrustedProxies(['1.2.3.4'], Request::HEADER_X_FORWARDED_PREFIX);

$request = Request::create('/user/123', 'GET');
Expand Down