Skip to content

KernelBrowser::clickAndValidate() #83

Open
@kbond

Description

@kbond

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions