From 8f9cba8a738dc62b7ede7b3d592258e5d3deba17 Mon Sep 17 00:00:00 2001 From: "S.a Mahmoudzadeh" <36761585+saMahmoudzadeh@users.noreply.github.com> Date: Fri, 3 May 2024 23:56:35 +0330 Subject: [PATCH] improvement test coverage for view components. (#51271) --- tests/View/ViewComponentTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/View/ViewComponentTest.php b/tests/View/ViewComponentTest.php index a51be9f3cd59..9057b6714b7e 100644 --- a/tests/View/ViewComponentTest.php +++ b/tests/View/ViewComponentTest.php @@ -58,13 +58,18 @@ public function goodbye() } } - public function testAttributeParentInheritance() + public function testAttributeParentInheritance(): void { $component = new TestViewComponent; + $attributes = new ComponentAttributeBag(['class' => 'bar', 'type' => 'button']); - $component->withAttributes(['class' => 'foo', 'attributes' => new ComponentAttributeBag(['class' => 'bar', 'type' => 'button'])]); + $component->withAttributes(['class' => 'foo', 'attributes' => $attributes]); $this->assertSame('class="foo bar" type="button"', (string) $component->attributes); + + // Test overriding parent class attributes + $component->withAttributes(['class' => 'override', 'type' => 'submit']); + $this->assertSame('class="override" type="submit"', (string) $component->attributes); } public function testPublicMethodsWithNoArgsAreConvertedToStringableCallablesInvokedAndNotCached()