browser icon indicating copy to clipboard operation
browser copied to clipboard

`KernelBrowser::clickAndValidate()`

Open kbond opened this issue 2 years ago • 0 comments

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.

kbond avatar Apr 07 '22 18:04 kbond