Agenda: Fix test

pull/4020/head
Julio 3 years ago
parent 6ccf45bf52
commit 68c788d85a
  1. 23
      src/CoreBundle/DataProvider/Extension/CCalendarEventExtension.php
  2. 9
      tests/CourseBundle/Repository/CCalendarEventRepositoryTest.php

@ -81,24 +81,17 @@ final class CCalendarEventExtension implements QueryCollectionExtensionInterface
$startDate = $request->query->get('startDate');
$endDate = $request->query->get('endDate');
$qb->andWhere(
"
if (!empty($startDate) && !empty($endDate)) {
$qb->andWhere(
"
$alias.startDate BETWEEN :start AND :end OR
$alias.endDate BETWEEN :start AND :end
"
);
/*OR
(
$alias.startDate IS NOT NULL AND $alias.endDate IS NOT NULL AND
YEAR($alias.startDate) = YEAR($alias.endDate) AND
MONTH(':start') BETWEEN MONTH($alias.startDate) AND MONTH($alias.endDate)
)*/
$qb
->setParameter('start', $startDate)
->setParameter('end', $endDate)
;
);
$qb
->setParameter('start', $startDate)
->setParameter('end', $endDate);
}
if (empty($courseId)) {
$qb

@ -47,7 +47,6 @@ class CCalendarEventRepositoryTest extends AbstractApiTest
$user = $this->createUser('test');
$resourceNodeId = $user->getResourceNode()->getId();
$em = $this->getEntityManager();
$repo = self::getContainer()->get(CCalendarEventRepository::class);
// Current server local time (check your php.ini).
@ -142,8 +141,8 @@ class CCalendarEventRepositoryTest extends AbstractApiTest
// 3. Get events filter by date, search for a very old date. Result: no events.
$response = $this->createClientWithCredentials($token)->request('GET', '/api/c_calendar_events', [
'query' => [
'startDate[after]' => '2009-02-14T18:00:00+02:00',
'endDate[before]' => '2009-02-14T19:00:00+02:00',
'startDate' => '2009-02-14T18:00:00+02:00',
'endDate' => '2009-02-14T19:00:00+02:00',
],
]);
$this->assertCount(0, $response->toArray()['hydra:member']);
@ -151,8 +150,8 @@ class CCalendarEventRepositoryTest extends AbstractApiTest
// 4. Get events for valid date.
$response = $this->createClientWithCredentials($token)->request('GET', '/api/c_calendar_events', [
'query' => [
'startDate[after]' => '2040-06-01T09:00:00+02:00',
'endDate[before]' => '2040-06-30T23:00:00+02:00',
'startDate' => '2040-06-01T09:00:00+02:00',
'endDate' => '2040-06-30T23:00:00+02:00',
],
]);
$this->assertCount(1, $response->toArray()['hydra:member']);

Loading…
Cancel
Save