Skip to content

Commit 1302b5c

Browse files
committed
Update testing helper to automatically parse attributes
Adds an option to use this with just the full attribute string
1 parent 7368117 commit 1302b5c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

packages/testing/src/Support/TestView.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,15 @@ public function assertSeeHtmlIgnoringFormatting(string $value): static
4242
*
4343
* @return $this
4444
*/
45-
public function assertAttributeIs(string $attributeName, string $expectedValue): static
45+
public function assertAttributeIs(string $attribute, ?string $expectedValue = null): static
4646
{
47+
if ($expectedValue === null) {
48+
[$attributeName, $expectedValue] = explode('=', $attribute);
49+
$expectedValue = trim($expectedValue, '"');
50+
} else {
51+
$attributeName = $attribute;
52+
}
53+
4754
static::assertHasAttribute($attributeName);
4855

4956
PHPUnit::assertStringContainsString($attributeName.'="'.$expectedValue.'"', $this->rendered, "The attribute '$attributeName' with value '$expectedValue' was not found.");

0 commit comments

Comments
 (0)