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