diff --git a/src/Concerns/Asserts/AssertsElement.php b/src/Concerns/Asserts/AssertsElement.php index deb4473..45eabb9 100644 --- a/src/Concerns/Asserts/AssertsElement.php +++ b/src/Concerns/Asserts/AssertsElement.php @@ -112,7 +112,7 @@ public function assertDoesntMatchSelector(string $selector, ?string $message = n /* |-------------------------------------------------------------------------- - | Assert Count + | Assert Elements Count |-------------------------------------------------------------------------- */ @@ -207,6 +207,36 @@ public function assertElementsCountLessThanOrEqual(string $selector, int $count, return $this; } + /* + |-------------------------------------------------------------------------- + | Assert Elements Present/Missing + |-------------------------------------------------------------------------- + */ + + /** Assert the element contains one or more elements matching the given selector. */ + public function assertElementsPresent(string $selector, ?string $message = null): static + { + $this->assertElementsCountGreaterThan($selector, 0, $message ?? sprintf( + "The element [%s] doesn't have one or more elements matching the given selector [%s].", + $this->identifier(), + $selector, + )); + + return $this; + } + + /** Assert the element contains no elements matching the given selector. */ + public function assertElementsMissing(string $selector, ?string $message = null): static + { + $this->assertElementsCount($selector, 0, $message ?? sprintf( + 'The element [%s] has one or more elements matching the given selector [%s].', + $this->identifier(), + $selector, + )); + + return $this; + } + /* |-------------------------------------------------------------------------- | Assert Text diff --git a/tests/Integration/AssertableHtmlTest.php b/tests/Integration/AssertableHtmlTest.php index 69c6f3a..0ed1133 100644 --- a/tests/Integration/AssertableHtmlTest.php +++ b/tests/Integration/AssertableHtmlTest.php @@ -41,13 +41,6 @@ public function test_assertable_html(): void