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.
The idea is to click a form submit and ensure there are no validation errors. If there are, fail.
Displaying the actual violations (not just the count) would be nice but the
ValidatorDataCollector
makes this difficult as the violations are inside aSymfony\Component\VarDumper\Cloner\Data
object. One possibility is to actuallydump
this but there is a lot of other data in here that isn't terribly useful and would just clutter your console.