mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 22:04:23 +00:00
Refactoring Tests/Controller/AccompanyingPeriodControllerTest.php : indentation and adding doc
This commit is contained in:
parent
471bace86d
commit
4aeba2019d
@ -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]';
|
||||||
@ -80,13 +71,13 @@ class AccompanyingPeriodControllerTest extends WebTestCase
|
|||||||
));
|
));
|
||||||
|
|
||||||
$center = static::$em->getRepository('ChillMainBundle:Center')
|
$center = static::$em->getRepository('ChillMainBundle:Center')
|
||||||
->findOneBy(array('name' => 'Center A'));
|
->findOneBy(array('name' => 'Center A'));
|
||||||
|
|
||||||
$this->person = (new Person(new \DateTime('2015-01-05')))
|
$this->person = (new Person(new \DateTime('2015-01-05')))
|
||||||
->setFirstName('Roland')
|
->setFirstName('Roland')
|
||||||
->setLastName('Gallorime')
|
->setLastName('Gallorime')
|
||||||
->setCenter($center)
|
->setCenter($center)
|
||||||
->setGender(Person::MALE_GENDER);
|
->setGender(Person::MALE_GENDER);
|
||||||
|
|
||||||
static::$em->persist($this->person);
|
static::$em->persist($this->person);
|
||||||
static::$em->flush();
|
static::$em->flush();
|
||||||
@ -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,26 +114,34 @@ 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)
|
||||||
->availableOptionValues();
|
->availableOptionValues();
|
||||||
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
|
||||||
->getRepository('ChillPersonBundle:AccompanyingPeriod\ClosingMotive')
|
->getRepository('ChillPersonBundle:AccompanyingPeriod\ClosingMotive')
|
||||||
->findAll();
|
->findAll();
|
||||||
return end($motives);
|
return end($motives);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user