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 and func0der committed May 6, 2024
1 parent aa0a999 commit 86293db
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 86293db

Please sign in to comment.