diff --git a/tests/Routing/RoutesTest.php b/tests/Routing/RoutesTest.php index e5c5fc8fae..932c3a4d39 100644 --- a/tests/Routing/RoutesTest.php +++ b/tests/Routing/RoutesTest.php @@ -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"]; }); @@ -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', @@ -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() { @@ -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() {