Skip to content

Commit

Permalink
improvement test coverage for view components. (laravel#51271)
Browse files Browse the repository at this point in the history
  • Loading branch information
saMahmoudzadeh authored May 3, 2024
1 parent 5f0bced commit 8f9cba8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions tests/View/ViewComponentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 8f9cba8

Please sign in to comment.