From 9ea23987a3c9c9367ad43f2d7b8706522093dbfa Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Fri, 6 Feb 2015 14:38:29 +0100 Subject: [PATCH] PersonHistoryFile -> AccompanyingPeriod - refs #275 - debug --- Entity/Person.php | 2 +- ...gPeriod.yml => AccompanyingPeriod.orm.yml} | 0 Resources/config/doctrine/Person.orm.yml | 2 +- .../AccompanyingPeriodControllerTest.php | 46 +++++++++---------- 4 files changed, 25 insertions(+), 25 deletions(-) rename Resources/config/doctrine/{AccompanyingPeriod.yml => AccompanyingPeriod.orm.yml} (100%) diff --git a/Entity/Person.php b/Entity/Person.php index 5dae44c33..82445d3cb 100644 --- a/Entity/Person.php +++ b/Entity/Person.php @@ -134,7 +134,7 @@ class Person { $this->history->add($period); } - public function removeHistoryFile(PersonHistoryFile $history) { + public function removeHistoryFile(AccompanyingPeriod $history) { $this->history->remove($history); } diff --git a/Resources/config/doctrine/AccompanyingPeriod.yml b/Resources/config/doctrine/AccompanyingPeriod.orm.yml similarity index 100% rename from Resources/config/doctrine/AccompanyingPeriod.yml rename to Resources/config/doctrine/AccompanyingPeriod.orm.yml diff --git a/Resources/config/doctrine/Person.orm.yml b/Resources/config/doctrine/Person.orm.yml index 63f0381b4..fc57c6037 100644 --- a/Resources/config/doctrine/Person.orm.yml +++ b/Resources/config/doctrine/Person.orm.yml @@ -53,7 +53,7 @@ Chill\PersonBundle\Entity\Person: nullable: true oneToMany: history: - targetEntity: PersonHistoryFile + targetEntity: AccompanyingPeriod mappedBy: person cascade: [persist, remove, merge, detach] manyToMany: diff --git a/Tests/Controller/AccompanyingPeriodControllerTest.php b/Tests/Controller/AccompanyingPeriodControllerTest.php index 1d2abd882..89b5c1598 100644 --- a/Tests/Controller/AccompanyingPeriodControllerTest.php +++ b/Tests/Controller/AccompanyingPeriodControllerTest.php @@ -2,7 +2,8 @@ /* * Chill is a software for social workers - * Copyright (C) 2015 Julien Fastré + * Copyright (C) 2015, Champs Libres Cooperative SCRLFS, + * * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by @@ -21,7 +22,7 @@ namespace Chill\PersonBundle\Tests\Controller; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; -use Chill\PersonBundle\Entity\PersonHistoryFile as AccompanyingPeriod; +use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive; @@ -50,9 +51,9 @@ class AccompanyingPeriodControllerTest extends WebTestCase */ private static $em; - const OPENING_INPUT = 'cl_chill_personbundle_personhistoryfile[date_opening]'; - const CLOSING_INPUT = 'cl_chill_personbundle_personhistoryfile[date_closing]'; - const CLOSING_MOTIVE_INPUT = 'cl_chill_personbundle_personhistoryfile[closingMotive]'; + const OPENING_INPUT = 'chill_personbundle_accompanyingperiod[date_opening]'; + const CLOSING_INPUT = 'chill_personbundle_accompanyingperiod[date_closing]'; + const CLOSING_MOTIVE_INPUT = 'chill_personbundle_accompanyingperiod[closingMotive]'; public static function setUpBeforeClass() { @@ -102,7 +103,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase ->setClosingMotive($periodDef['closingMotive']); } - $this->person->addHistoryFile($period); + $this->person->addAccompanyingPeriod($period); static::$em->persist($period); @@ -130,7 +131,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase * Test the closing of a periods * * Given that a person as an accompanying period opened since 2015-01-05 - * and we fill the close form (at /en/person/[id]/history/close + * and we fill the close form (at /en/person/[id]/accompanying-period/close * with : dateClosing: 2015-02-01 * with : the last closing motive in list * Then the response should redirect to history view @@ -139,10 +140,9 @@ class AccompanyingPeriodControllerTest extends WebTestCase * @todo */ public function testClosingCurrentPeriod() - { - + { $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/close'); + .$this->person->getId().'/accompanying-period/close'); $form = $crawler->selectButton('Submit')->form(); @@ -154,8 +154,8 @@ class AccompanyingPeriodControllerTest extends WebTestCase $cr = $this->client->submit($form); $this->assertTrue($this->client->getResponse()->isRedirect( - '/en/person/'.$this->person->getId().'/history'), - 'the server redirects to /history page'); + '/en/person/'.$this->person->getId().'/accompanying-period'), + 'the server redirects to /accompanying-period page'); $this->assertGreaterThan(0, $this->client->followRedirect() ->filter('.success')->count(), "a 'success' element is shown"); @@ -165,7 +165,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase * Test the closing of a periods * * Given that a person as an accompanying period opened since 2015-01-05 - * and we fill the close form (at /en/person/[id]/history/close + * and we fill the close form (at /en/person/[id]/accompanying-period/close * with : dateClosing: 2014-01-01 * with : the last closing motive in list * Then the response should redirect to history view @@ -177,7 +177,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase { $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/close'); + .$this->person->getId().'/accompanying-period/close'); $form = $crawler->selectButton('Submit')->form(); @@ -209,7 +209,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase { $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/create'); + .$this->person->getId().'/accompanying-period/create'); $form = $crawler->selectButton('Submit')->form();; $form->get(self::CLOSING_MOTIVE_INPUT) @@ -222,8 +222,8 @@ class AccompanyingPeriodControllerTest extends WebTestCase $this->client->submit($form); $this->assertTrue($this->client->getResponse()->isRedirect( - '/en/person/'.$this->person->getId().'/history'), - 'the server redirects to /history page'); + '/en/person/'.$this->person->getId().'/accompanying-period'), + 'the server redirects to /accompanying-period page'); $this->assertGreaterThan(0, $this->client->followRedirect() ->filter('.success')->count(), "a 'success' element is shown"); @@ -248,7 +248,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase $this->markTestSkipped('this feature is not yet implemented'); $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/create'); + .$this->person->getId().'/accompanying-period/create'); $form = $crawler->selectButton('Submit')->form();; $form->get(self::CLOSING_MOTIVE_INPUT) @@ -285,7 +285,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase $this->markTestSkipped('this feature is not yet implemented'); $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/create'); + .$this->person->getId().'/accompanying-period/create'); $form = $crawler->selectButton('Submit')->form();; $form->get(self::CLOSING_MOTIVE_INPUT) @@ -327,7 +327,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase )); $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/create'); + .$this->person->getId().'/accompanying-period/create'); $form = $crawler->selectButton('Submit')->form();; $form->get(self::CLOSING_MOTIVE_INPUT) @@ -358,7 +358,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase public function testCreatePeriodWithClosingBeforeOpeningFails() { $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/create'); + .$this->person->getId().'/accompanying-period/create'); $form = $crawler->selectButton('Submit')->form();; $form->get(self::CLOSING_MOTIVE_INPUT) @@ -400,7 +400,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase )); $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/create'); + .$this->person->getId().'/accompanying-period/create'); $form = $crawler->selectButton('Submit')->form();; $form->get(self::CLOSING_MOTIVE_INPUT) @@ -442,7 +442,7 @@ class AccompanyingPeriodControllerTest extends WebTestCase )); $crawler = $this->client->request('GET', '/en/person/' - .$this->person->getId().'/history/create'); + .$this->person->getId().'/accompanying-period/create'); $form = $crawler->selectButton('Submit')->form();; $form->get(self::CLOSING_MOTIVE_INPUT)