browser
browser copied to clipboard
`KernelBrowser::clickAndValidate()`
The idea is to click a form submit and ensure there are no validation errors. If there are, fail.
public function clickAndValidate(string $locator): self
{
return $this->clickAndIntercept($locator)
->use(function (ValidatorDataCollector $collector) {
Assert::that($collector->getViolationsCount())
->isEmpty('There were {actual} validation violations.')
;
})
;
}
Displaying the actual violations (not just the count) would be nice but the ValidatorDataCollector
makes this difficult as the violations are inside a Symfony\Component\VarDumper\Cloner\Data
object. One possibility is to actually dump
this but there is a lot of other data in here that isn't terribly useful and would just clutter your console.