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()