diff --git a/src/Bundle/ChillPersonBundle/Controller/PersonController.php b/src/Bundle/ChillPersonBundle/Controller/PersonController.php index 77a564157..c390565b5 100644 --- a/src/Bundle/ChillPersonBundle/Controller/PersonController.php +++ b/src/Bundle/ChillPersonBundle/Controller/PersonController.php @@ -275,7 +275,7 @@ final class PersonController extends AbstractController return $this->redirectToRoute('chill_person_general_edit', ['person_id' => $person->getId()]); } - } elseif ($request->getMethod() === Request::METHOD_POST) { + } elseif ($request->getMethod() === Request::METHOD_POST && !$form->isValid()) { $this->addFlash('error', $this->translator->trans('This form contains errors')); } diff --git a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php index 75d7ad1e0..ef4fdc9c9 100644 --- a/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php +++ b/src/Bundle/ChillPersonBundle/Tests/Controller/PersonControllerCreateTest.php @@ -63,7 +63,7 @@ class PersonControllerCreateTest extends WebTestCase $creationForm->get(self::LASTNAME_INPUT)->setValue($lastname.'_'.uniqid()); $creationForm->get(self::GENDER_INPUT)->select("man"); $date = new \DateTime('1947-02-01'); - $creationForm->get(self::BIRTHDATE_INPUT)->setValue($date->format('d-m-Y')); + $creationForm->get(self::BIRTHDATE_INPUT)->setValue($date->format('Y-m-d')); return $creationForm; } @@ -114,15 +114,18 @@ class PersonControllerCreateTest extends WebTestCase * * @param Form $form * @return string The id of the created person - * @depends testAddAPersonPage */ - public function testValidForm(Form $form) + public function testValidForm() { + $client = $this->client; + $crawler = $client->request('GET', '/fr/person/new'); + + $form = $crawler->selectButton("Ajouter la personne")->form(); $this->fillAValidCreationForm($form); $client = $this->client; - $crawler = $client->submit($form); + $client->submit($form); - $this->assertTrue((bool)$client->getResponse()->isRedirect(), + $this->assertTrue($client->getResponse()->isRedirect(), "a valid form redirect to url /{_locale}/person/{personId}/general/edit"); $client->followRedirect();