Skip to content

Commit

Permalink
Add test coverage for broken primitive type hints.
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseleite committed Feb 20, 2025
1 parent 4ace966 commit 585c427
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions tests/Routing/RoutesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ protected function resolveApplicationConfiguration($app)
return view('test', ['hello' => "view closure dependencies: $request->value $foo->value $bar->value $baz $qux"]);
});

Route::statamic('/route/with/placeholders/view/closure-primitive-type-hints/{name}/{age}', function (string $name, int $age) {
return view('test', ['hello' => "view closure placeholders: $name $age"]);
});

Route::statamic('/route/with/placeholders/data/closure/{foo}/{bar}/{baz}', 'test', function ($foo, $bar, $baz) {
return ['hello' => "data closure placeholders: $foo $bar $baz"];
});
Expand All @@ -86,6 +90,10 @@ protected function resolveApplicationConfiguration($app)
return ['hello' => "data closure dependencies: $request->value $foo->value $bar->value $baz $qux"];
});

Route::statamic('/route/with/placeholders/data/closure-primitive-type-hints/{name}/{age}', 'test', function (string $name, int $age) {
return ['hello' => "data closure placeholders: $name $age"];
});

Route::statamic('/route-with-custom-layout', 'test', [
'layout' => 'custom-layout',
'hello' => 'world',
Expand Down Expand Up @@ -320,6 +328,17 @@ public function it_renders_a_view_with_placeholders_using_a_view_closure_and_dep
->assertSee('Hello view closure dependencies: request_value foo_class bar_class_modified one two');
}

#[Test]
public function it_renders_a_view_with_placeholders_using_a_view_closure_using_primitive_type_hints()
{
$this->viewShouldReturnRaw('layout', '{{ template_content }}');
$this->viewShouldReturnRaw('test', 'Hello {{ hello }}');

$this->get('/route/with/placeholders/view/closure-primitive-type-hints/darth/42')
->assertOk()
->assertSee('Hello view closure placeholders: darth 42');
}

#[Test]
public function it_renders_a_view_with_placeholders_using_a_data_closure()
{
Expand Down Expand Up @@ -360,6 +379,17 @@ public function it_renders_a_view_with_placeholders_using_a_data_closure_and_dep
->assertSee('Hello data closure dependencies: request_value foo_class bar_class_modified one two');
}

#[Test]
public function it_renders_a_view_with_placeholders_using_a_data_closure_using_primitive_type_hints()
{
$this->viewShouldReturnRaw('layout', '{{ template_content }}');
$this->viewShouldReturnRaw('test', 'Hello {{ hello }}');

$this->get('/route/with/placeholders/data/closure-primitive-type-hints/darth/42')
->assertOk()
->assertSee('Hello data closure placeholders: darth 42');
}

#[Test]
public function it_renders_a_view_with_custom_layout()
{
Expand Down

0 comments on commit 585c427

Please sign in to comment.