diff --git a/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php b/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php index 8d8ab9b46..301da25e1 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Tests/Controller/AsideActivityControllerTest.php @@ -4,6 +4,8 @@ namespace Chill\AsideActivityBundle\Tests\Controller; use Chill\MainBundle\Test\PrepareClientTrait; use Symfony\Bundle\FrameworkBundle\Test\WebTestCase; +use Chill\AsideActivityBundle\Entity\AsideActivity; +use Doctrine\ORM\EntityManagerInterface; class AccompanyingCourseControllerTest extends WebTestCase @@ -17,11 +19,55 @@ class AccompanyingCourseControllerTest extends WebTestCase $this->client = $this->getClientAuthenticated(); } - public function testNewWithoutUsers() + public function testIndexWithoutUsers() { $this->client->request('GET', '/fr/asideactivity'); - $this->assertResponseSuccessful(); + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); } + public function testNewWithoutUsers() + { + $this->client->request('GET', '/fr/asideactivity/new'); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + } + + /** + * @dataProvider generateAsideActivityId + */ + + public function testEditWithoutUsers(int $asideActivityId) + { + $this->client->request('GET', "/fr/asideactivity/{$asideActivityId}/edit"); + + $this->assertEquals(200, $this->client->getResponse()->getStatusCode()); + } + + public function generateAsideActivityId() + { + self::bootKernel(); + + $qb = self::$container->get(EntityManagerInterface::class) + ->createQueryBuilder(); + + $asideActivityIds = $qb + ->select('DISTINCT asideactivity.id') + ->from(AsideActivity::class, 'asideactivity') + ->innerJoin('asideactivity.agent', 'agent') + ->where($qb->expr()->eq('agent.username', ':center_name')) + ->setParameter('center_name', 'center a_social') + ->setMaxResults(100) + ->getQuery() + ->getResult() + ; + + \shuffle($asideActivityIds); + + yield [ \array_pop($asideActivityIds)['id'] ]; + yield [ \array_pop($asideActivityIds)['id'] ]; + yield [ \array_pop($asideActivityIds)['id'] ]; + } + + } \ No newline at end of file