fix loading calendar range fixtures

This commit is contained in:
Julien Fastré 2022-07-03 22:11:32 +02:00
parent 20b70f9eed
commit accee53f5a
2 changed files with 26 additions and 2 deletions

View File

@ -12,12 +12,18 @@ declare(strict_types=1);
namespace Chill\CalendarBundle\DataFixtures\ORM;
use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Country;
use Chill\MainBundle\Entity\Location;
use Chill\MainBundle\Entity\LocationType;
use Chill\MainBundle\Entity\PostalCode;
use Chill\MainBundle\Repository\UserRepository;
use DateTimeImmutable;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager;
use libphonenumber\PhoneNumberUtil;
class LoadCalendarRange extends Fixture implements FixtureGroupInterface, OrderedFixtureInterface
{
@ -49,6 +55,22 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
$users = $this->userRepository->findAll();
$location = (new Location())
->setAddress($address = new Address())
->setName('Centre A')
->setEmail('centreA@test.chill.social')
->setLocationType($type = new LocationType())
->setPhonenumber1(PhoneNumberUtil::getInstance()->parse('+3287653812'));
$address->setStreet('Rue des Épaules')->setStreetNumber('14')
->setPostcode($postCode = new PostalCode());
$postCode->setCode('4145')->setName('Houte-Si-Plout')->setCountry(
$country = (new Country())->setName(['fr' => 'Pays'])->setCountryCode('ZZ')
);
$manager->persist($country);
$manager->persist($postCode);
$manager->persist($address);
$manager->persist($location);
$days = [
'2021-08-23',
'2021-08-24',
@ -58,6 +80,8 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
'2021-08-31',
'2021-09-01',
'2021-09-02',
(new DateTimeImmutable('tomorrow'))->format('Y-m-d'),
(new DateTimeImmutable('today'))->format('Y-m-d'),
];
$hours = [
@ -76,7 +100,8 @@ class LoadCalendarRange extends Fixture implements FixtureGroupInterface, Ordere
$calendarRange = (new CalendarRange())
->setUser($u)
->setStartDate($startEvent)
->setEndDate($endEvent);
->setEndDate($endEvent)
->setLocation($location);
$manager->persist($calendarRange);
}

View File

@ -14,7 +14,6 @@ namespace Chill\CalendarBundle\RemoteCalendar\Connector;
use Chill\CalendarBundle\Entity\Calendar;
use Chill\CalendarBundle\Entity\CalendarRange;
use Chill\CalendarBundle\Entity\Invite;
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MachineHttpClient;
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\MapCalendarToUser;
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\OnBehalfOfUserHttpClient;
use Chill\CalendarBundle\RemoteCalendar\Connector\MSGraph\OnBehalfOfUserTokenStorage;