mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix test for accompanying period
This commit is contained in:
parent
19bfeacc9a
commit
81a8a6ed03
@ -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 = $this->client->request('GET', '/en/person/'
|
||||
.$this->person->getId().'/timeline');
|
||||
$crawler = $client->request('GET', "/en/person/{$personId}/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");
|
||||
@ -58,4 +58,33 @@ class TimelineAccompanyingPeriodTest extends \Chill\PersonBundle\Tests\Controlle
|
||||
"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'] ];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user