Skip to content

Commit

Permalink
Merge pull request #1608 from hydephp/add-html-testing-helpers
Browse files Browse the repository at this point in the history
Internal: Improve testing helpers
  • Loading branch information
caendesilva authored Mar 13, 2024
2 parents 9a2ed40 + 6a88a87 commit 0d5fd3b
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/testing/src/Support/TestView.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,30 @@ public function assertSeeHtmlIgnoringFormatting(string $value): static
return $this;
}

/**
* Assert that the HTML attribute value is contained within the view.
*
* @return $this
*/
public function assertAttributeIs(string $attributeName, string $expectedValue): static
{
PHPUnit::assertStringContainsString($attributeName.'="'.$expectedValue.'"', $this->rendered);

return $this;
}

/**
* Assert that the given text is equals the view's text content.
*
* @return $this
*/
public function assertTextIs(string $value): static
{
PHPUnit::assertSame($value, strip_tags($this->rendered));

return $this;
}

protected function trimNewlinesAndIndentation(string $value): string
{
return str_replace([' ', "\t", "\n", "\r"], '', $value);
Expand Down

0 comments on commit 0d5fd3b

Please sign in to comment.