Refactoring Tests/Controller/AccompanyingPeriodControllerTest.php : indentation and adding doc

This commit is contained in:
Marc Ducobu 2015-08-24 15:54:13 +02:00
parent 471bace86d
commit 4aeba2019d

View File

@ -37,22 +37,13 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive;
*/ */
class AccompanyingPeriodControllerTest extends WebTestCase class AccompanyingPeriodControllerTest extends WebTestCase
{ {
/** /** @var \Symfony\Component\BrowserKit\Client */
*
* @var \Symfony\Component\BrowserKit\Client
*/
protected $client; protected $client;
/** /** @var Person The person on which the form is applied*/
*
* @var Person
*/
protected $person; protected $person;
/** /** @var \Doctrine\ORM\EntityManagerInterface */
*
* @var \Doctrine\ORM\EntityManagerInterface
*/
protected static $em; protected static $em;
const OPENING_INPUT = 'chill_personbundle_accompanyingperiod[openingDate]'; const OPENING_INPUT = 'chill_personbundle_accompanyingperiod[openingDate]';
@ -103,6 +94,10 @@ class AccompanyingPeriodControllerTest extends WebTestCase
static::$em->flush(); static::$em->flush();
} }
/**
* Given an array of periods (key openingDate, closingDate (optioal),
* closingMotive) generate the periods in the db.
*/
protected function generatePeriods(array $periods) protected function generatePeriods(array $periods)
{ {
foreach ($periods as $periodDef) { foreach ($periods as $periodDef) {
@ -119,14 +114,18 @@ class AccompanyingPeriodControllerTest extends WebTestCase
} }
$this->person->addAccompanyingPeriod($period); $this->person->addAccompanyingPeriod($period);
static::$em->persist($period); static::$em->persist($period);
} }
static::$em->flush(); static::$em->flush();
} }
/**
* Get the last value of a closing motive
* @var \Symfony\Component\DomCrawler\Form The form
* @return Chill\PersonBundle\Entity\AccompanyingPeriod The last value of closing
* motive
*/
protected function getLastValueOnClosingMotive(\Symfony\Component\DomCrawler\Form $form) protected function getLastValueOnClosingMotive(\Symfony\Component\DomCrawler\Form $form)
{ {
$values = $form->get(self::CLOSING_MOTIVE_INPUT) $values = $form->get(self::CLOSING_MOTIVE_INPUT)
@ -134,6 +133,10 @@ class AccompanyingPeriodControllerTest extends WebTestCase
return end($values); return end($values);
} }
/**
* Get a random closing motive
* @return Chill\PersonBundle\Entity\AccompanyingPeriod The last closing motive
*/
protected function getRandomClosingMotive() protected function getRandomClosingMotive()
{ {
$motives = static::$em $motives = static::$em