From 38d4458e96a75b1b07d246b72f209c15c76dc223 Mon Sep 17 00:00:00 2001 From: fadrian06 Date: Wed, 24 Jun 2026 02:48:31 -0400 Subject: [PATCH] 5. views can repass props --- tests/ViewTest.php | 22 ++++++++++++++++--- .../page-with-component-with-one-prop.php | 2 +- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tests/ViewTest.php b/tests/ViewTest.php index 3f24028..bb5c47e 100644 --- a/tests/ViewTest.php +++ b/tests/ViewTest.php @@ -235,11 +235,14 @@ class ViewTest extends TestCase } /** @dataProvider pagesDataProvider */ - public function testItRendersComponent(string $page, string $expected): void - { + public function testItRendersComponent( + string $page, + string $expected, + array $props = [] + ): void { $view = new View(__DIR__ . '/views'); $view->preserveVars = false; - $actual = $view->fetch("pages/$page"); + $actual = $view->fetch("pages/$page", $props); self::assertSame( self::removeIndentation(self::removeLineEndings($expected)), @@ -329,7 +332,20 @@ class ViewTest extends TestCase html, + ['name' => 'James'], + ], + [ + 'page-with-component-with-one-prop', + <<<'html' + + +

Hello, Victoria

+ + + html, + ['name' => 'Victoria'], ], + ]; } diff --git a/tests/views/pages/page-with-component-with-one-prop.php b/tests/views/pages/page-with-component-with-one-prop.php index 7244435..9839e1a 100644 --- a/tests/views/pages/page-with-component-with-one-prop.php +++ b/tests/views/pages/page-with-component-with-one-prop.php @@ -1,5 +1,5 @@ - + \ No newline at end of file