mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge commit 'a9ce72034be03f5c84799f5982f97f515900504a'
This commit is contained in:
commit
47d6270b7f
@ -33,6 +33,8 @@
|
|||||||
</testsuite>
|
</testsuite>
|
||||||
<testsuite name="AsideActivityBundle">
|
<testsuite name="AsideActivityBundle">
|
||||||
<directory suffix="Test.php">src/Bundle/ChillAsideActivityBundle/src/Tests/</directory>
|
<directory suffix="Test.php">src/Bundle/ChillAsideActivityBundle/src/Tests/</directory>
|
||||||
|
<testsuite name="CalendarBundle">
|
||||||
|
<directory suffix="Test.php">src/Bundle/ChillCalendarBundle/Tests/</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
|
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace Chill\CalendarBundle\Tests\Controller;
|
namespace Chill\CalendarBundle\Tests\Controller;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Repository\AccompanyingPeriodRepository;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||||
@ -9,58 +11,63 @@ use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
|||||||
class CalendarControllerTest extends WebTestCase
|
class CalendarControllerTest extends WebTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup before the first test of this class (see phpunit doc)
|
|
||||||
*/
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
static::bootKernel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Setup before each test method (see phpunit doc)
|
* Setup before each test method (see phpunit doc)
|
||||||
*/
|
*/
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
|
static::bootKernel();
|
||||||
$this->client = static::createClient(array(), array(
|
$this->client = static::createClient(array(), array(
|
||||||
'PHP_AUTH_USER' => 'center a_social',
|
'PHP_AUTH_USER' => 'center a_social',
|
||||||
'PHP_AUTH_PW' => 'password',
|
'PHP_AUTH_PW' => 'password',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAccompanyingPeriodFromFixtures(): AccompanyingPeriod
|
public function provideAccompanyingPeriod(): iterable
|
||||||
{
|
{
|
||||||
$em = static::$kernel->getContainer()
|
static::bootKernel();
|
||||||
->get('doctrine.orm.entity_manager');
|
$em= static::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
$accompanying_period = $em->getRepository('ChillPersonBundle:AccompanyingPeriod')->find(1);
|
$nb = $em->createQueryBuilder()
|
||||||
|
->from(AccompanyingPeriod::class, 'ac')
|
||||||
|
->select('COUNT(ac) AS nb')
|
||||||
|
->getQuery()
|
||||||
|
->getSingleScalarResult()
|
||||||
|
;
|
||||||
|
|
||||||
if ($accompanying_period === NULL) {
|
yield [ $em->createQueryBuilder()
|
||||||
throw new \RuntimeException("We need an accompanying course with id = 1. Did you add fixtures ?");
|
->from(AccompanyingPeriod::class, 'ac')
|
||||||
}
|
->select('ac.id')
|
||||||
|
->setFirstResult(\random_int(0, $nb))
|
||||||
return $accompanying_period;
|
->setMaxResults(1)
|
||||||
|
->getQuery()
|
||||||
|
->getSingleScalarResult()
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testList()
|
/**
|
||||||
|
* @dataProvider provideAccompanyingPeriod
|
||||||
|
*/
|
||||||
|
public function testList(int $accompanyingPeriodId)
|
||||||
{
|
{
|
||||||
$this->client->request(
|
$this->client->request(
|
||||||
Request::METHOD_GET,
|
Request::METHOD_GET,
|
||||||
sprintf('/fr/calendar/?accompanying_period_id=%d', $this->getAccompanyingPeriodFromFixtures()->getId())
|
sprintf('/fr/calendar/calendar/?accompanying_period_id=%d', $accompanyingPeriodId)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
public function testNew()
|
* @dataProvider provideAccompanyingPeriod
|
||||||
|
*/
|
||||||
|
public function testNew(int $accompanyingPeriodId)
|
||||||
{
|
{
|
||||||
$this->client->request(
|
$this->client->request(
|
||||||
Request::METHOD_GET,
|
Request::METHOD_GET,
|
||||||
sprintf('/fr/calendar/new?accompanying_period_id=%d', $this->getAccompanyingPeriodFromFixtures()->getId())
|
sprintf('/fr/calendar/calendar/new?accompanying_period_id=%d', $accompanyingPeriodId)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
$this->assertEquals(200, $this->client->getResponse()->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user