| @@ 8-21 (lines=14) @@ | ||
| 5 | use Symfony\Component\DomCrawler\Crawler; |
|
| 6 | use Psr7Unitesting\Utils\ValueConstraintTrait; |
|
| 7 | ||
| 8 | class Has extends AbstractConstraint |
|
| 9 | { |
|
| 10 | use ValueConstraintTrait; |
|
| 11 | ||
| 12 | public function toString() |
|
| 13 | { |
|
| 14 | return sprintf('has at least one element matching with the selector "%s"', $this->expected); |
|
| 15 | } |
|
| 16 | ||
| 17 | protected function runMatches(Crawler $html) |
|
| 18 | { |
|
| 19 | return count($html->filter($this->expected)) > 0; |
|
| 20 | } |
|
| 21 | } |
|
| 22 | ||
| @@ 8-21 (lines=14) @@ | ||
| 5 | use Symfony\Component\DomCrawler\Crawler; |
|
| 6 | use Psr7Unitesting\Utils\ValueConstraintTrait; |
|
| 7 | ||
| 8 | class HasNot extends AbstractConstraint |
|
| 9 | { |
|
| 10 | use ValueConstraintTrait; |
|
| 11 | ||
| 12 | public function toString() |
|
| 13 | { |
|
| 14 | return sprintf('has not any element matching with the selector "%s"', $this->expected); |
|
| 15 | } |
|
| 16 | ||
| 17 | protected function runMatches(Crawler $html) |
|
| 18 | { |
|
| 19 | return count($html->filter($this->expected)) === 0; |
|
| 20 | } |
|
| 21 | } |
|
| 22 | ||