From d70be5ea85501e1ff313a760687c07c914ea8b49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 18 Jan 2016 22:30:57 +0100 Subject: [PATCH] add person detection improvement: inversion firstName<->lastName --- Controller/PersonController.php | 4 ++- .../Controller/PersonControllerCreateTest.php | 25 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/Controller/PersonController.php b/Controller/PersonController.php index 3c461d1ba..60e9f7eb7 100644 --- a/Controller/PersonController.php +++ b/Controller/PersonController.php @@ -302,7 +302,9 @@ class PersonController extends Controller $dql = 'SELECT p from ChillPersonBundle:Person p WHERE ' . 'LOWER(p.firstName) LIKE LOWER(:firstName)' - . ' OR LOWER(p.lastName) LIKE LOWER(:lastName)'; + . ' OR LOWER(p.lastName) LIKE LOWER(:lastName)' + . ' OR LOWER(p.firstName) LIKE LOWER(:lastName)' + . ' OR LOWER(p.lastName) LIKE LOWER(:firstName)'; $query->setParameter('firstName', $form['firstName']->getData()) ->setParameter('lastName', $form['lastName']->getData()); diff --git a/Tests/Controller/PersonControllerCreateTest.php b/Tests/Controller/PersonControllerCreateTest.php index 83acbbf7b..5f0a33fab 100644 --- a/Tests/Controller/PersonControllerCreateTest.php +++ b/Tests/Controller/PersonControllerCreateTest.php @@ -240,6 +240,31 @@ class PersonControllerCreateTest extends WebTestCase } + public function testReviewExistingDetectionInversedLastNameWithFirstName() + { + $client = $this->getAuthenticatedClient(); + + $crawler = $client->request('GET', '/fr/person/new'); + + //test the page is loaded before continuing + $this->assertTrue($client->getResponse()->isSuccessful()); + + $form = $crawler->selectButton("Ajouter la personne")->form(); + $form = $this->fillAValidCreationForm($form, 'Charline', 'dd'); + $client->submit($form); + + $this->assertContains('Depardieu', $client->getCrawler()->text(), + "check that the page has detected the lastname of a person existing in database"); + + //inversion + $form = $crawler->selectButton("Ajouter la personne")->form(); + $form = $this->fillAValidCreationForm($form, 'dd', 'Charline'); + $client->submit($form); + + $this->assertContains('Depardieu', $client->getCrawler()->text(), + "check that the page has detected the lastname of a person existing in database"); + } + public static function tearDownAfterClass() { static::bootKernel();