diff --git a/packages/testing/src/Support/TestView.php b/packages/testing/src/Support/TestView.php index 8bb446c3ebc..4e04a247a7d 100644 --- a/packages/testing/src/Support/TestView.php +++ b/packages/testing/src/Support/TestView.php @@ -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);