mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Fixed: a bug for range generatoion during week-end
The range generator failed during week-end, because no range is selected (lastStart and endDate is null). with this commit, the rangeGenerator may return null instead of an array, which means no sms will be send.
This commit is contained in:
@@ -22,6 +22,7 @@ use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Repository\CalendarRepository;
|
||||
use Chill\CalendarBundle\Service\ShortMessageNotification\CalendarForShortMessageProvider;
|
||||
use Chill\CalendarBundle\Service\ShortMessageNotification\DefaultRangeGenerator;
|
||||
use Chill\CalendarBundle\Service\ShortMessageNotification\RangeGeneratorInterface;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
@@ -37,6 +38,32 @@ final class CalendarForShortMessageProviderTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
public function testGenerateRangeIsNull()
|
||||
{
|
||||
$calendarRepository = $this->prophesize(CalendarRepository::class);
|
||||
$calendarRepository->findByNotificationAvailable(
|
||||
Argument::type(DateTimeImmutable::class),
|
||||
Argument::type(DateTimeImmutable::class),
|
||||
Argument::type('int'),
|
||||
Argument::exact(0)
|
||||
)->shouldBeCalledTimes(0);
|
||||
$rangeGenerator = $this->prophesize(RangeGeneratorInterface::class);
|
||||
$rangeGenerator->generateRange(Argument::type(DateTimeImmutable::class))->willReturn(null);
|
||||
|
||||
$em = $this->prophesize(EntityManagerInterface::class);
|
||||
$em->clear()->shouldNotBeCalled();
|
||||
|
||||
$provider = new CalendarForShortMessageProvider(
|
||||
$calendarRepository->reveal(),
|
||||
$em->reveal(),
|
||||
$rangeGenerator->reveal()
|
||||
);
|
||||
|
||||
$calendars = iterator_to_array($provider->getCalendars(new DateTimeImmutable('now')));
|
||||
|
||||
$this->assertEquals(0, count($calendars));
|
||||
}
|
||||
|
||||
public function testGetCalendars()
|
||||
{
|
||||
$calendarRepository = $this->prophesize(CalendarRepository::class);
|
||||
|
Reference in New Issue
Block a user