From 2daf1f0c5a8a9f7f6c3fb3e5e37070f15e95808c Mon Sep 17 00:00:00 2001 From: Tavo Nieves J Date: Fri, 20 Nov 2020 10:54:08 -0500 Subject: [PATCH] Added seeFormHasErrors function --- src/Codeception/Module/Symfony.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Codeception/Module/Symfony.php b/src/Codeception/Module/Symfony.php index b2c6af65..b7c3452d 100644 --- a/src/Codeception/Module/Symfony.php +++ b/src/Codeception/Module/Symfony.php @@ -1170,6 +1170,27 @@ public function amLoggedInAs(UserInterface $user, string $firewallName = 'main', $this->client->getCookieJar()->set($cookie); } + /** + * Verifies that there are one or more errors bound to the submitted form. + * + * ``` php + * seeFormHasErrors(); + * ``` + * + * @return void + */ + public function seeFormHasErrors() + { + $formCollector = $this->grabCollector('form', __FUNCTION__); + + $this->assertGreaterThan( + 0, + $formCollector->getData()->offsetGet('nb_errors'), + 'Expecting that the form has errors, but there were none!' + ); + } + /** * Grab a Doctrine entity repository. * Works with objects, entities, repositories, and repository interfaces.