From 0a1ff9e1414c6141f0ce046b2ef39686ba017dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Thu, 29 Jan 2015 18:42:42 +0100 Subject: [PATCH] complete tests for person edition close #405 add a test on false date, but this made the validation fail. --- ...rTest.php => PersonControllerCreateTest.php} | 2 +- ...eTest.php => PersonControllerUpdateTest.php} | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) rename Tests/Controller/{PersonControllerTest.php => PersonControllerCreateTest.php} (99%) rename Tests/Controller/{PersonUpdateTest.php => PersonControllerUpdateTest.php} (94%) diff --git a/Tests/Controller/PersonControllerTest.php b/Tests/Controller/PersonControllerCreateTest.php similarity index 99% rename from Tests/Controller/PersonControllerTest.php rename to Tests/Controller/PersonControllerCreateTest.php index 8c0f91072..cbc6444e6 100644 --- a/Tests/Controller/PersonControllerTest.php +++ b/Tests/Controller/PersonControllerCreateTest.php @@ -9,7 +9,7 @@ use Symfony\Component\HttpFoundation\RedirectResponse; /** * Test creation and deletion for persons */ -class PersonControllerTest extends WebTestCase +class PersonControllerCreateTest extends WebTestCase { const FIRSTNAME_INPUT = 'chill_personbundle_person_creation[firstName]'; diff --git a/Tests/Controller/PersonUpdateTest.php b/Tests/Controller/PersonControllerUpdateTest.php similarity index 94% rename from Tests/Controller/PersonUpdateTest.php rename to Tests/Controller/PersonControllerUpdateTest.php index ec0228a6d..20b423151 100644 --- a/Tests/Controller/PersonUpdateTest.php +++ b/Tests/Controller/PersonControllerUpdateTest.php @@ -30,7 +30,7 @@ use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; * * @author Julien Fastré */ -class PersonUpdateTest extends WebTestCase +class PersonControllerUpdateTest extends WebTestCase { /** * @@ -128,8 +128,10 @@ class PersonUpdateTest extends WebTestCase $this->client->submit($form); $this->em->refresh($this->person); - $this->assertTrue($this->client->getResponse()->isRedirect($this->seeUrl)); - $this->assertEquals($value, $callback($this->person)); + $this->assertTrue($this->client->getResponse()->isRedirect($this->seeUrl), + 'the page is redirected to general view'); + $this->assertEquals($value, $callback($this->person), + 'the value '.$field.' is updated in db'); } /** @@ -176,8 +178,10 @@ class PersonUpdateTest extends WebTestCase $crawler = $this->client->submit($form); - $this->assertFalse($this->client->getResponse()->isRedirect()); - $this->assertGreaterThan(0, $crawler->filter('.error')->count()); + $this->assertFalse($this->client->getResponse()->isRedirect(), + 'the page is not redirected to /general'); + $this->assertGreaterThan(0, $crawler->filter('.error')->count(), + 'a element .error is shown'); } public function providesInvalidFieldsValues() @@ -186,7 +190,8 @@ class PersonUpdateTest extends WebTestCase ['firstName', $this->getVeryLongText()], ['lastName', $this->getVeryLongText()], ['firstName', ''], - ['lastName', ''] + ['lastName', ''], + ['dateOfBirth', 'false date'] ); }