mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Remove creation of AccompanyingPeriod on person creation
This commit is contained in:
@@ -93,8 +93,6 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
'The page contains a "gender" input');
|
||||
$this->assertTrue($form->has(self::BIRTHDATE_INPUT),
|
||||
'The page has a "date of birth" input');
|
||||
$this->assertTrue($form->has(self::CREATEDATE_INPUT),
|
||||
'The page contains a "creation date" input');
|
||||
|
||||
$genderType = $form->get(self::GENDER_INPUT);
|
||||
$this->assertEquals('radio', $genderType->getType(),
|
||||
@@ -107,10 +105,6 @@ class PersonControllerCreateTest extends WebTestCase
|
||||
'gender has "femme" option');
|
||||
$this->assertFalse($genderType->hasValue(), 'The gender input is not checked');
|
||||
|
||||
$today = new \DateTime();
|
||||
$this->assertEquals($today->format('d-m-Y'), $form->get(self::CREATEDATE_INPUT)
|
||||
->getValue(), 'The creation date input has the current date by default');
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@@ -45,11 +45,12 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
public function testGetCurrentAccompanyingPeriod()
|
||||
{
|
||||
$d = new \DateTime('yesterday');
|
||||
$p = new Person($d);
|
||||
$p = new Person();
|
||||
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
|
||||
|
||||
$period = $p->getCurrentAccompanyingPeriod();
|
||||
|
||||
$this->assertInstanceOf('Chill\PersonBundle\Entity\AccompanyingPeriod', $period);
|
||||
$this->assertInstanceOf(AccompanyingPeriod::class, $period);
|
||||
$this->assertTrue($period->isOpen());
|
||||
$this->assertEquals($d, $period->getOpeningDate());
|
||||
|
||||
@@ -67,7 +68,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
public function testAccompanyingPeriodOrderWithUnorderedAccompanyingPeriod()
|
||||
{
|
||||
$d = new \DateTime("2013/2/1");
|
||||
$p = new Person($d);
|
||||
$p = new Person();
|
||||
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
|
||||
|
||||
$e = new \DateTime("2013/3/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
|
||||
@@ -93,7 +95,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
*/
|
||||
public function testAccompanyingPeriodOrderSameDateOpening() {
|
||||
$d = new \DateTime("2013/2/1");
|
||||
$p = new Person($d);
|
||||
$p = new Person();
|
||||
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
|
||||
|
||||
$g = new \DateTime("2013/4/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($g);
|
||||
@@ -120,7 +123,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
*/
|
||||
public function testDateCoveringWithCoveringAccompanyingPeriod() {
|
||||
$d = new \DateTime("2013/2/1");
|
||||
$p = new Person($d);
|
||||
$p = new Person();
|
||||
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
|
||||
|
||||
$e = new \DateTime("2013/3/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
|
||||
@@ -145,7 +149,8 @@ class PersonTest extends \PHPUnit\Framework\TestCase
|
||||
*/
|
||||
public function testNotOpenAFileReOpenedLater() {
|
||||
$d = new \DateTime("2013/2/1");
|
||||
$p = new Person($d);
|
||||
$p = new Person();
|
||||
$p->addAccompanyingPeriod(new AccompanyingPeriod($d));
|
||||
|
||||
$e = new \DateTime("2013/3/1");
|
||||
$period = $p->getCurrentAccompanyingPeriod()->setClosingDate($e);
|
||||
|
@@ -20,9 +20,11 @@
|
||||
|
||||
namespace Chill\PersonBundle\Tests\Timeline;
|
||||
|
||||
use Symfony\Bundle\SecurityBundle\Tests\Functional\WebTestCase;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* This class tests entries are shown for closing and opening
|
||||
@@ -31,22 +33,20 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @author Champs Libres <info@champs-libres.coop>
|
||||
*/
|
||||
class TimelineAccompanyingPeriodTest extends \Chill\PersonBundle\Tests\Controller\AccompanyingPeriodControllerTest
|
||||
class TimelineAccompanyingPeriodTest extends WebTestCase
|
||||
{
|
||||
public function testEntriesAreShown()
|
||||
use PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* @dataProvider provideDataPersonWithAccompanyingPeriod
|
||||
*/
|
||||
public function testEntriesAreShown($personId)
|
||||
{
|
||||
$this->generatePeriods(array(
|
||||
[
|
||||
'openingDate' => '2014-01-01',
|
||||
'closingDate' => '2014-12-31',
|
||||
'closingMotive' => $this->getRandomClosingMotive()
|
||||
]
|
||||
));
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$crawler = $client->request('GET', "/en/person/{$personId}/timeline");
|
||||
|
||||
$crawler = $this->client->request('GET', '/en/person/'
|
||||
.$this->person->getId().'/timeline');
|
||||
|
||||
$this->assertTrue($this->client->getResponse()->isSuccessful(),
|
||||
$this->assertTrue($client->getResponse()->isSuccessful(),
|
||||
"the timeline page loads sucessfully");
|
||||
$this->assertGreaterThan(0, $crawler->filter('.timeline div')->count(),
|
||||
"the timeline page contains multiple div inside a .timeline element");
|
||||
@@ -57,5 +57,34 @@ class TimelineAccompanyingPeriodTest extends \Chill\PersonBundle\Tests\Controlle
|
||||
$crawler->Filter('.timeline')->text(),
|
||||
"the text 'Une période d'accompagnement a été fermée' is present");
|
||||
}
|
||||
|
||||
public function provideDataPersonWithAccompanyingPeriod()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$qb = self::$container->get(EntityManagerInterface::class)
|
||||
->createQueryBuilder()
|
||||
;
|
||||
$personIds = $qb
|
||||
->from(Person::class, 'p')
|
||||
->join('p.accompanyingPeriodParticipations', 'part')
|
||||
->join('part.accompanyingPeriod', 'period')
|
||||
->join('p.center', 'center')
|
||||
->select('p.id')
|
||||
->where($qb->expr()->isNotNull('period.closingDate'))
|
||||
->andWhere($qb->expr()->eq('center.name', ':center'))
|
||||
->setParameter('center', 'Center A')
|
||||
->setMaxResults(1000)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
|
||||
\shuffle($personIds);
|
||||
|
||||
yield [ \array_pop($personIds)['id'] ];
|
||||
yield [ \array_pop($personIds)['id'] ];
|
||||
yield [ \array_pop($personIds)['id'] ];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user