Format code
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
fdac0052a5
commit
8c63dc09f2
|
@ -43,7 +43,7 @@ class CleanUpOutdatedBookingsJob extends TimedJob {
|
|||
BookingService $service,
|
||||
LoggerInterface $logger) {
|
||||
parent::__construct($time);
|
||||
$this->setInterval(24*60*60);
|
||||
$this->setInterval(24 * 60 * 60);
|
||||
$this->service = $service;
|
||||
$this->logger = $logger;
|
||||
}
|
||||
|
|
|
@ -198,7 +198,7 @@ class BookingController extends Controller {
|
|||
public function confirmBooking(string $token): TemplateResponse {
|
||||
try {
|
||||
$booking = $this->bookingService->findByToken($token);
|
||||
} catch(ClientException $e) {
|
||||
} catch (ClientException $e) {
|
||||
$this->logger->warning($e->getMessage(), ['exception' => $e]);
|
||||
return new TemplateResponse(
|
||||
Application::APP_ID,
|
||||
|
@ -220,7 +220,7 @@ class BookingController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
$link = $this->urlGenerator->linkToRouteAbsolute( 'calendar.appointment.show', [ 'token' => $config->getToken() ]);
|
||||
$link = $this->urlGenerator->linkToRouteAbsolute('calendar.appointment.show', [ 'token' => $config->getToken() ]);
|
||||
try {
|
||||
$booking = $this->bookingService->confirmBooking($booking, $config);
|
||||
} catch (ClientException $e) {
|
||||
|
|
|
@ -111,5 +111,4 @@ class AppointmentConfigMapper extends QBMapper {
|
|||
|
||||
return $qb->executeStatement();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ namespace OCA\Calendar\Db;
|
|||
|
||||
use JsonSerializable;
|
||||
use OCP\AppFramework\Db\Entity;
|
||||
use Safe\DateTimeImmutable;
|
||||
|
||||
/**
|
||||
* @method int getId()
|
||||
|
|
|
@ -26,7 +26,6 @@ declare(strict_types=1);
|
|||
namespace OCA\Calendar\Db;
|
||||
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
use OCP\AppFramework\Db\MultipleObjectsReturnedException;
|
||||
use OCP\AppFramework\Db\QBMapper;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\DB\Exception as DbException;
|
||||
|
@ -68,7 +67,5 @@ class BookingMapper extends QBMapper {
|
|||
$qb->delete($this->getTableName())
|
||||
->where($qb->expr()->lt('created_at', $qb->createNamedParameter($limit, IQueryBuilder::PARAM_INT), IQueryBuilder::PARAM_INT));
|
||||
return $qb->executeStatement();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,5 +27,4 @@ declare(strict_types=1);
|
|||
namespace OCA\Calendar\Exception;
|
||||
|
||||
class NoSlotFoundException extends ClientException {
|
||||
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ class AvailabilityGenerator {
|
|||
// E.g. 5m slots should only be available at 10:20 and 10:25, not at 10:17
|
||||
// when the user opens the page at 10:17.
|
||||
// But only do this when the time isn't already a "pretty" time
|
||||
if($earliestStart % $config->getLength() !== 0) {
|
||||
if ($earliestStart % $config->getLength() !== 0) {
|
||||
$roundTo = (int) round(($config->getLength()) / 300) * 300;
|
||||
$earliestStart = (int) ceil($earliestStart / $roundTo) * $roundTo;
|
||||
}
|
||||
|
@ -102,8 +102,8 @@ class AvailabilityGenerator {
|
|||
$applicableSlots = $this->filterDates($start, $slots, $timeZone);
|
||||
|
||||
$intervals = [];
|
||||
foreach($applicableSlots as $slot) {
|
||||
if($slot['end'] <= $earliestStart || $slot['start'] >= $latestEnd) {
|
||||
foreach ($applicableSlots as $slot) {
|
||||
if ($slot['end'] <= $earliestStart || $slot['start'] >= $latestEnd) {
|
||||
continue;
|
||||
}
|
||||
$startSlot = max(
|
||||
|
@ -122,12 +122,12 @@ class AvailabilityGenerator {
|
|||
private function filterDates(int $start, array $availabilityArray, string $timeZone) : array {
|
||||
// First, transform all timestamps to DateTime Objects
|
||||
$availabilityRules = [];
|
||||
foreach($availabilityArray as $key => $availabilitySlots) {
|
||||
if(empty($availabilitySlots)) {
|
||||
foreach ($availabilityArray as $key => $availabilitySlots) {
|
||||
if (empty($availabilitySlots)) {
|
||||
$availabilityRules[$key] = [];
|
||||
continue;
|
||||
}
|
||||
foreach($availabilitySlots as $slot) {
|
||||
foreach ($availabilitySlots as $slot) {
|
||||
$availabilityRules[$key][] = [
|
||||
'start' => (new DateTimeImmutable())->setTimestamp($slot['start']),
|
||||
'end' => (new DateTimeImmutable())->setTimestamp($slot['end'])
|
||||
|
@ -145,20 +145,20 @@ class AvailabilityGenerator {
|
|||
|
||||
$applicable = [];
|
||||
/** @var DateTimeImmutable $item */
|
||||
foreach($period as $item) {
|
||||
foreach ($period as $item) {
|
||||
// get the weekday from our item and select the applicable rule
|
||||
$weekday = strtoupper(mb_strcut($item->format('D'), 0, 2));
|
||||
/** @var DateTimeImmutable[][] $dailyRules */
|
||||
$dailyRules = $availabilityRules[$weekday];
|
||||
// days with no rule should be treated as unavailable
|
||||
if(empty($dailyRules)) {
|
||||
if (empty($dailyRules)) {
|
||||
continue;
|
||||
}
|
||||
foreach($dailyRules as $dailyRule) {
|
||||
foreach ($dailyRules as $dailyRule) {
|
||||
$dStart = $dailyRule['start'];
|
||||
$dEnd = $dailyRule['end'];
|
||||
$applicable[] = [
|
||||
'start' => $item->setTime((int)$dStart->format('H'), (int)$dStart->format('i'))->getTimestamp(),
|
||||
$applicable[] = [
|
||||
'start' => $item->setTime((int)$dStart->format('H'), (int)$dStart->format('i'))->getTimestamp(),
|
||||
'end' => $item->setTime((int)$dEnd->format('H'), (int)$dEnd->format('i'))->getTimestamp(),
|
||||
];
|
||||
}
|
||||
|
|
|
@ -26,10 +26,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Calendar\Service\Appointments;
|
||||
|
||||
use DateTime;
|
||||
use DateTimeImmutable;
|
||||
use OCA\Calendar\Db\AppointmentConfig;
|
||||
use OCA\DAV\CalDAV\CalendarImpl;
|
||||
use OCP\Calendar\Exceptions\CalendarException;
|
||||
use OCP\Calendar\ICreateFromString;
|
||||
use OCP\Calendar\IManager;
|
||||
|
@ -95,7 +93,7 @@ class BookingCalendarWriter {
|
|||
]
|
||||
]);
|
||||
|
||||
if(!empty($description)) {
|
||||
if (!empty($description)) {
|
||||
$vcalendar->VEVENT->add('DESCRIPTION', $description);
|
||||
}
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ class BookingService {
|
|||
|
||||
$tz = new DateTimeZone($booking->getTimezone());
|
||||
$startObj = (new DateTimeImmutable())->setTimestamp($booking->getStart())->setTimezone($tz);
|
||||
if(!$startObj) {
|
||||
if (!$startObj) {
|
||||
throw new ClientException('Could not make sense of booking times');
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ class BookingService {
|
|||
|
||||
try {
|
||||
$tz = new DateTimeZone($timeZone);
|
||||
} catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
throw new InvalidArgumentException('Could not make sense of the timezone', $e->getCode(), $e);
|
||||
}
|
||||
|
||||
|
@ -143,7 +143,7 @@ class BookingService {
|
|||
|
||||
try {
|
||||
$this->mailService->sendConfirmationEmail($booking, $config);
|
||||
} catch( ServiceException $e) {
|
||||
} catch (ServiceException $e) {
|
||||
$this->bookingMapper->delete($booking);
|
||||
throw $e;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ class DailyLimitFilter {
|
|||
|
||||
$events = $this->calendarManger->searchForPrincipal($query);
|
||||
|
||||
$eventsOfSameAppointment = array_filter($events, function(array $event) use ($config) {
|
||||
$eventsOfSameAppointment = array_filter($events, function (array $event) use ($config) {
|
||||
$isAppointment = ($event['objects'][0]['X-NC-APPOINTMENT'][0][0] ?? null) === $config->getToken();
|
||||
$isCancelled = ($event['objects'][0]['STATUS'][0] ?? null) === 'CANCELLED';
|
||||
$isFree = ($event['objects'][0]['TRANSP'][0] ?? null) === 'TRANSPARENT';
|
||||
|
|
|
@ -67,7 +67,6 @@ class MailService {
|
|||
URLGenerator $urlGenerator,
|
||||
IDateTimeFormatter $dateFormatter,
|
||||
IFactory $lFactory) {
|
||||
|
||||
$this->userManager = $userManager;
|
||||
$this->mailer = $mailer;
|
||||
$this->l10n = $l10n;
|
||||
|
@ -86,7 +85,7 @@ class MailService {
|
|||
public function sendConfirmationEmail(Booking $booking, AppointmentConfig $config): void {
|
||||
$user = $this->userManager->get($config->getUserId());
|
||||
|
||||
if($user === null) {
|
||||
if ($user === null) {
|
||||
throw new ServiceException('Could not find organizer');
|
||||
}
|
||||
|
||||
|
@ -118,7 +117,7 @@ class MailService {
|
|||
$bookingUrl = $this->urlGenerator->linkToRouteAbsolute('calendar.booking.confirmBooking', ['token' => $booking->getToken()]);
|
||||
$template->addBodyButton($this->l10n->t('Confirm'), $bookingUrl);
|
||||
|
||||
$bodyText = $this->l10n->t('This confirmation link expires in %s hours.', [(BookingService::EXPIRY /3600)] );
|
||||
$bodyText = $this->l10n->t('This confirmation link expires in %s hours.', [(BookingService::EXPIRY / 3600)]);
|
||||
$template->addBodyText($bodyText);
|
||||
|
||||
$bodyText = $this->l10n->t("If you wish to cancel the appointment after all, please contact your organizer.");
|
||||
|
@ -133,7 +132,7 @@ class MailService {
|
|||
$failed = $this->mailer->send($message);
|
||||
if (count($failed) > 0) {
|
||||
$this->logger->warning('Mail delivery failed for some recipients.');
|
||||
foreach($failed as $fail) {
|
||||
foreach ($failed as $fail) {
|
||||
$this->logger->debug('Failed to deliver email to ' . $fail);
|
||||
throw new ServiceException('Could not send mail for recipient ' . $fail);
|
||||
}
|
||||
|
@ -148,7 +147,6 @@ class MailService {
|
|||
IL10N $l10n,
|
||||
Booking $booking,
|
||||
?string $location = null):void {
|
||||
|
||||
$template->addBodyListItem($booking->getDisplayName(), $l10n->t('Appointment:'));
|
||||
|
||||
$l = $this->lFactory->findGenericLanguage();
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/**
|
||||
* @copyright 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2021 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
|
@ -15,6 +17,7 @@
|
|||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import { getRequestToken } from '@nextcloud/auth'
|
||||
|
|
|
@ -59,7 +59,7 @@ export async function bookSlot(config, slot, displayName, email, description, ti
|
|||
displayName,
|
||||
email,
|
||||
description,
|
||||
timeZone
|
||||
timeZone,
|
||||
})
|
||||
|
||||
return response.data.data
|
||||
|
|
|
@ -3,26 +3,26 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* @author Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
* Calendar App
|
||||
*
|
||||
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* @author Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
script(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-appointments-conflict');
|
||||
|
||||
|
|
|
@ -3,26 +3,26 @@
|
|||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Calendar App
|
||||
*
|
||||
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* @author Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
* Calendar App
|
||||
*
|
||||
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* @author Anna Larch <anna.larch@gmx.net>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 3 of the License, or any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
script(\OCA\Calendar\AppInfo\Application::APP_ID, 'calendar-appointments-confirmation');
|
||||
|
||||
|
|
|
@ -25,10 +25,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace OCA\Calendar\Tests\Integration\Db;
|
||||
|
||||
use BadFunctionCallException;
|
||||
use ChristophWurst\Nextcloud\Testing\DatabaseTransaction;
|
||||
use ChristophWurst\Nextcloud\Testing\TestCase;
|
||||
use InvalidArgumentException;
|
||||
use OCA\Calendar\Db\AppointmentConfig;
|
||||
use OCA\Calendar\Db\AppointmentConfigMapper;
|
||||
use OCP\AppFramework\Db\DoesNotExistException;
|
||||
|
|
|
@ -50,7 +50,7 @@ class CleanupOutdatedBookingJobTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ use OCA\Calendar\Exception\ServiceException;
|
|||
use OCA\Calendar\Service\Appointments\AppointmentConfigService;
|
||||
use OCP\Calendar\ICalendarQuery;
|
||||
use OCP\Contacts\IManager;
|
||||
use OCP\IInitialStateService;
|
||||
use OCP\IRequest;
|
||||
use OCP\IUser;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
@ -63,7 +62,7 @@ class AppointmentConfigControllerTest extends TestCase {
|
|||
protected function setUp():void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ use OCP\IRequest;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Sabre\VObject\Cli;
|
||||
|
||||
class AppointmentControllerTest extends TestCase {
|
||||
|
||||
|
@ -70,7 +69,7 @@ class AppointmentControllerTest extends TestCase {
|
|||
protected function setUp():void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
@ -151,5 +150,4 @@ class AppointmentControllerTest extends TestCase {
|
|||
|
||||
$this->controller->show($token);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ use OCP\IRequest;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Sabre\VObject\Cli;
|
||||
|
||||
class AppointmentControllerVisitorTest extends TestCase {
|
||||
|
||||
|
@ -70,7 +69,7 @@ class AppointmentControllerVisitorTest extends TestCase {
|
|||
protected function setUp():void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
@ -152,6 +151,4 @@ class AppointmentControllerVisitorTest extends TestCase {
|
|||
|
||||
$this->controller->show($token);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -26,15 +26,10 @@ namespace OCA\Calendar\Controller;
|
|||
|
||||
use ChristophWurst\Nextcloud\Testing\TestCase;
|
||||
use DateTimeZone;
|
||||
use OC\AppFramework\Services\InitialState;
|
||||
use OC\URLGenerator;
|
||||
use OCA\Calendar\Db\AppointmentConfig;
|
||||
use OCA\Calendar\Exception\ClientException;
|
||||
use OCA\Calendar\Exception\ServiceException;
|
||||
use OCA\Calendar\Service\Appointments\AppointmentConfigService;
|
||||
use OCA\Calendar\Service\Appointments\BookingService;
|
||||
use OCA\Calendar\Service\Appointments\BookingServiceTest;
|
||||
use OCA\Calendar\Service\Appointments\MailService;
|
||||
use OCP\AppFramework\Services\IInitialState;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\Calendar\ICalendarQuery;
|
||||
|
@ -87,7 +82,7 @@ class BookingControllerTest extends TestCase {
|
|||
protected function setUp():void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
@ -140,7 +135,7 @@ class BookingControllerTest extends TestCase {
|
|||
->method('getAvailableSlots')
|
||||
->with($apptConfg, $sDT, $eDT);
|
||||
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $start, $end,'Europe/Berlin' );
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $start, $end,'Europe/Berlin');
|
||||
}
|
||||
|
||||
public function testGetBookableSlotsInvalidTimezone(): void {
|
||||
|
@ -158,7 +153,7 @@ class BookingControllerTest extends TestCase {
|
|||
->method('getAvailableSlots');
|
||||
|
||||
$this->expectException(\Exception::class);
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $start, $end, 'Hook/Neverland' );
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $start, $end, 'Hook/Neverland');
|
||||
}
|
||||
|
||||
public function testGetBookableSlotsInvalidTimestamps() {
|
||||
|
@ -177,7 +172,7 @@ class BookingControllerTest extends TestCase {
|
|||
$this->logger->expects(self::once())
|
||||
->method('warning');
|
||||
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $end, $start,'Europe/Berlin' );
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $end, $start,'Europe/Berlin');
|
||||
}
|
||||
|
||||
public function testGetBookableSlotsInvalidTimespan() {
|
||||
|
@ -196,7 +191,7 @@ class BookingControllerTest extends TestCase {
|
|||
$this->logger->expects(self::once())
|
||||
->method('warning');
|
||||
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $start, $end,'Europe/Berlin' );
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $start, $end,'Europe/Berlin');
|
||||
}
|
||||
|
||||
public function testGetBookableSlotsDatesInPast() {
|
||||
|
@ -218,6 +213,6 @@ class BookingControllerTest extends TestCase {
|
|||
$this->logger->expects(self::once())
|
||||
->method('warning');
|
||||
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $start, $end,'Europe/Berlin' );
|
||||
$this->controller->getBookableSlots($apptConfg->getId(), $start, $end,'Europe/Berlin');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
@ -101,7 +101,7 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
$slots = $this->generator->generate($config, 1 * 5400 + 1, 2 * 5400 + 1);
|
||||
|
||||
self::assertCount(1, $slots);
|
||||
self::assertEquals($slots[0]->getStart(), 2*5400);
|
||||
self::assertEquals($slots[0]->getStart(), 2 * 5400);
|
||||
self::assertEquals(0, $slots[0]->getStart() % 5400);
|
||||
}
|
||||
|
||||
|
@ -121,10 +121,10 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
$config->setLength(40 * 60);
|
||||
$config->setAvailability(null);
|
||||
|
||||
$slots = $this->generator->generate($config, 1 * 2400 +1, 2 * 2400+1);
|
||||
$slots = $this->generator->generate($config, 1 * 2400 + 1, 2 * 2400 + 1);
|
||||
|
||||
self::assertCount(1, $slots);
|
||||
self::assertEquals($slots[0]->getStart(), 2*2400);
|
||||
self::assertEquals($slots[0]->getStart(), 2 * 2400);
|
||||
self::assertEquals(0, $slots[0]->getStart() % 2400);
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,7 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
$config = new AppointmentConfig();
|
||||
$config->setLength(60 * 60);
|
||||
$config->setAvailability(null);
|
||||
$config->setEnd(10*3600);
|
||||
$config->setEnd(10 * 3600);
|
||||
|
||||
$slots = $this->generator->generate($config, 4 * 3600, 15 * 3600);
|
||||
|
||||
|
@ -144,11 +144,11 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
|
||||
public function testNoAvailabilityAfterEndDate(): void {
|
||||
$this->timeFactory->method('getTime')
|
||||
->willReturn(15*3600);
|
||||
->willReturn(15 * 3600);
|
||||
$config = new AppointmentConfig();
|
||||
$config->setLength(60 * 60);
|
||||
$config->setAvailability(null);
|
||||
$config->setEnd(10*3600);
|
||||
$config->setEnd(10 * 3600);
|
||||
|
||||
$slots = $this->generator->generate($config, 13 * 3600, 15 * 3600);
|
||||
|
||||
|
@ -156,7 +156,6 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testSimpleRule(): void {
|
||||
|
||||
$dateTime = new DateTimeImmutable();
|
||||
$tz = new DateTimeZone('Europe/Vienna');
|
||||
$startTimestamp = $dateTime->setTimezone($tz)
|
||||
|
@ -216,7 +215,6 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testViennaComplexRule(): void {
|
||||
|
||||
$dateTime = new DateTimeImmutable();
|
||||
$tz = new DateTimeZone('Europe/Vienna');
|
||||
$dateTime->setTimezone($tz)->setDate(2021, 11, 22);
|
||||
|
@ -282,7 +280,6 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testViennaComplexRuleWithLunch(): void {
|
||||
|
||||
$dateTime = new DateTimeImmutable();
|
||||
$tz = new DateTimeZone('Europe/Vienna');
|
||||
$dateTime->setTimezone($tz)->setDate(2021, 11, 22);
|
||||
|
@ -348,7 +345,6 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testForAuckland(): void {
|
||||
|
||||
$dateTime = new DateTimeImmutable();
|
||||
$tz = new DateTimeZone('Pacific/Auckland');
|
||||
$startTimestamp = $dateTime->setTimezone($tz)->setDate(2021, 11, 22)->setTime(8,0)->getTimestamp();
|
||||
|
@ -407,7 +403,6 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testAucklandComplexRule(): void {
|
||||
|
||||
$dateTime = new DateTimeImmutable();
|
||||
$tz = new DateTimeZone('Pacific/Auckland');
|
||||
$dateTime->setTimezone($tz)->setDate(2021, 11, 22);
|
||||
|
@ -554,7 +549,6 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
}
|
||||
|
||||
public function testAucklandAndViennaComplexRuleNoResult(): void {
|
||||
|
||||
$dateTime = new DateTimeImmutable();
|
||||
$tz = new DateTimeZone('Europe/Vienna');
|
||||
$dateTime->setTimezone($tz)->setDate(2021, 11, 22);
|
||||
|
@ -618,5 +612,4 @@ class AvailabilityGeneratorTest extends TestCase {
|
|||
$slots = $this->generator->generate($config, $wednesdayMidnight->getTimestamp(), $thursdayMidnight->getTimestamp());
|
||||
self::assertCount(0, $slots);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ class BookingServiceTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
@ -139,7 +139,7 @@ class BookingServiceTest extends TestCase {
|
|||
$intervals = [
|
||||
new Interval(1891378800, 1891382400),
|
||||
new Interval(1891382400, 1891386000),
|
||||
new Interval(1891386000, 1891389600 )
|
||||
new Interval(1891386000, 1891389600)
|
||||
];
|
||||
|
||||
$this->availabilityGenerator->expects(self::once())
|
||||
|
@ -167,7 +167,7 @@ class BookingServiceTest extends TestCase {
|
|||
$intervals = [
|
||||
new Interval(1891378800, 1891382400),
|
||||
new Interval(1891382400, 1891386000),
|
||||
new Interval(1891386000, 1891389600 )
|
||||
new Interval(1891386000, 1891389600)
|
||||
];
|
||||
|
||||
$this->availabilityGenerator->expects(self::once())
|
||||
|
@ -281,7 +281,7 @@ class BookingServiceTest extends TestCase {
|
|||
public function testDeleteOutdated() : void {
|
||||
$this->bookingMapper->expects(self::once())
|
||||
->method('deleteOutdated')
|
||||
->with(24*60*60)
|
||||
->with(24 * 60 * 60)
|
||||
->willReturn(1);
|
||||
|
||||
$this->service->deleteOutdated();
|
||||
|
|
|
@ -47,7 +47,7 @@ class DailyLimitFilterTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ class EventConflictFilterTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ class MailServiceTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,7 @@ class SlotExtrapolatorTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ class SlotExtrapolatorTest extends TestCase {
|
|||
$config->setLength(60 * 60);
|
||||
$config->setIncrement(15 * 60);
|
||||
$availabilityIntervals = [
|
||||
new Interval(0, 60 * 60 *60),
|
||||
new Interval(0, 60 * 60 * 60),
|
||||
];
|
||||
|
||||
$slots = $this->extrapolator->extrapolate($config, $availabilityIntervals);
|
||||
|
|
|
@ -44,7 +44,7 @@ class JsDataServiceTest extends TestCase {
|
|||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
if(!class_exists(ICalendarQuery::class)) {
|
||||
if (!class_exists(ICalendarQuery::class)) {
|
||||
$this->markTestIncomplete();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue