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;
|
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\Person;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class tests entries are shown for closing and opening
|
* 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 Julien Fastré <julien.fastre@champs-libres.coop>
|
||||||
* @author Champs Libres <info@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(
|
$client = $this->getClientAuthenticated();
|
||||||
[
|
|
||||||
'openingDate' => '2014-01-01',
|
$crawler = $client->request('GET', "/en/person/{$personId}/timeline");
|
||||||
'closingDate' => '2014-12-31',
|
|
||||||
'closingMotive' => $this->getRandomClosingMotive()
|
|
||||||
]
|
|
||||||
));
|
|
||||||
|
|
||||||
$crawler = $this->client->request('GET', '/en/person/'
|
$this->assertTrue($client->getResponse()->isSuccessful(),
|
||||||
.$this->person->getId().'/timeline');
|
|
||||||
|
|
||||||
$this->assertTrue($this->client->getResponse()->isSuccessful(),
|
|
||||||
"the timeline page loads sucessfully");
|
"the timeline page loads sucessfully");
|
||||||
$this->assertGreaterThan(0, $crawler->filter('.timeline div')->count(),
|
$this->assertGreaterThan(0, $crawler->filter('.timeline div')->count(),
|
||||||
"the timeline page contains multiple div inside a .timeline element");
|
"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(),
|
$crawler->Filter('.timeline')->text(),
|
||||||
"the text 'Une période d'accompagnement a été fermée' is present");
|
"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