From cb93ab26606d40cdd32a805f3ded329a45128cc3 Mon Sep 17 00:00:00 2001 From: Yuriy Bakhtin Date: Wed, 26 Jun 2024 16:43:55 +0200 Subject: [PATCH 1/2] Use PHP CS Fixer --- .github/workflows/php-cs-fixer.yml | 7 +++++++ docs/CHANGELOG.md | 4 ++++ module.json | 2 +- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/php-cs-fixer.yml diff --git a/.github/workflows/php-cs-fixer.yml b/.github/workflows/php-cs-fixer.yml new file mode 100644 index 00000000..2144827b --- /dev/null +++ b/.github/workflows/php-cs-fixer.yml @@ -0,0 +1,7 @@ +name: PHP CS Fixer + +on: push + +jobs: + tests: + uses: humhub/actions/.github/workflows/module-php-cs-fixer.yml@main diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6777f6a5..b2289080 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,6 +1,10 @@ Changelog ========= +1.5.13 (Unreleased) +---------------------- +- Enh #489: Use PHP CS Fixer + 1.5.12 (June 25, 2024) ---------------------- - Fix #487: Base event notification broken diff --git a/module.json b/module.json index a2cf6f05..7a1d0d8e 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "name": "Calendar", "description": "Create one-time or recurring events, invite and manage attendees, and keep track of all your events with the Calendar module.", "keywords": ["calendar"], - "version": "1.5.12", + "version": "1.5.13", "humhub": { "minVersion": "1.14" }, From 0c0eaa60ec4ff723a8afefe031b0c653aa64b27c Mon Sep 17 00:00:00 2001 From: yurabakhtin Date: Wed, 26 Jun 2024 14:44:22 +0000 Subject: [PATCH 2/2] Autocommit PHP CS Fixer --- Events.php | 2 +- activities/ResponseAttend.php | 1 - activities/ResponseDeclined.php | 1 - activities/ResponseInvited.php | 1 - assets/CalendarAsset.php | 10 +- assets/CalendarBaseAssets.php | 6 +- assets/FullCalendarAssets.php | 2 +- assets/ParticipationFormAssets.php | 2 +- assets/RecurrenceFormAssets.php | 4 +- assets/ReminderFormAssets.php | 4 +- config.php | 2 +- controllers/AbstractConfigController.php | 16 +- controllers/ConfigController.php | 6 +- controllers/FullCalendarController.php | 6 +- controllers/GlobalController.php | 13 +- controllers/IcalController.php | 7 +- controllers/ReminderController.php | 6 +- controllers/ViewController.php | 3 +- controllers/rest/CalendarController.php | 10 +- helpers/CalendarUtils.php | 55 +++--- helpers/RRuleHelper.php | 3 +- helpers/RecurrenceHelper.php | 6 +- helpers/RestDefinitions.php | 9 +- helpers/Url.php | 6 +- integration/BirthdayCalendar.php | 7 +- integration/BirthdayCalendarEntry.php | 11 +- integration/BirthdayCalendarQuery.php | 21 ++- integration/BirthdayCalendarType.php | 8 +- integration/BirthdayUserModel.php | 4 +- interfaces/AbstractCalendarQuery.php | 3 +- interfaces/CalendarItemWrapper.php | 5 +- interfaces/CalendarService.php | 13 +- interfaces/VCalendar.php | 35 ++-- interfaces/event/AbstractCalendarQuery.php | 82 ++++----- interfaces/event/CalendarEntryTypeSetting.php | 3 +- interfaces/event/CalendarEventIF.php | 5 +- interfaces/event/CalendarEventStatusIF.php | 9 +- interfaces/event/CalendarItemTypesEvent.php | 12 +- interfaces/event/CalendarItemsEvent.php | 7 +- interfaces/event/CalendarTypeArrayWrapper.php | 14 +- interfaces/event/CalendarTypeIF.php | 3 +- interfaces/event/CalendarTypeSetting.php | 19 +-- interfaces/event/EditableEventIF.php | 4 +- .../event/FilterNotSupportedException.php | 6 +- .../event/legacy/CalendarEventIFWrapper.php | 49 +++--- .../fullcalendar/FullCalendarEventIF.php | 8 +- .../CalendarEventParticipationIF.php | 11 +- .../recurrence/AbstractRecurrenceQuery.php | 28 ++-- interfaces/recurrence/RecurrenceFormModel.php | 61 ++++--- interfaces/recurrence/RecurrenceQueryIF.php | 6 +- interfaces/recurrence/RecurrentEventIF.php | 2 +- .../widgets/RecurrenceFormWidget.php | 8 +- .../reminder/CalendarEventReminderIF.php | 3 +- jobs/ForceParticipation.php | 2 +- migrations/m140729_223509_initial.php | 1 - migrations/m150706_193118_renamefield.php | 4 +- migrations/m150707_134615_update.php | 1 - migrations/m170721_203204_close_event.php | 2 +- migrations/m171027_185419_uid.php | 2 +- migrations/m171027_185420_reminder.php | 2 +- migrations/m220217_141238_move_files.php | 8 +- .../m240319_152508_fix_notification.php | 4 +- migrations/uninstall.php | 1 - models/CalendarDateFormatter.php | 17 +- models/CalendarEntry.php | 41 +++-- models/CalendarEntryDummy.php | 18 +- models/CalendarEntryParticipant.php | 20 +-- models/CalendarEntryQuery.php | 23 +-- models/CalendarEntryType.php | 9 +- models/ICS.php | 10 +- models/SnippetModuleSettings.php | 22 +-- models/forms/BasicSettings.php | 2 +- models/forms/CalendarEntryForm.php | 20 +-- .../forms/CalendarEntryParticipationForm.php | 8 +- .../CalendarDateFormatValidator.php | 2 +- .../validators/CalendarEndDateValidator.php | 4 +- .../validators/CalendarTypeValidator.php | 4 +- models/fullcalendar/FullCalendar.php | 13 +- .../CalendarEntryParticipation.php | 32 ++-- models/participation/FullCalendarSettings.php | 14 +- .../participation/ParticipationSettings.php | 14 +- .../CalendarEntryRecurrenceQuery.php | 4 +- .../recurrence/CalendarRecurrenceExpand.php | 28 ++-- models/reminder/CalendarReminder.php | 36 ++-- models/reminder/CalendarReminderSent.php | 4 +- models/reminder/ReminderProcessor.php | 8 +- models/reminder/ReminderService.php | 8 +- models/reminder/forms/ReminderSettings.php | 46 +++-- .../CalendarNotificationCategory.php | 2 +- notifications/CanceledEvent.php | 8 +- notifications/Remind.php | 6 +- permissions/CreateEntry.php | 2 +- permissions/ManageEntry.php | 2 +- .../codeception/_support/AcceptanceTester.php | 3 +- tests/codeception/_support/ApiTester.php | 1 + .../codeception/_support/CalendarUnitTest.php | 18 +- .../codeception/_support/FunctionalTester.php | 9 +- .../_support/RecurrenceUnitTest.php | 10 +- tests/codeception/_support/UnitTester.php | 7 +- .../acceptance/CreateSpaceEntryCest.php | 15 +- .../acceptance/GlobalCalendarCest.php | 26 +-- .../acceptance/GlobalGuestCalendarCest.php | 16 +- .../acceptance/ParticipationCest.php | 12 +- tests/codeception/acceptance/SettingsCest.php | 8 +- tests/codeception/acceptance/_bootstrap.php | 2 +- tests/codeception/api/_bootstrap.php | 2 +- tests/codeception/config/unit.php | 2 +- .../fixtures/CalendarEntryFixture.php | 4 +- .../CalendarEntryParticipantFixture.php | 2 +- .../fixtures/CalendarReminderFixture.php | 6 +- .../fixtures/data/calendarEntry.php | 1 - .../data/calendarEntryParticipant.php | 1 - .../fixtures/data/calendarReminder.php | 1 - .../fixtures/data/calendarReminderSent.php | 1 - tests/codeception/functional/_bootstrap.php | 2 +- tests/codeception/unit/_bootstrap.php | 2 +- .../unit/birthday/BirthdayQueryTest.php | 14 +- .../entry/CalendarEntryFormSequenceTest.php | 18 +- .../unit/entry/CalendarEntryFormTest.php | 75 +++++---- .../unit/entry/CalendarEntryFormatTest.php | 24 +-- .../unit/entry/CalendarEntryQueryTest.php | 157 +++++++++--------- .../unit/entry/CalendarFormTimezoneTest.php | 22 ++- .../unit/entry/CalendarServiceTest.php | 10 +- .../unit/entry/LegacyCalendarEntryTest.php | 9 +- tests/codeception/unit/entry/LocaleTest.php | 12 +- .../unit/helpers/CalendarUtilTest.php | 2 +- .../unit/interface/ItemTypeInterfaceTest.php | 38 +++-- .../unit/models/OtherTestEventType.php | 6 +- .../codeception/unit/models/TestEventType.php | 6 +- .../unit/participation/ParticipationTest.php | 6 +- .../unit/recurrence/RecurrenceEditTest.php | 26 +-- .../unit/recurrence/RecurrenceFormTest.php | 20 +-- .../unit/recurrence/RecurrenceQueryTest.php | 10 +- .../unit/recurrence/RecurrenceServiceTest.php | 9 +- .../unit/reminder/ReminderProcessTest.php | 72 ++++---- .../unit/reminder/ReminderSettingsTest.php | 114 ++++++------- .../unit/reminder/ReminderTest.php | 14 +- .../unit/reminder/ReminderUserQueryTest.php | 25 ++- tests/config/test.php | 7 +- widgets/CalendarControls.php | 3 +- widgets/CalendarFilterBar.php | 1 - widgets/CalendarTypeListView.php | 3 +- widgets/CloseLink.php | 6 +- widgets/ConfigureButton.php | 3 +- widgets/ContainerConfigMenu.php | 8 +- widgets/DeleteLink.php | 6 +- widgets/DownloadIcsLink.php | 4 +- widgets/EditLink.php | 6 +- widgets/EntryParticipants.php | 3 +- widgets/ExportParticipantsButton.php | 138 +++++++-------- widgets/FullCalendar.php | 4 +- widgets/GlobalConfigMenu.php | 14 +- widgets/ParticipantAddForm.php | 2 +- widgets/ParticipantsLink.php | 4 +- widgets/ReminderLink.php | 4 +- widgets/UpcomingEvents.php | 1 - widgets/WallEntry.php | 8 +- widgets/mails/CalendarEventMailInfo.php | 18 +- 158 files changed, 1047 insertions(+), 1118 deletions(-) diff --git a/Events.php b/Events.php index cada145d..9ebdd0bf 100644 --- a/Events.php +++ b/Events.php @@ -379,7 +379,7 @@ public static function onCronRun($event) } catch (\Throwable $e) { Yii::error($e); $controller->stdout('error.' . PHP_EOL, Console::FG_RED); - $controller->stderr("\n".$e->getTraceAsString()."\n", Console::BOLD); + $controller->stderr("\n" . $e->getTraceAsString() . "\n", Console::BOLD); } $module->settings->set('lastReminderRunTS', time()); } diff --git a/activities/ResponseAttend.php b/activities/ResponseAttend.php index 1fcbe894..f2381323 100644 --- a/activities/ResponseAttend.php +++ b/activities/ResponseAttend.php @@ -19,7 +19,6 @@ */ class ResponseAttend extends BaseActivity implements ConfigurableActivityInterface { - public $viewName = 'response_attend'; public $moduleId = 'calendar'; diff --git a/activities/ResponseDeclined.php b/activities/ResponseDeclined.php index 27f9a5ce..e343f1ea 100644 --- a/activities/ResponseDeclined.php +++ b/activities/ResponseDeclined.php @@ -19,7 +19,6 @@ */ class ResponseDeclined extends BaseActivity implements ConfigurableActivityInterface { - public $viewName = 'response_declined'; public $moduleId = 'calendar'; diff --git a/activities/ResponseInvited.php b/activities/ResponseInvited.php index 771181f1..9c8c1941 100644 --- a/activities/ResponseInvited.php +++ b/activities/ResponseInvited.php @@ -19,7 +19,6 @@ */ class ResponseInvited extends BaseActivity implements ConfigurableActivityInterface { - public $viewName = 'response_invited'; public $moduleId = 'calendar'; diff --git a/assets/CalendarAsset.php b/assets/CalendarAsset.php index e426e115..e316fbcd 100644 --- a/assets/CalendarAsset.php +++ b/assets/CalendarAsset.php @@ -17,18 +17,18 @@ class CalendarAsset extends AssetBundle public $defer = true; public $publishOptions = [ - 'forceCopy' => false + 'forceCopy' => false, ]; - + public $sourcePath = '@calendar/resources/js'; public $js = [ - 'humhub.calendar.Calendar.min.js' + 'humhub.calendar.Calendar.min.js', ]; public $depends = [ FullCalendarAssets::class, - CalendarBaseAssets::class + CalendarBaseAssets::class, ]; /** @@ -44,7 +44,7 @@ public static function register($view) 'button.week' => Yii::t('CalendarModule.calendar', 'Week'), 'button.day' => Yii::t('CalendarModule.calendar', 'Day'), 'button.list' => Yii::t('CalendarModule.calendar', 'List'), - ] + ], ]); return parent::register($view); } diff --git a/assets/CalendarBaseAssets.php b/assets/CalendarBaseAssets.php index 1d651eb4..43a7f519 100644 --- a/assets/CalendarBaseAssets.php +++ b/assets/CalendarBaseAssets.php @@ -15,9 +15,9 @@ class CalendarBaseAssets extends AssetBundle public $defer = true; public $publishOptions = [ - 'forceCopy' => false + 'forceCopy' => false, ]; - + public $sourcePath = '@calendar/resources'; public $css = [ @@ -25,6 +25,6 @@ class CalendarBaseAssets extends AssetBundle ]; public $js = [ - 'js/humhub.calendar.min.js' + 'js/humhub.calendar.min.js', ]; } diff --git a/assets/FullCalendarAssets.php b/assets/FullCalendarAssets.php index 26e99ec0..3ca464fc 100644 --- a/assets/FullCalendarAssets.php +++ b/assets/FullCalendarAssets.php @@ -15,7 +15,7 @@ class FullCalendarAssets extends AssetBundle public $defer = true; public $publishOptions = ['forceCopy' => false]; - + public $sourcePath = '@calendar/resources'; public $css = ['css/fullcalendar.bundle.min.css']; diff --git a/assets/ParticipationFormAssets.php b/assets/ParticipationFormAssets.php index 589dc875..d18b3315 100644 --- a/assets/ParticipationFormAssets.php +++ b/assets/ParticipationFormAssets.php @@ -17,7 +17,7 @@ class ParticipationFormAssets extends AssetBundle * @inheritdoc */ public $publishOptions = [ - 'forceCopy' => false + 'forceCopy' => false, ]; /** diff --git a/assets/RecurrenceFormAssets.php b/assets/RecurrenceFormAssets.php index ee475304..110b677e 100644 --- a/assets/RecurrenceFormAssets.php +++ b/assets/RecurrenceFormAssets.php @@ -15,9 +15,9 @@ class RecurrenceFormAssets extends AssetBundle public $defer = true; public $publishOptions = [ - 'forceCopy' => false + 'forceCopy' => false, ]; - + public $sourcePath = '@calendar/resources'; public $js = [ diff --git a/assets/ReminderFormAssets.php b/assets/ReminderFormAssets.php index 44a07def..f944baa1 100644 --- a/assets/ReminderFormAssets.php +++ b/assets/ReminderFormAssets.php @@ -15,9 +15,9 @@ class ReminderFormAssets extends AssetBundle public $defer = true; public $publishOptions = [ - 'forceCopy' => false + 'forceCopy' => false, ]; - + public $sourcePath = '@calendar/resources'; public $js = [ diff --git a/config.php b/config.php index 5ce1e7ac..cd67d958 100644 --- a/config.php +++ b/config.php @@ -26,7 +26,7 @@ ['class' => ProfileMenu::class, 'event' => ProfileMenu::EVENT_INIT, 'callback' => [Events::class, 'onProfileMenuInit']], ['class' => SpaceSidebar::class, 'event' => SpaceSidebar::EVENT_INIT, 'callback' => [Events::class, 'onSpaceSidebarInit']], ['class' => ProfileSidebar::class, 'event' => ProfileSidebar::EVENT_INIT, 'callback' => [Events::class, 'onProfileSidebarInit']], - ['class' => DashboardSidebar::class, 'event' =>DashboardSidebar::EVENT_INIT, 'callback' => [Events::class, 'onDashboardSidebarInit']], + ['class' => DashboardSidebar::class, 'event' => DashboardSidebar::EVENT_INIT, 'callback' => [Events::class, 'onDashboardSidebarInit']], ['class' => TopMenu::class, 'event' => TopMenu::EVENT_INIT, 'callback' => [Events::class, 'onTopMenuInit']], ['class' => 'humhub\modules\calendar\interfaces\CalendarService', 'event' => 'getItemTypes', 'callback' => [Events::class, 'onGetCalendarItemTypes']], ['class' => 'humhub\modules\calendar\interfaces\CalendarService', 'event' => 'findItems', 'callback' => [Events::class, 'onFindCalendarItems']], diff --git a/controllers/AbstractConfigController.php b/controllers/AbstractConfigController.php index 8b5f52a6..4054e69a 100644 --- a/controllers/AbstractConfigController.php +++ b/controllers/AbstractConfigController.php @@ -26,10 +26,10 @@ */ abstract class AbstractConfigController extends ContentContainerController { - const VIEW_CONFIG_DEFAULT = '@calendar/views/common/defaultConfig'; - const VIEW_CONFIG_TYPE = '@calendar/views/common/typesConfig'; - const VIEW_CONFIG_EDIT_TYPE_MODAL = '@calendar/views/common/editTypeModal'; - const VIEW_CONFIG_CALENDARS = '@calendar/views/common/calendarsConfig'; + public const VIEW_CONFIG_DEFAULT = '@calendar/views/common/defaultConfig'; + public const VIEW_CONFIG_TYPE = '@calendar/views/common/typesConfig'; + public const VIEW_CONFIG_EDIT_TYPE_MODAL = '@calendar/views/common/editTypeModal'; + public const VIEW_CONFIG_CALENDARS = '@calendar/views/common/calendarsConfig'; /** * @var CalendarService @@ -57,7 +57,7 @@ public function actionIndex() } return $this->render(static::VIEW_CONFIG_DEFAULT, [ - 'model' => $model + 'model' => $model, ]); } @@ -68,13 +68,13 @@ public function actionTypes() : CalendarEntryType::findGlobal(); $typeDataProvider = new ActiveDataProvider([ - 'query' => $query + 'query' => $query, ]); return $this->render(static::VIEW_CONFIG_TYPE, [ 'typeDataProvider' => $typeDataProvider, 'createUrl' => URL::toCreateType($this->contentContainer), - 'contentContainer' => $this->contentContainer + 'contentContainer' => $this->contentContainer, ]); } @@ -115,7 +115,7 @@ public function actionCalendars() $types = $this->calendarService->getCalendarItemTypes($this->contentContainer); return $this->render(static::VIEW_CONFIG_CALENDARS, [ 'contentContainer' => $this->contentContainer, - 'calendars' => $types + 'calendars' => $types, ]); } diff --git a/controllers/ConfigController.php b/controllers/ConfigController.php index e85c9ed0..0677f241 100644 --- a/controllers/ConfigController.php +++ b/controllers/ConfigController.php @@ -40,7 +40,7 @@ public function actionSnippet() } return $this->render('snippet', [ - 'model' => $model + 'model' => $model, ]); } @@ -53,8 +53,8 @@ public function actionMenu() } return $this->render('menu', [ - 'model' => $model + 'model' => $model, ]); } -} \ No newline at end of file +} diff --git a/controllers/FullCalendarController.php b/controllers/FullCalendarController.php index 670314cf..6c8a07d7 100644 --- a/controllers/FullCalendarController.php +++ b/controllers/FullCalendarController.php @@ -19,10 +19,10 @@ public function getAccessRules() return [ ['login'], ['json'], - ['post'] + ['post'], ]; } - + public function actionUpdate($id) { $this->forcePostRequest(); @@ -67,4 +67,4 @@ public function actionUpdate($id) return $this->asJson(['success' => false, 'error' => $result]); } -} \ No newline at end of file +} diff --git a/controllers/GlobalController.php b/controllers/GlobalController.php index 02fc1848..d9a68706 100644 --- a/controllers/GlobalController.php +++ b/controllers/GlobalController.php @@ -48,7 +48,7 @@ class GlobalController extends Controller public function getAccessRules() { return [ - ['login' => ['enable', 'select']] + ['login' => ['enable', 'select']], ]; } @@ -84,7 +84,7 @@ public function actionIndex() 'selectors' => $this->getSelectorSettings(), 'filters' => $this->getFilterSettings(), 'canConfigure' => $moduleEnabled, - 'editUrl' => Url::to(['/calendar/entry/edit']) + 'editUrl' => Url::to(['/calendar/entry/edit']), ]); } @@ -141,9 +141,10 @@ public function actionSelect($start = null, $end = null) $calendarMemberSpaceQuery = Membership::getUserSpaceQuery(Yii::$app->user->getIdentity()); if (!ContentContainerModuleManager::getDefaultState(Space::class, 'calendar')) { - $calendarMemberSpaceQuery->leftJoin('contentcontainer_module', + $calendarMemberSpaceQuery->leftJoin( + 'contentcontainer_module', 'contentcontainer_module.module_id = :calendar AND contentcontainer_module.contentcontainer_id = space.contentcontainer_id', - [':calendar' => 'calendar'] + [':calendar' => 'calendar'], )->andWhere('contentcontainer_module.module_id IS NOT NULL') ->andWhere(['contentcontainer_module.module_state' => ContentContainerModuleState::STATE_ENABLED]); } @@ -254,7 +255,7 @@ public function actionEnable($start, $end) 'header' => Yii::t('CalendarModule.base', 'Add profile calendar'), 'body' => Yii::t('CalendarModule.base', 'In order to add events to your profile, you have to enable the calendar module first.'), 'footer' => $enableButton . $nextButton . $cancelButton, - 'centerText' => true + 'centerText' => true, ]); } @@ -276,7 +277,7 @@ public function actionEnableConfig() 'header' => Yii::t('CalendarModule.base', 'Add profile calendar'), 'body' => Yii::t('CalendarModule.base', 'Do you want to install this module on your profile?'), 'footer' => $enableButton . $nextButton . $cancelButton, - 'centerText' => true + 'centerText' => true, ]); } diff --git a/controllers/IcalController.php b/controllers/IcalController.php index 2027a4a3..85fe2ef6 100644 --- a/controllers/IcalController.php +++ b/controllers/IcalController.php @@ -12,7 +12,6 @@ use yii\web\HttpException; use yii\web\NotFoundHttpException; - class IcalController extends Controller { /** @@ -20,7 +19,7 @@ class IcalController extends Controller */ public $calendarService; - const EXPORT_MIME = 'text/calendar'; + public const EXPORT_MIME = 'text/calendar'; /** * @return array @@ -28,7 +27,7 @@ class IcalController extends Controller public function getAccessRules() { return [ - [ControllerAccess::RULE_LOGGED_IN_ONLY] + [ControllerAccess::RULE_LOGGED_IN_ONLY], ]; } @@ -58,7 +57,7 @@ public function actionExport($id) $uid = $model->getUid() ?: $this->uniqueId; - return Yii::$app->response->sendContentAsFile($ics, $uid.'.ics', ['mimeType' => static::EXPORT_MIME]); + return Yii::$app->response->sendContentAsFile($ics, $uid . '.ics', ['mimeType' => static::EXPORT_MIME]); } /** diff --git a/controllers/ReminderController.php b/controllers/ReminderController.php index 06096da8..d19ec071 100644 --- a/controllers/ReminderController.php +++ b/controllers/ReminderController.php @@ -25,7 +25,7 @@ class ReminderController extends ContentContainerController public function getAccessRules() { return [ - [ControllerAccess::RULE_LOGGED_IN_ONLY] + [ControllerAccess::RULE_LOGGED_IN_ONLY], ]; } @@ -54,7 +54,7 @@ public function actionSet($id) throw new HttpException(400); } - $reminderSettings = new ReminderSettings(['entry' =>$model, 'user' => Yii::$app->user->getIdentity()]); + $reminderSettings = new ReminderSettings(['entry' => $model, 'user' => Yii::$app->user->getIdentity()]); if($reminderSettings->load(Yii::$app->request->post()) && $reminderSettings->save()) { return ModalClose::widget(['saved' => true]); @@ -62,4 +62,4 @@ public function actionSet($id) return $this->renderAjax('userLevelReminder', ['reminderSettings' => $reminderSettings]); } -} \ No newline at end of file +} diff --git a/controllers/ViewController.php b/controllers/ViewController.php index f7723481..d86d33c0 100644 --- a/controllers/ViewController.php +++ b/controllers/ViewController.php @@ -21,7 +21,6 @@ */ class ViewController extends ContentContainerController { - /** * @inheritdoc */ @@ -75,7 +74,7 @@ public function actionLoadAjax($start, $end) // Don't expand recurrence event on filter by "I'm attending" because this option is selected per each date separately $expand = !in_array(AbstractCalendarQuery::FILTER_PARTICIPATE, $filters); - foreach ($this->calendarService->getCalendarItems( new DateTime($start), new DateTime($end), $filters, $this->contentContainer, null, $expand, $types) as $entry) { + foreach ($this->calendarService->getCalendarItems(new DateTime($start), new DateTime($end), $filters, $this->contentContainer, null, $expand, $types) as $entry) { $result[] = FullCalendar::getFullCalendarArray($entry); } diff --git a/controllers/rest/CalendarController.php b/controllers/rest/CalendarController.php index f84a26e2..c8492bd3 100644 --- a/controllers/rest/CalendarController.php +++ b/controllers/rest/CalendarController.php @@ -122,11 +122,11 @@ public function actionRespond($id) } if (! in_array((int)$respondType, [ - CalendarEntryParticipant::PARTICIPATION_STATE_NONE, - CalendarEntryParticipant::PARTICIPATION_STATE_DECLINED, - CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE, - CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED, - ], true)) { + CalendarEntryParticipant::PARTICIPATION_STATE_NONE, + CalendarEntryParticipant::PARTICIPATION_STATE_DECLINED, + CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE, + CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED, + ], true)) { return $this->returnError(400, 'Invalid respond type'); } diff --git a/helpers/CalendarUtils.php b/helpers/CalendarUtils.php index 151d8f2c..9f6841ca 100644 --- a/helpers/CalendarUtils.php +++ b/helpers/CalendarUtils.php @@ -20,35 +20,34 @@ */ class CalendarUtils { - /** * Database Field - Validators */ - const REGEX_DBFORMAT_DATE = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/'; - const REGEX_DBFORMAT_DATETIME = '/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/'; + public const REGEX_DBFORMAT_DATE = '/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/'; + public const REGEX_DBFORMAT_DATETIME = '/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/'; private static $userTimezone; private static $userTimezoneString; - const DATE_FORMAT_ATOM = 'Y-m-d\TH:i:sP'; - const DB_DATE_FORMAT = 'Y-m-d H:i:s'; - const DATE_FORMAT_SHORT = 'Y-m-d'; - const DATE_FORMAT_SHORT_NO_TIME = '!Y-m-d'; + public const DATE_FORMAT_ATOM = 'Y-m-d\TH:i:sP'; + public const DB_DATE_FORMAT = 'Y-m-d H:i:s'; + public const DATE_FORMAT_SHORT = 'Y-m-d'; + public const DATE_FORMAT_SHORT_NO_TIME = '!Y-m-d'; - const TIME_FORMAT_SHORT_PHP = 'H:i'; - const TIME_FORMAT_SHORT = 'php:'.self::TIME_FORMAT_SHORT_PHP; - const TIME_FORMAT_SHORT_MERIDIEM_PHP = 'h:i A'; - const TIME_FORMAT_SHORT_MERIDIEM = 'php:'.self::TIME_FORMAT_SHORT_MERIDIEM_PHP; + public const TIME_FORMAT_SHORT_PHP = 'H:i'; + public const TIME_FORMAT_SHORT = 'php:' . self::TIME_FORMAT_SHORT_PHP; + public const TIME_FORMAT_SHORT_MERIDIEM_PHP = 'h:i A'; + public const TIME_FORMAT_SHORT_MERIDIEM = 'php:' . self::TIME_FORMAT_SHORT_MERIDIEM_PHP; - const ICAL_TIME_FORMAT = 'Ymd\THis'; + public const ICAL_TIME_FORMAT = 'Ymd\THis'; - const DOW_SUNDAY = 1; - const DOW_MONDAY = 2; - const DOW_TUESDAY = 3; - const DOW_WEDNESDAY = 4; - const DOW_THURSDAY = 5; - const DOW_FRIDAY = 6; - const DOW_SATURDAY = 7; + public const DOW_SUNDAY = 1; + public const DOW_MONDAY = 2; + public const DOW_TUESDAY = 3; + public const DOW_WEDNESDAY = 4; + public const DOW_THURSDAY = 5; + public const DOW_FRIDAY = 6; + public const DOW_SATURDAY = 7; /** * @param $value @@ -102,7 +101,7 @@ public static function getTimeFormat($php = false) * Checks whether the given value is a db date format or not. * * @param string $value the date value - * @return boolean + * @return bool */ protected static function isInDbFormat($value) { @@ -191,8 +190,8 @@ public static function ensureAllDay(DateTime $startDt, DateTime $endDt) $endDt->modify('+1 day'); } - $startDt->setTime(0,0,0); - $endDt->setTime(0,0,0); + $startDt->setTime(0, 0, 0); + $endDt->setTime(0, 0, 0); } /** @@ -221,7 +220,7 @@ public static function getDateTime($date) if($date instanceof \DateTimeImmutable) { return DateTime::createFromFormat( static::DATE_FORMAT_ATOM, - $date->format(static::DATE_FORMAT_ATOM) + $date->format(static::DATE_FORMAT_ATOM), ); } @@ -408,13 +407,15 @@ private static function parseFormat($format = null) return $format; } - public static function generateEventUid(CalendarEventIF $event, $type = 'event') { + public static function generateEventUid(CalendarEventIF $event, $type = 'event') + { return static::generateUUid($event->getEventType()->getKey()); } - public static function generateUUid($type = 'event') { + public static function generateUUid($type = 'event') + { Module::registerAutoloader(); - return 'humhub-'.$type.'-' . UUIDUtil::getUUID(); + return 'humhub-' . $type . '-' . UUIDUtil::getUUID(); } /** @@ -445,7 +446,7 @@ public static function incrementSequence(CalendarEventIF $entry) { if($entry instanceof EditableEventIF) { $sequence = $entry->getSequence(); - $entry->setSequence( ($sequence === null) ? 0 : ++$sequence); + $entry->setSequence(($sequence === null) ? 0 : ++$sequence); } } } diff --git a/helpers/RRuleHelper.php b/helpers/RRuleHelper.php index 7e080451..e27efd14 100644 --- a/helpers/RRuleHelper.php +++ b/helpers/RRuleHelper.php @@ -6,7 +6,6 @@ class RRuleHelper { - /** * @param $rrule * @param $until @@ -51,4 +50,4 @@ public static function toArray($rrule) return $parts; } -} \ No newline at end of file +} diff --git a/helpers/RecurrenceHelper.php b/helpers/RecurrenceHelper.php index 184147f8..0a7eec42 100644 --- a/helpers/RecurrenceHelper.php +++ b/helpers/RecurrenceHelper.php @@ -1,9 +1,7 @@ (int)$entry->max_participants, 'location' => $entry->location, 'content' => ContentDefinitions::getContent($entry->content), - 'participants' => static::getParticipantUsers($entry->getParticipantEntries()->with('user')->all()) + 'participants' => static::getParticipantUsers($entry->getParticipantEntries()->with('user')->all()), ]; } @@ -46,15 +47,15 @@ private static function getParticipantUsers($participants) $result = [ 'attending' => [], 'maybe' => [], - 'declined' => [] + 'declined' => [], ]; foreach ($participants as $participant) { if ($participant->participation_state === CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED) { $result['attending'][] = UserDefinitions::getUserShort($participant->user); - } elseif ($participant->participation_state === CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE){ + } elseif ($participant->participation_state === CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE) { $result['maybe'][] = UserDefinitions::getUserShort($participant->user); - } elseif ($participant->participation_state === CalendarEntryParticipant::PARTICIPATION_STATE_DECLINED){ + } elseif ($participant->participation_state === CalendarEntryParticipant::PARTICIPATION_STATE_DECLINED) { $result['declined'][] = UserDefinitions::getUserShort($participant->user); } } diff --git a/helpers/Url.php b/helpers/Url.php index 196c7166..91948469 100644 --- a/helpers/Url.php +++ b/helpers/Url.php @@ -36,7 +36,7 @@ public static function toConfigTypes(ContentContainerActiveRecord $container = n public static function toEditType(CalendarEntryType $model, ContentContainerActiveRecord $container = null) { if ($model->container instanceof ContentContainerActiveRecord) { - return $model->container->createUrl('/calendar/container-config/edit-type', ['id' => $model->id] ); + return $model->container->createUrl('/calendar/container-config/edit-type', ['id' => $model->id]); } $params = ['/calendar/config/edit-type', 'id' => $model->id]; @@ -49,7 +49,7 @@ public static function toEditType(CalendarEntryType $model, ContentContainerActi public static function toCreateType(ContentContainerActiveRecord $container = null) { if($container) { - return $container->createUrl('/calendar/container-config/edit-type' ); + return $container->createUrl('/calendar/container-config/edit-type'); } return static::to(['/calendar/config/edit-type']) ; @@ -264,7 +264,7 @@ public static function toExportParticipations(string $type, CalendarEntry $entry return $entry->content->container->createUrl('/calendar/entry/export-participants', [ 'id' => $entry->id, 'state' => $state, - 'type' => $type + 'type' => $type, ]); } diff --git a/integration/BirthdayCalendar.php b/integration/BirthdayCalendar.php index 06116a03..1c750055 100644 --- a/integration/BirthdayCalendar.php +++ b/integration/BirthdayCalendar.php @@ -14,7 +14,6 @@ use humhub\modules\calendar\interfaces\event\CalendarItemTypesEvent; use humhub\modules\user\models\User; - /** * Created by PhpStorm. * User: buddha @@ -29,9 +28,9 @@ class BirthdayCalendar extends Component /** * Default color of meeting type calendar items. */ - const DEFAULT_COLOR = '#59D6E4'; + public const DEFAULT_COLOR = '#59D6E4'; - const ITEM_TYPE_KEY = 'birthday'; + public const ITEM_TYPE_KEY = 'birthday'; /** * @param $event CalendarItemTypesEvent @@ -64,4 +63,4 @@ public static function getTitle(User $user) return Yii::t('CalendarModule.base', '{displayName} Birthday', ['displayName' => Html::encode($user->getDisplayName())]); } -} \ No newline at end of file +} diff --git a/integration/BirthdayCalendarEntry.php b/integration/BirthdayCalendarEntry.php index 1cf75fc2..e2f4070f 100644 --- a/integration/BirthdayCalendarEntry.php +++ b/integration/BirthdayCalendarEntry.php @@ -1,9 +1,7 @@ model->guid; + return 'birthday' . $this->model->guid; } /** @@ -47,7 +44,7 @@ public function getEventType() * Defines whether or not this event is an spans over an whole day. * Note all_day events should omit any timezone translations. * - * @return boolean + * @return bool */ public function isAllDay() { @@ -268,7 +265,7 @@ public function isUpdatable() * * @param DateTime $start * @param DateTime $end - * @return boolean|string + * @return bool|string */ public function updateTime(DateTime $start, DateTime $end) { @@ -321,4 +318,4 @@ public function getFullCalendarOptions() { return []; } -} \ No newline at end of file +} diff --git a/integration/BirthdayCalendarQuery.php b/integration/BirthdayCalendarQuery.php index 68b72787..b2d9f85a 100644 --- a/integration/BirthdayCalendarQuery.php +++ b/integration/BirthdayCalendarQuery.php @@ -45,8 +45,8 @@ class BirthdayCalendarQuery extends AbstractCalendarQuery protected function setupDateCriteria() { - $from = $this->_from ?: (new \DateTime())->setTime(0,0,0); - $to = $this->_to ?: (new \DateTime())->setTime(0,0,0)->modify('+2 year'); + $from = $this->_from ?: (new \DateTime())->setTime(0, 0, 0); + $to = $this->_to ?: (new \DateTime())->setTime(0, 0, 0)->modify('+2 year'); $fromYear = (int)$from->format('Y'); $toYear = (int)$to->format('Y'); @@ -65,11 +65,13 @@ protected function setupDateCriteria() $this->_query->joinWith('profile'); $this->_query->addSelect(['profile.*', 'user.*']); $this->_query->addSelect(new Expression($toOrFromBirthday . ' AS next_birthday')); - $this->_query->andWhere(new Expression($toOrFromBirthday . ' BETWEEN :fromDate AND :toDate'), + $this->_query->andWhere( + new Expression($toOrFromBirthday . ' BETWEEN :fromDate AND :toDate'), [ ':fromDate' => $from->format('Y-m-d'), - ':toDate' => $to->format('Y-m-d') - ]); + ':toDate' => $to->format('Y-m-d'), + ], + ); } @@ -80,8 +82,11 @@ protected function filterDashboard() } if (!Yii::$app->user->isGuest && Yii::$app->getModule('friendship')->settings->get('enable')) { - $this->_query->innerJoin('user_friendship', 'user.id=user_friendship.friend_user_id AND user_friendship.user_id=:userId', - [':userId' => Yii::$app->user->id]); + $this->_query->innerJoin( + 'user_friendship', + 'user.id=user_friendship.friend_user_id AND user_friendship.user_id=:userId', + [':userId' => Yii::$app->user->id], + ); } else { throw new FilterNotSupportedException('Global filter not supported for this query'); } @@ -135,7 +140,7 @@ protected function filterContentContainer() ->leftJoin('space', 'space.id=space_membership.space_id') ->where('space.id=:spaceId') ->andWhere('space_membership.user_id=user.id AND space_membership.status=' . Membership::STATUS_MEMBER)->params([ - ':spaceId' => $this->_container->id + ':spaceId' => $this->_container->id, ]); $this->_query->andWhere(['exists', $spaceMemberships]); diff --git a/integration/BirthdayCalendarType.php b/integration/BirthdayCalendarType.php index 1d1bf09f..5dba3250 100644 --- a/integration/BirthdayCalendarType.php +++ b/integration/BirthdayCalendarType.php @@ -1,17 +1,15 @@ $end ? clone $end : null, 'filters' => $filters, 'limit' => $limit, - 'expand' => $expand + 'expand' => $expand, ]); $this->trigger(static::EVENT_FIND_ITEMS, $event); @@ -202,7 +203,7 @@ public function getUpcomingEntries(ContentContainerActiveRecord $contentContaine { $start = new DateTime('now', CalendarUtils::getUserTimeZone()); $end = ($daysInFuture > 0) ? (new DateTime('now', CalendarUtils::getUserTimeZone())) - ->add(new DateInterval('P'.$daysInFuture.'D')) : null; + ->add(new DateInterval('P' . $daysInFuture . 'D')) : null; return $this->getCalendarItems($start, $end, $filters, $contentContainer, $limit, $expand); } @@ -223,4 +224,4 @@ public function getItemType($key, ContentContainerActiveRecord $contentContainer return null; } -} \ No newline at end of file +} diff --git a/interfaces/VCalendar.php b/interfaces/VCalendar.php index 56620dc6..7c8b893b 100644 --- a/interfaces/VCalendar.php +++ b/interfaces/VCalendar.php @@ -1,9 +1,7 @@ $item]); } @@ -130,7 +127,7 @@ private function addVEvent(CalendarEventIF $item, bool $isRecurrenceChild = fals if ($item->isAllDay() && $dtend->format('H:i') === '23:59') { // Translate for legacy events - $dtend->modify('+1 hour')->setTime(0,0,0); + $dtend->modify('+1 hour')->setTime(0, 0, 0); } $dtStart = clone $item->getStartDateTime(); @@ -147,7 +144,7 @@ private function addVEvent(CalendarEventIF $item, bool $isRecurrenceChild = fals 'DTEND' => $dtEnd, 'SUMMARY' => $item->getTitle(), ]; - + if (isset($item->closed) && $item->closed) { $result['STATUS'] = 'CANCELLED'; } @@ -175,7 +172,7 @@ private function addVEvent(CalendarEventIF $item, bool $isRecurrenceChild = fals if ($initRecurrenceChildren) { $recurrenceItems = $item->getRecurrenceInstances()->all(); } - } else if (RecurrenceHelper::isRecurrentInstance($item)) { + } elseif (RecurrenceHelper::isRecurrentInstance($item)) { $recurrenceId = new DateTime($item->getRecurrenceId()); $recurrenceId->setTimezone(CalendarUtils::getStartTimeZone($item)); $result['RECURRENCE-ID'] = $recurrenceId; @@ -269,7 +266,7 @@ private function getCN(User $user) $result = $user->getDisplayName(); if($user->email) { - $result .= ':MAILTO:'.$user->email; + $result .= ':MAILTO:' . $user->email; } return $result; @@ -280,17 +277,21 @@ private function getCN(User $user) * with daylight transitions covering the given date range. * * @param string Timezone ID as used in PHP's Date functions - * @param integer Unix timestamp with first date/time in this timezone - * @param integer Unix timestap with last date/time in this timezone + * @param int Unix timestamp with first date/time in this timezone + * @param int Unix timestap with last date/time in this timezone * * @return mixed A Sabre\VObject\Component object representing a VTIMEZONE definition * or false if no timezone information is available * @throws Exception */ - function generate_vtimezone($tzid, $from = 0, $to = 0) + public function generate_vtimezone($tzid, $from = 0, $to = 0) { - if (!$from) $from = time(); - if (!$to) $to = $from; + if (!$from) { + $from = time(); + } + if (!$to) { + $to = $from; + } try { $tz = new \DateTimeZone($tzid); } catch (Exception $e) { diff --git a/interfaces/event/AbstractCalendarQuery.php b/interfaces/event/AbstractCalendarQuery.php index 0778d477..287cbc92 100644 --- a/interfaces/event/AbstractCalendarQuery.php +++ b/interfaces/event/AbstractCalendarQuery.php @@ -33,30 +33,30 @@ abstract class AbstractCalendarQuery extends Component /** * Available filters */ - const FILTER_PARTICIPATE = 1; + public const FILTER_PARTICIPATE = 1; /** * @deprecated This is a legacy filter which is not active anymore */ - const FILTER_NOT_RESPONDED = 3; + public const FILTER_NOT_RESPONDED = 3; /** * @deprecated This is a legacy filter which is not active anymore */ - const FILTER_RESPONDED = 4; - const FILTER_MINE = 5; - const FILTER_DASHBOARD = 6; - const FILTER_USERRELATED = 'userRelated'; + public const FILTER_RESPONDED = 4; + public const FILTER_MINE = 5; + public const FILTER_DASHBOARD = 6; + public const FILTER_USERRELATED = 'userRelated'; /** * If this filter is set, non readable entries will be included */ - const FILTER_INCLUDE_NONREADABLE = 'includeNonReadable'; - const FILTER_INCLUDE_ARCHIVED = 'includeArchived'; + public const FILTER_INCLUDE_NONREADABLE = 'includeNonReadable'; + public const FILTER_INCLUDE_ARCHIVED = 'includeArchived'; - const DATE_QUERY_TYPE_TIME = 0; - const DATE_QUERY_TYPE_DATE = 1; - const DATE_QUERY_TYPE_MIXED = 2; + public const DATE_QUERY_TYPE_TIME = 0; + public const DATE_QUERY_TYPE_DATE = 1; + public const DATE_QUERY_TYPE_MIXED = 2; /** * @var string Defines the ActiveRecord class used for this query @@ -156,7 +156,7 @@ abstract class AbstractCalendarQuery extends Component protected $_to; /** - * @var boolean flag to enable/disable the openRange behaviour (default true) + * @var bool flag to enable/disable the openRange behaviour (default true) */ protected $_openRange = true; @@ -181,12 +181,12 @@ abstract class AbstractCalendarQuery extends Component protected $_userScopes; /** - * @var boolean if set to false (default) will ignore time information in date filter intervals + * @var bool if set to false (default) will ignore time information in date filter intervals */ protected $_withTime = true; /** - * @var boolean determines if the query was already built + * @var bool determines if the query was already built */ protected $_built = false; @@ -356,7 +356,7 @@ public function userRelated($scopes = [ActiveQueryContent::USER_RELATED_SCOPE_OW * Note: This method has to be called before the [[from()]] and [[to()]] or any other * date interval filter in order to affect the query. * - * @param boolean $withTime + * @param bool $withTime * @return $this */ public function withTime($withTime = true) @@ -457,7 +457,7 @@ public function container(ContentContainerActiveRecord $container = null) * If this behaviour is deactivated, only entries where the start and end date * is within the date filter interval will be included. * - * @param boolean $openRange false to deactivate the openRange behaviour else ture (default) + * @param bool $openRange false to deactivate the openRange behaviour else ture (default) * @return $this */ public function openRange($openRange = true) @@ -531,9 +531,9 @@ public function to($to = null, $dateUnit = 'D') if (is_int($to)) { if ($to >= 0) { - $to = (new DateTime)->add(new DateInterval('P' . $to . $dateUnit)); + $to = (new DateTime())->add(new DateInterval('P' . $to . $dateUnit)); } else { - $to = (new DateTime)->sub(new DateInterval('P' . abs($to) . $dateUnit)); + $to = (new DateTime())->sub(new DateInterval('P' . abs($to) . $dateUnit)); } } @@ -585,9 +585,9 @@ public function from($from = null, $dateUnit = 'D') if (is_int($from)) { if ($from >= 0) { - $from = (new DateTime)->add(new DateInterval('P' . $from . $dateUnit)); + $from = (new DateTime())->add(new DateInterval('P' . $from . $dateUnit)); } else { - $from = (new DateTime)->sub(new DateInterval('P' . abs($from) . $dateUnit)); + $from = (new DateTime())->sub(new DateInterval('P' . abs($from) . $dateUnit)); } } @@ -683,7 +683,7 @@ public function years($years) * Used to either add the given $interval to the start date (end date = start date + interval) * or substract the given $interval from the end date (start date = end date - interval). * - * @param integer $dayRange + * @param int $dayRange * @param string $dateUnit * @return $this * @throws Exception @@ -808,53 +808,53 @@ protected function setupDateCriteria() ['and', $this->getStartCriteria($this->_from, '<'), $this->getEndCriteria($this->_to, '>')], ['and', $this->getStartCriteria($this->_from, '>='), $this->getStartCriteria($this->_to, '<')], ['and', $this->getEndCriteria($this->_from, '>'), $this->getEndCriteria($this->_to, '<=')], - $this->isRecurrenceRootCondition() + $this->isRecurrenceRootCondition(), ]); - } else if($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { + } elseif($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { $this->_query->andFilterWhere(['or', ['and', $this->getStartCriteria($fromTime, '<'), $this->getEndCriteria($toTime, '>')], ['and', $this->getStartCriteria($fromTime, '>='), $this->getStartCriteria($toTime, '<')], ['and', $this->getEndCriteria($fromTime, '>'), $this->getEndCriteria($toTime, '<=')], - $this->isRecurrenceRootCondition() + $this->isRecurrenceRootCondition(), ]); - } else if($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { + } elseif($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { $this->_query->andFilterWhere( - ['or', + ['or', ['or', ['and', [$this->allDayField => 0], ['or', ['and', $this->getStartCriteria($fromTime, '<'), $this->getEndCriteria($toTime, '>')], ['and', $this->getStartCriteria($fromTime, '>='), $this->getStartCriteria($toTime, '<')], - ['and', $this->getEndCriteria($fromTime, '>'), $this->getEndCriteria($toTime, '<=')] - ] + ['and', $this->getEndCriteria($fromTime, '>'), $this->getEndCriteria($toTime, '<=')], + ], ], ['and', [$this->allDayField => 1], ['or', ['and', $this->getStartCriteria($this->_from, '<'), $this->getEndCriteria($this->_to, '>')], ['and', $this->getStartCriteria($this->_from, '>='), $this->getStartCriteria($this->_to, '<')], - ['and', $this->getEndCriteria($this->_from, '>'), $this->getEndCriteria($this->_to, '<=')] - ] + ['and', $this->getEndCriteria($this->_from, '>'), $this->getEndCriteria($this->_to, '<=')], + ], ], ], - $this->isRecurrenceRootCondition() - ] + $this->isRecurrenceRootCondition(), + ], ); } } else { if ($this->_from) { if($this->dateQueryType === static::DATE_QUERY_TYPE_DATE) { $this->_query->andWhere(['or', $this->getStartCriteria($this->_from, '>='), $this->isRecurrenceRootCondition()]); - } else if($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { + } elseif($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { $this->_query->andWhere(['or', $this->getStartCriteria($fromTime, '>='), $this->isRecurrenceRootCondition()]); - } else if($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { + } elseif($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { $this->_query->andWhere( ['or', ['and', [$this->allDayField => 0], $this->getStartCriteria($fromTime, '>=')], ['and', [$this->allDayField => 1], $this->getStartCriteria($this->_from, '>=')], - $this->isRecurrenceRootCondition() - ] + $this->isRecurrenceRootCondition(), + ], ); } } @@ -862,15 +862,15 @@ protected function setupDateCriteria() if ($this->_to) { if($this->dateQueryType === static::DATE_QUERY_TYPE_DATE) { $this->_query->andWhere(['or', $this->getEndCriteria($this->_to, '<='), $this->isRecurrenceRootCondition()]); - } else if($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { + } elseif($this->dateQueryType === static::DATE_QUERY_TYPE_TIME) { $this->_query->andWhere(['or', $this->getEndCriteria($toTime, '<='), $this->isRecurrenceRootCondition()]); - } else if($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { + } elseif($this->dateQueryType === static::DATE_QUERY_TYPE_MIXED) { $this->_query->andWhere( ['or', ['and', [$this->allDayField => 0], $this->getEndCriteria($toTime, '<=')], ['and', [$this->allDayField => 1], $this->getEndCriteria($this->_to, '<=')], - $this->isRecurrenceRootCondition() - ] + $this->isRecurrenceRootCondition(), + ], ); } @@ -1128,4 +1128,4 @@ protected function preFilter($result = []) { return $result; } -} \ No newline at end of file +} diff --git a/interfaces/event/CalendarEntryTypeSetting.php b/interfaces/event/CalendarEntryTypeSetting.php index 70605c1c..f1abc002 100644 --- a/interfaces/event/CalendarEntryTypeSetting.php +++ b/interfaces/event/CalendarEntryTypeSetting.php @@ -15,7 +15,6 @@ namespace humhub\modules\calendar\interfaces\event; - use humhub\modules\calendar\models\CalendarEntryType; use humhub\modules\space\models\Space; use Yii; @@ -75,4 +74,4 @@ public function getDefaultColor() return parent::getDefaultColor(); } -} \ No newline at end of file +} diff --git a/interfaces/event/CalendarEventIF.php b/interfaces/event/CalendarEventIF.php index cf6118a6..cbc97305 100644 --- a/interfaces/event/CalendarEventIF.php +++ b/interfaces/event/CalendarEventIF.php @@ -15,7 +15,6 @@ namespace humhub\modules\calendar\interfaces\event; - use DateTime; use humhub\modules\calendar\helpers\CalendarUtils; use humhub\widgets\Label; @@ -91,7 +90,7 @@ public function getEventType(); * Defines whether or not this event is an spans over an whole day. * Note all_day events should omit any timezone translations. * - * @return boolean + * @return bool */ public function isAllDay(); @@ -221,4 +220,4 @@ public function getLastModified(); * @return int */ public function getSequence(); -} \ No newline at end of file +} diff --git a/interfaces/event/CalendarEventStatusIF.php b/interfaces/event/CalendarEventStatusIF.php index 4dfa0e89..86292f36 100644 --- a/interfaces/event/CalendarEventStatusIF.php +++ b/interfaces/event/CalendarEventStatusIF.php @@ -7,16 +7,15 @@ namespace humhub\modules\calendar\interfaces\event; - interface CalendarEventStatusIF { - const STATUS_TENTATIVE = 'TENTATIVE'; - const STATUS_CONFIRMED = 'CONFIRMED'; - const STATUS_CANCELLED = 'CANCELLED'; + public const STATUS_TENTATIVE = 'TENTATIVE'; + public const STATUS_CONFIRMED = 'CONFIRMED'; + public const STATUS_CANCELLED = 'CANCELLED'; /** * @return mixed */ public function getEventStatus(); -} \ No newline at end of file +} diff --git a/interfaces/event/CalendarItemTypesEvent.php b/interfaces/event/CalendarItemTypesEvent.php index 8af68fdd..630b540b 100644 --- a/interfaces/event/CalendarItemTypesEvent.php +++ b/interfaces/event/CalendarItemTypesEvent.php @@ -15,7 +15,6 @@ namespace humhub\modules\calendar\interfaces\event; - use humhub\modules\content\components\ContentContainerActiveRecord; use yii\base\Event; @@ -32,7 +31,8 @@ class CalendarItemTypesEvent extends Event * @param $key string|CalendarTypeIF * @param $options CalendarTypeIF */ - public function addType($key, $options) { + public function addType($key, $options) + { if($key instanceof CalendarTypeIF) { $this->result[$key->getKey()] = $key; } else { @@ -40,11 +40,13 @@ public function addType($key, $options) { } } - public function hasType($key) { + public function hasType($key) + { return array_key_exists($key, $this->result); } - public function getTypes() { + public function getTypes() + { return $this->result; } -} \ No newline at end of file +} diff --git a/interfaces/event/CalendarItemsEvent.php b/interfaces/event/CalendarItemsEvent.php index 3086b711..b03cd06f 100644 --- a/interfaces/event/CalendarItemsEvent.php +++ b/interfaces/event/CalendarItemsEvent.php @@ -15,7 +15,6 @@ namespace humhub\modules\calendar\interfaces\event; - use DateTime; use humhub\modules\content\components\ContentContainerActiveRecord; use yii\base\Event; @@ -43,12 +42,12 @@ class CalendarItemsEvent extends Event public $end; /** - * @var integer result limit + * @var int result limit */ public $limit; /** - * @var boolean whether or not to expand recurring events + * @var bool whether or not to expand recurring events */ public $expand; @@ -78,4 +77,4 @@ public function getItems() return $this->items; } -} \ No newline at end of file +} diff --git a/interfaces/event/CalendarTypeArrayWrapper.php b/interfaces/event/CalendarTypeArrayWrapper.php index 2d931107..e18319c2 100644 --- a/interfaces/event/CalendarTypeArrayWrapper.php +++ b/interfaces/event/CalendarTypeArrayWrapper.php @@ -1,9 +1,7 @@ getKey().'_item_enabled'; + $settingKey = $this->getKey() . '_item_enabled'; if($this->contentContainer) { - return (boolean) $this->getSettings()->contentContainer($this->contentContainer)->getInherit($settingKey, true); + return (bool) $this->getSettings()->contentContainer($this->contentContainer)->getInherit($settingKey, true); } - return (boolean) $this->getSettings()->get($settingKey, true); + return (bool) $this->getSettings()->get($settingKey, true); } @@ -103,7 +102,7 @@ protected function getSettings() public function updateEnabled($isEnabled) { - $settingKey = $this->getKey().'_item_enabled'; + $settingKey = $this->getKey() . '_item_enabled'; if($this->contentContainer) { return $this->getSettings()->contentContainer($this->contentContainer)->set($settingKey, $isEnabled); } @@ -141,7 +140,7 @@ public function getIcon() */ public function getColor() { - $settingKey = $this->getKey().'_item_color'; + $settingKey = $this->getKey() . '_item_color'; if($this->contentContainer) { return $this->getSettings()->contentContainer($this->contentContainer)->getInherit($settingKey, $this->getDefaultColor()); } @@ -154,7 +153,7 @@ public function getColor() */ public function updateColor($color) { - $settingKey = $this->getKey().'_item_color'; + $settingKey = $this->getKey() . '_item_color'; if($this->contentContainer) { return $this->getSettings()->contentContainer($this->contentContainer)->set($settingKey, $color); } else { @@ -195,4 +194,4 @@ public function getDescription() { return $this->type->getDescription(); } -} \ No newline at end of file +} diff --git a/interfaces/event/EditableEventIF.php b/interfaces/event/EditableEventIF.php index 79e2b70b..3f19df97 100644 --- a/interfaces/event/EditableEventIF.php +++ b/interfaces/event/EditableEventIF.php @@ -1,9 +1,7 @@ getOption(static::OPTION_ALL_DAY, false); + return $this->getOption(static::OPTION_ALL_DAY, false); } public function getUpdateUrl() @@ -283,7 +282,7 @@ public function getEndTimezone() * * @param DateTime $start * @param DateTime $end - * @return boolean|string + * @return bool|string */ public function updateTime(DateTime $start, DateTime $end) { @@ -294,4 +293,4 @@ public function isUpdatable() { return $this->getOption(static::OPTION_EDITABLE, false); } -} \ No newline at end of file +} diff --git a/interfaces/fullcalendar/FullCalendarEventIF.php b/interfaces/fullcalendar/FullCalendarEventIF.php index b1fcfc5e..ecd653bf 100644 --- a/interfaces/fullcalendar/FullCalendarEventIF.php +++ b/interfaces/fullcalendar/FullCalendarEventIF.php @@ -10,12 +10,12 @@ interface FullCalendarEventIF extends CalendarEventIF /** * Used when the detail view should be opened within a modal */ - const VIEW_MODE_MODAL = 'modal'; + public const VIEW_MODE_MODAL = 'modal'; /** * Used when the detail view should be opened by redirect link */ - const VIEW_MODE_REDIRECT = 'redirect'; + public const VIEW_MODE_REDIRECT = 'redirect'; /** * Whether or not this calendar event supports drag/drop and resizing in the calendar view and the current @@ -53,7 +53,7 @@ public function isUpdatable(); * * @param DateTime $start * @param DateTime $end - * @return boolean|string + * @return bool|string */ public function updateTime(DateTime $start, DateTime $end); @@ -94,4 +94,4 @@ public function getCalendarViewMode(); * @return array */ public function getFullCalendarOptions(); -} \ No newline at end of file +} diff --git a/interfaces/participation/CalendarEventParticipationIF.php b/interfaces/participation/CalendarEventParticipationIF.php index f01a0216..84c14c2f 100644 --- a/interfaces/participation/CalendarEventParticipationIF.php +++ b/interfaces/participation/CalendarEventParticipationIF.php @@ -7,17 +7,16 @@ namespace humhub\modules\calendar\interfaces\participation; - use humhub\modules\user\components\ActiveQueryUser; use humhub\modules\user\models\User; interface CalendarEventParticipationIF { - const PARTICIPATION_STATUS_NONE = 0; - const PARTICIPATION_STATUS_DECLINED = 1; - const PARTICIPATION_STATUS_MAYBE = 2; - const PARTICIPATION_STATUS_ACCEPTED = 3; - const PARTICIPATION_STATUS_INVITED = 4; + public const PARTICIPATION_STATUS_NONE = 0; + public const PARTICIPATION_STATUS_DECLINED = 1; + public const PARTICIPATION_STATUS_MAYBE = 2; + public const PARTICIPATION_STATUS_ACCEPTED = 3; + public const PARTICIPATION_STATUS_INVITED = 4; /** * Returns the participation state for a given user or guests if $user is null. diff --git a/interfaces/recurrence/AbstractRecurrenceQuery.php b/interfaces/recurrence/AbstractRecurrenceQuery.php index 510d88bf..14d84f29 100644 --- a/interfaces/recurrence/AbstractRecurrenceQuery.php +++ b/interfaces/recurrence/AbstractRecurrenceQuery.php @@ -1,6 +1,5 @@ startField, $start->format('Y-m-d H:i:s')], - ['>', $this->endField, $end->format('Y-m-d H:i:s')] + ['>', $this->endField, $end->format('Y-m-d H:i:s')], ], ['and', ['>=', $this->startField, $start->format('Y-m-d H:i:s')], - ['<', $this->endField, $end->format('Y-m-d H:i:s')] + ['<', $this->endField, $end->format('Y-m-d H:i:s')], ], ['and', ['>', $this->endField, $start->format('Y-m-d H:i:s')], - ['<=', $this->endField, $end->format('Y-m-d H:i:s')] - ] - ]); + ['<=', $this->endField, $end->format('Y-m-d H:i:s')], + ], + ], + ); } return $query; } @@ -97,7 +97,7 @@ protected function isRecurrenceRootCondition() if($this->isRecurrenceSupported()) { return ['and', $this->rruleField . ' IS NOT NULL', - $this->parentEventIdField . ' IS NULL' + $this->parentEventIdField . ' IS NULL', ]; } @@ -110,14 +110,14 @@ protected function isRecurrenceRootCondition() * @param DateTime|null $end * @return array|CalendarReminder[]|CalendarReminderSent[]|ActiveRecord[] */ - public function getRecurrenceExceptions(DateTime $start = null, DateTime $end = null) - { - if($this->event instanceof EditableEventIF) { - return $this->findRecurrenceInstances($start, $end)->andWhere(['>', $this->sequenceField, 0])->all(); - } + public function getRecurrenceExceptions(DateTime $start = null, DateTime $end = null) + { + if($this->event instanceof EditableEventIF) { + return $this->findRecurrenceInstances($start, $end)->andWhere(['>', $this->sequenceField, 0])->all(); + } - return []; - } + return []; + } /** * This function can be used for subclasses to expand e.g. recurrent events by adding all expanded events to the diff --git a/interfaces/recurrence/RecurrenceFormModel.php b/interfaces/recurrence/RecurrenceFormModel.php index b7edf8bf..5a9f3e9c 100644 --- a/interfaces/recurrence/RecurrenceFormModel.php +++ b/interfaces/recurrence/RecurrenceFormModel.php @@ -1,6 +1,5 @@ rrule->getUntil(); $endDate->setTimeZone(CalendarUtils::getStartTimeZone($this->entry)); $this->setEndDate($endDate); - } else if ($this->rrule->getCount()) { + } elseif ($this->rrule->getCount()) { $this->end = static::ENDS_AFTER_OCCURRENCES; $this->endOccurrences = $this->rrule->getCount(); } @@ -163,7 +162,7 @@ public function setEndDate($endDate) { if (is_string($endDate)) { $this->endDate = $endDate; - } else if ($endDate instanceof \DateTimeInterface) { + } elseif ($endDate instanceof \DateTimeInterface) { $this->endDate = $endDate->format(CalendarUtils::DB_DATE_FORMAT); } } @@ -241,7 +240,7 @@ public function validateFrequency($attribute, $params) } catch (\Exception $e) { if ($this->interval == Frequency::MONTHLY) { $this->addError('monthDaySelection', Yii::t('CalendarModule.recurrence', 'Invalid day of month given')); - } else if ($this->interval == Frequency::WEEKLY) { + } elseif ($this->interval == Frequency::WEEKLY) { $this->addError('weekDays', Yii::t('CalendarModule.recurrence', 'Invalid week day selection')); } } @@ -274,7 +273,7 @@ public function save(RecurrentEventIF $original = null) return $this->entry->saveEvent(); case static::EDIT_MODE_FOLLOWING: $this->entry->setRrule($this->buildRRuleString()); - return $original ? $this->entry->getRecurrenceQuery()->saveThisAndFollowing($original): false; + return $original ? $this->entry->getRecurrenceQuery()->saveThisAndFollowing($original) : false; case static::EDIT_MODE_ALL: $this->entry->setRrule($this->buildRRuleString()); return $original ? $this->entry->getRecurrenceQuery()->saveAll($original) : false; @@ -318,7 +317,7 @@ private function setRuleEnd() $entryDateTime = $this->entry->getStartDateTime(); $until->setTime($entryDateTime->format('H'), $entryDateTime->format('i')); $this->rrule->setUntil($until); - } else if ($this->end == static::ENDS_AFTER_OCCURRENCES) { + } elseif ($this->end == static::ENDS_AFTER_OCCURRENCES) { $this->rrule->setCount($this->endOccurrences); } @@ -364,14 +363,14 @@ private function setRuleDay() { if ($this->frequency == Frequency::WEEKLY) { $this->rrule->setByDay($this->getByDays()); - } else if ($this->frequency == Frequency::MONTHLY) { + } elseif ($this->frequency == Frequency::MONTHLY) { if ($this->monthDaySelection == static::MONTHLY_BY_OCCURRENCE) { $pos = $this->getMonthlyPositionOfStart(); $this->rrule->setByDay([$this->translateDayOfWeekToRrule($this->getStartDayOfWeek())]); $this->rrule->setBySetPosition([$pos]); - } else if ($this->monthDaySelection == static::MONTHLY_LAST_DAY_OF_MONTH) { - $this->rrule->setByDay(['-1'.$this->translateDayOfWeekToRrule($this->getStartDayOfWeek())]); - } else if ($this->monthDaySelection == static::MONTHLY_BY_DAY_OF_MONTH) { + } elseif ($this->monthDaySelection == static::MONTHLY_LAST_DAY_OF_MONTH) { + $this->rrule->setByDay(['-1' . $this->translateDayOfWeekToRrule($this->getStartDayOfWeek())]); + } elseif ($this->monthDaySelection == static::MONTHLY_BY_DAY_OF_MONTH) { $this->rrule->setByMonthDay([$this->getStartDayOfMonth()]); } } @@ -406,15 +405,15 @@ public function getMonthDaySelection() { $result = [ self::MONTHLY_BY_DAY_OF_MONTH => Yii::t('CalendarModule.recurrence', 'Monthly on day {dayOfMonth}', [ - 'dayOfMonth' => $this->getStartDayOfMonth() - ]) + 'dayOfMonth' => $this->getStartDayOfMonth(), + ]), ]; - // If the date is not in the fifth week of the month + // If the date is not in the fifth week of the month if(!$this->isFifthWeekOfMonth($this->getMonthlyPositionOfStart())) { $result[self::MONTHLY_BY_OCCURRENCE] = Yii::t('CalendarModule.recurrence', 'Monthly on the {position} {dayOfWeek}', [ 'position' => $this->getMonthlyPositionOfStartFormatted(), - 'dayOfWeek' => $this->getStartDayOfWeekFormatted() + 'dayOfWeek' => $this->getStartDayOfWeekFormatted(), ]); } @@ -422,7 +421,7 @@ public function getMonthDaySelection() if($this->isLastWeekDayOfMonth()) { $result[self::MONTHLY_LAST_DAY_OF_MONTH] = Yii::t('CalendarModule.recurrence', 'Monthly on the {position} {dayOfWeek}', [ 'position' => Yii::t('CalendarModule.recurrence', 'last'), - 'dayOfWeek' => $this->getStartDayOfWeekFormatted() + 'dayOfWeek' => $this->getStartDayOfWeekFormatted(), ]); } @@ -452,19 +451,19 @@ public function getIntervalTypesSelectionData() return [ Frequency::DAILY => [ 'data-singular' => Yii::t('CalendarModule.recurrence', 'Day'), - 'data-plural' => Yii::t('CalendarModule.recurrence', 'Days') + 'data-plural' => Yii::t('CalendarModule.recurrence', 'Days'), ], Frequency::WEEKLY => [ 'data-singular' => Yii::t('CalendarModule.recurrence', 'Week'), - 'data-plural' => Yii::t('CalendarModule.recurrence', 'Weeks') + 'data-plural' => Yii::t('CalendarModule.recurrence', 'Weeks'), ], Frequency::MONTHLY => [ 'data-singular' => Yii::t('CalendarModule.recurrence', 'Month'), - 'data-plural' => Yii::t('CalendarModule.recurrence', 'Months') + 'data-plural' => Yii::t('CalendarModule.recurrence', 'Months'), ], Frequency::YEARLY => [ 'data-singular' => Yii::t('CalendarModule.recurrence', 'Year'), - 'data-plural' => Yii::t('CalendarModule.recurrence', 'Years') + 'data-plural' => Yii::t('CalendarModule.recurrence', 'Years'), ], ]; } diff --git a/interfaces/recurrence/RecurrenceQueryIF.php b/interfaces/recurrence/RecurrenceQueryIF.php index ce25a616..cd7fe8b7 100644 --- a/interfaces/recurrence/RecurrenceQueryIF.php +++ b/interfaces/recurrence/RecurrenceQueryIF.php @@ -1,9 +1,7 @@ render('@calendar/views/common/recurrenceForm', [ 'model' => $model, 'form' => $this->form, - 'options' => $this->getOptions() + 'options' => $this->getOptions(), ]); } @@ -59,11 +57,11 @@ public function getData() if ($this->picker) { return [ 'picker-selector' => $this->picker, - 'update-monthly-recurrence-test' => Url::toUpdateMonthlyRecurrenceSelection() + 'update-monthly-recurrence-test' => Url::toUpdateMonthlyRecurrenceSelection(), ]; } return []; } -} \ No newline at end of file +} diff --git a/interfaces/reminder/CalendarEventReminderIF.php b/interfaces/reminder/CalendarEventReminderIF.php index 0ac31f13..a82ef501 100644 --- a/interfaces/reminder/CalendarEventReminderIF.php +++ b/interfaces/reminder/CalendarEventReminderIF.php @@ -7,7 +7,6 @@ namespace humhub\modules\calendar\interfaces\reminder; - use humhub\modules\calendar\interfaces\event\CalendarEventIF; use humhub\modules\content\models\Content; use humhub\modules\user\components\ActiveQueryUser; @@ -25,4 +24,4 @@ public function getContentRecord(); * @return ActiveQueryUser */ public function getReminderUserQuery(); -} \ No newline at end of file +} diff --git a/jobs/ForceParticipation.php b/jobs/ForceParticipation.php index 636a066c..c00bfcba 100644 --- a/jobs/ForceParticipation.php +++ b/jobs/ForceParticipation.php @@ -39,7 +39,7 @@ public function run() if(!$entry || !$originator || !($entry->content->container instanceof Space) || !CalendarEntryParticipation::isAllowedStatus($status)) { - throw new InvalidConfigException('Could not force calendar event participation due to invalid config ('.$this->entry_id.', '.$this->originator_id.', '.$status.')'); + throw new InvalidConfigException('Could not force calendar event participation due to invalid config (' . $this->entry_id . ', ' . $this->originator_id . ', ' . $status . ')'); } $subQuery = CalendarEntryParticipant::find() diff --git a/migrations/m140729_223509_initial.php b/migrations/m140729_223509_initial.php index a177198b..35350b9c 100644 --- a/migrations/m140729_223509_initial.php +++ b/migrations/m140729_223509_initial.php @@ -4,7 +4,6 @@ class m140729_223509_initial extends Migration { - public function up() { $this->createTable('calendar_entry', [ diff --git a/migrations/m150706_193118_renamefield.php b/migrations/m150706_193118_renamefield.php index 75dd974b..2455e01b 100644 --- a/migrations/m150706_193118_renamefield.php +++ b/migrations/m150706_193118_renamefield.php @@ -17,13 +17,13 @@ public function down() return false; } - + /* // Use safeUp/safeDown to run migration code within a transaction public function safeUp() { } - + public function safeDown() { } diff --git a/migrations/m150707_134615_update.php b/migrations/m150707_134615_update.php index 55c401be..5c84967d 100644 --- a/migrations/m150707_134615_update.php +++ b/migrations/m150707_134615_update.php @@ -7,7 +7,6 @@ class m150707_134615_update extends Migration { - public function up() { // Namespace Classes diff --git a/migrations/m170721_203204_close_event.php b/migrations/m170721_203204_close_event.php index b0874a60..e7f87b20 100644 --- a/migrations/m170721_203204_close_event.php +++ b/migrations/m170721_203204_close_event.php @@ -13,7 +13,7 @@ class m170721_203204_close_event extends Migration { public function safeUp() { - $this->addColumn('calendar_entry', 'closed', Schema::TYPE_BOOLEAN. ' DEFAULT 0'); + $this->addColumn('calendar_entry', 'closed', Schema::TYPE_BOOLEAN . ' DEFAULT 0'); } public function safeDown() diff --git a/migrations/m171027_185419_uid.php b/migrations/m171027_185419_uid.php index cd5ae6cb..7c946d58 100644 --- a/migrations/m171027_185419_uid.php +++ b/migrations/m171027_185419_uid.php @@ -12,7 +12,7 @@ class m171027_185419_uid extends Migration { public function safeUp() { - $this->addColumn('calendar_entry', 'uid', $this->string(100)); + $this->addColumn('calendar_entry', 'uid', $this->string(100)); } public function safeDown() diff --git a/migrations/m171027_185420_reminder.php b/migrations/m171027_185420_reminder.php index 0ecbe0c1..72bcf223 100644 --- a/migrations/m171027_185420_reminder.php +++ b/migrations/m171027_185420_reminder.php @@ -19,7 +19,7 @@ public function safeUp() 'content_id' => $this->integer()->null(), 'active' => $this->tinyInteger(4)->defaultValue(1), 'disabled' => $this->tinyInteger(4)->defaultValue(0), - 'contentcontainer_id' => $this->integer()->null() + 'contentcontainer_id' => $this->integer()->null(), ]); $this->createTable('calendar_reminder_sent', [ diff --git a/migrations/m220217_141238_move_files.php b/migrations/m220217_141238_move_files.php index 9ca3c2b3..be25ccca 100644 --- a/migrations/m220217_141238_move_files.php +++ b/migrations/m220217_141238_move_files.php @@ -47,11 +47,13 @@ public function safeUp() } // Update all attached files to content mode - $this->execute('UPDATE file + $this->execute( + 'UPDATE file SET show_in_stream = 0 WHERE object_model = :CalendarEntryClass AND show_in_stream = 1', - ['CalendarEntryClass' => CalendarEntry::class]); + ['CalendarEntryClass' => CalendarEntry::class], + ); } /** @@ -62,4 +64,4 @@ public function safeDown() echo "m220217_141238_move_files cannot be reverted.\n"; return false; } -} \ No newline at end of file +} diff --git a/migrations/m240319_152508_fix_notification.php b/migrations/m240319_152508_fix_notification.php index 07456a56..f662760c 100644 --- a/migrations/m240319_152508_fix_notification.php +++ b/migrations/m240319_152508_fix_notification.php @@ -17,8 +17,8 @@ public function safeUp() ['class' => 'humhub\\modules\\calendar\\notifications\\ParticipantAdded'], ['IN', 'class', [ 'humhub\\modules\\calendar\\notifications\\Invited', - 'humhub\\modules\\calendar\\notifications\\ForceAdd' - ]] + 'humhub\\modules\\calendar\\notifications\\ForceAdd', + ]], ); } diff --git a/migrations/uninstall.php b/migrations/uninstall.php index 690344d1..d608bc7e 100644 --- a/migrations/uninstall.php +++ b/migrations/uninstall.php @@ -5,7 +5,6 @@ class uninstall extends Migration { - public function up() { $this->dropTable('calendar_entry'); diff --git a/models/CalendarDateFormatter.php b/models/CalendarDateFormatter.php index 4237e6b2..25e3c9a9 100644 --- a/models/CalendarDateFormatter.php +++ b/models/CalendarDateFormatter.php @@ -26,7 +26,6 @@ class CalendarDateFormatter extends Component { - /** * @var CalendarEventIF */ @@ -107,14 +106,14 @@ public function getFormattedEndTime($format = 'short', $timeZone = null) return $result; } - protected function getFormattedNonAllDay($format = 'long') + protected function getFormattedNonAllDay($format = 'long') { $result = $this->getFormattedStartDate($format); if(!$this->isSameDay()) { - $result .= ', '.$this->getFormattedStartTime(). ' - '; - $result .= $this->getFormattedEndDate($format).', '.$this->getFormattedEndTime(); + $result .= ', ' . $this->getFormattedStartTime() . ' - '; + $result .= $this->getFormattedEndDate($format) . ', ' . $this->getFormattedEndTime(); } else { - $result .= ' ('.$this->getFormattedStartTime().' - '.$this->getFormattedEndTime().')'; + $result .= ' (' . $this->getFormattedStartTime() . ' - ' . $this->getFormattedEndTime() . ')'; } return $result; @@ -129,12 +128,12 @@ protected function isSameDay() $start->setTimezone(CalendarUtils::getUserTimeZone()); $end->setTimezone(CalendarUtils::getUserTimeZone()); } - + return $start->format('Y-m-d') === $end->format('Y-m-d'); } - protected function getFormattedAllDay($format = 'long') + protected function getFormattedAllDay($format = 'long') { $result = $this->getFormattedStartDate($format); @@ -168,7 +167,7 @@ public function isRunning() public function getOffsetDays() { $s = new DateTime($this->calendarItem->getStartDateTime()); - return $s->diff(new DateTime)->days; + return $s->diff(new DateTime())->days; } public static function getTimezoneLabel($timeZone) @@ -188,4 +187,4 @@ public static function getTimeZoneItems() return $timeZoneItems; } -} \ No newline at end of file +} diff --git a/models/CalendarEntry.php b/models/CalendarEntry.php index 4c5521e0..ade480ed 100644 --- a/models/CalendarEntry.php +++ b/models/CalendarEntry.php @@ -41,20 +41,20 @@ * This is the model class for table "calendar_entry". * * The followings are the available columns in table 'calendar_entry': - * @property integer $id + * @property int $id * @property string $title * @property string $description * @property string $start_datetime * @property string $end_datetime - * @property integer $all_day - * @property integer $participation_mode + * @property int $all_day + * @property int $participation_mode * @property string $color * @property string $uid - * @property integer $allow_decline - * @property integer $allow_maybe + * @property int $allow_decline + * @property int $allow_maybe * @property string $participant_info - * @property integer $closed - * @property integer $max_participants + * @property int $closed + * @property int $max_participants * @property string $rrule * @property string $recurrence_id * @property int $parent_event_id @@ -67,8 +67,13 @@ * @property-read bool $reminder * @property-read CalendarEntry|null $recurrenceRoot */ -class CalendarEntry extends ContentActiveRecord implements Searchable, RecurrentEventIF, FullCalendarEventIF, - CalendarEventStatusIF, CalendarEventReminderIF, CalendarEventParticipationIF +class CalendarEntry extends ContentActiveRecord implements + Searchable, + RecurrentEventIF, + FullCalendarEventIF, + CalendarEventStatusIF, + CalendarEventReminderIF, + CalendarEventParticipationIF { /** * @inheritdoc @@ -118,10 +123,10 @@ class CalendarEntry extends ContentActiveRecord implements Searchable, Recurrent /** * Filters */ - const FILTER_PARTICIPATE = 1; - const FILTER_NOT_RESPONDED = 3; - const FILTER_RESPONDED = 4; - const FILTER_MINE = 5; + public const FILTER_PARTICIPATE = 1; + public const FILTER_NOT_RESPONDED = 3; + public const FILTER_RESPONDED = 4; + public const FILTER_MINE = 5; /** * @var CalendarEntryParticipation @@ -277,16 +282,16 @@ public function afterFind() $endDT->modify('+1 day')->setTime(0, 0, 0); $this->updateAttributes([ 'start_datetime' => CalendarUtils::toDBDateFormat($startDT), - 'end_datetime' => CalendarUtils::toDBDateFormat($endDT) + 'end_datetime' => CalendarUtils::toDBDateFormat($endDT), ]); - } else if (!CalendarUtils::isAllDay($this->start_datetime, $this->end_datetime, true)) { + } elseif (!CalendarUtils::isAllDay($this->start_datetime, $this->end_datetime, true)) { // Translate from 23:59 end dates to 00:00 end dates $start = $this->getStartDateTime(); $end = $this->getEndDateTime()->modify('+1 hour'); CalendarUtils::ensureAllDay($start, $end); $this->updateAttributes([ 'start_datetime' => CalendarUtils::toDBDateFormat($start), - 'end_datetime' => CalendarUtils::toDBDateFormat($end) + 'end_datetime' => CalendarUtils::toDBDateFormat($end), ]); } @@ -572,7 +577,7 @@ public function getFormattedTime($format = 'long') } /** - * @return boolean weather or not this item spans exactly over a whole day + * @return bool weather or not this item spans exactly over a whole day */ public function isAllDay() { @@ -580,7 +585,7 @@ public function isAllDay() $this->all_day = 1; } - return (boolean)$this->all_day; + return (bool)$this->all_day; } /** diff --git a/models/CalendarEntryDummy.php b/models/CalendarEntryDummy.php index 391e258d..65a7ca28 100644 --- a/models/CalendarEntryDummy.php +++ b/models/CalendarEntryDummy.php @@ -17,20 +17,20 @@ * This is the model class for table "calendar_entry". * * The followings are the available columns in table 'calendar_entry': - * @property integer $id + * @property int $id * @property string $title * @property string $description * @property string $start_datetime * @property string $end_datetime - * @property integer $all_day - * @property integer $participation_mode + * @property int $all_day + * @property int $participation_mode * @property string $color * @property string $uid - * @property integer $allow_decline - * @property integer $allow_maybe + * @property int $allow_decline + * @property int $allow_maybe * @property string $participant_info - * @property integer closed - * @property integer max_participants + * @property int closed + * @property int max_participants * @property string rrule * @property string recurrence_id * @property int parent_event_id @@ -91,7 +91,7 @@ public function getEventType() * Defines whether or not this event is an spans over an whole day. * Note all_day events should omit any timezone translations. * - * @return boolean + * @return bool */ public function isAllDay() { @@ -233,7 +233,7 @@ public function getBadge() */ public function getCalendarOptions() { - return []; + return []; } /** diff --git a/models/CalendarEntryParticipant.php b/models/CalendarEntryParticipant.php index ce55be5a..c1021f60 100644 --- a/models/CalendarEntryParticipant.php +++ b/models/CalendarEntryParticipant.php @@ -10,21 +10,21 @@ * This is the model class for table "calendar_entry_participant". * * The followings are the available columns in table 'calendar_entry_participant': - * @property integer $id - * @property integer $calendar_entry_id - * @property integer $user_id - * @property integer $participation_state + * @property int $id + * @property int $calendar_entry_id + * @property int $user_id + * @property int $participation_state */ class CalendarEntryParticipant extends ActiveRecord { // NONE means user hasn't responded or removed a previous response. // NONE is usually not stored explicitly, instead, no matches in // calendar_entry_participant implies NONE. - const PARTICIPATION_STATE_NONE = 0; - const PARTICIPATION_STATE_DECLINED = 1; - const PARTICIPATION_STATE_MAYBE = 2; - const PARTICIPATION_STATE_ACCEPTED = 3; - const PARTICIPATION_STATE_INVITED = 4; + public const PARTICIPATION_STATE_NONE = 0; + public const PARTICIPATION_STATE_DECLINED = 1; + public const PARTICIPATION_STATE_MAYBE = 2; + public const PARTICIPATION_STATE_ACCEPTED = 3; + public const PARTICIPATION_STATE_INVITED = 4; /** * @return string the associated database table name @@ -77,7 +77,7 @@ public function afterSave($insert, $changedAttributes) { $activity = null; if ($this->participation_state == self::PARTICIPATION_STATE_ACCEPTED) { - $activity = new \humhub\modules\calendar\activities\ResponseAttend; + $activity = new \humhub\modules\calendar\activities\ResponseAttend(); } elseif ($this->participation_state == self::PARTICIPATION_STATE_MAYBE) { $activity = new \humhub\modules\calendar\activities\ResponseMaybe(); } elseif ($this->participation_state == self::PARTICIPATION_STATE_DECLINED) { diff --git a/models/CalendarEntryQuery.php b/models/CalendarEntryQuery.php index cd2bb4a1..15176d41 100644 --- a/models/CalendarEntryQuery.php +++ b/models/CalendarEntryQuery.php @@ -1,4 +1,5 @@ container($user1)->limit(20)->all(); - * + * * // Find all entries from 3 days in the past till three days in the future * CalendarEntryQuery::find()->from(-3)->to(3)->all(); - * + * * // Find all entries within today at 00:00 till three days in the future at 23:59 * CalendarEntryQuery::find()->days(3)->all(); - * + * * // Filter entries where the current user is participating * CalendarEntryQuery::find()->participate(); * ``` - * + * * > Note: If [[from()]] and [[to()]] is set, the query will use an open range query by default, which * means either the start time or the end time of the [[CalendarEntry]] has to be within the searched interval. * This behaviour can be changed by using the [[openRange()]]-method. If the openRange behaviour is deactivated * only entries with start and end time within the search interval will be included. - * + * * > Note: By default we are searching in whole day intervals and get rid of the time information of from/to boundaries by setting * the time of the from date to 00:00:00 and the time of the end date to 23:59:59. This behaviour can be deactivated by using the [[withTime()]]-method. - * + * * The following filters are available: - * + * * - [[from()]]: Date filter interval start * - [[to()]]: Date filter interval end * - [[days()]]: Filter by future or past day interval * - [[months()]]: Filter by future or past month interval * - [[years()]]: Filter by future or past year interval - * + * * - [[container()]]: Filter by container * - [[userRelated()]]: Adds a user relation by the given or default scope (e.g: Following Spaces, Member Spaces, Own Profile, etc.) * - [[participant()]]: Given user accepted invitation diff --git a/models/CalendarEntryType.php b/models/CalendarEntryType.php index 75c30224..f3c660cb 100644 --- a/models/CalendarEntryType.php +++ b/models/CalendarEntryType.php @@ -15,7 +15,6 @@ namespace humhub\modules\calendar\models; - use humhub\modules\calendar\interfaces\event\CalendarTypeIF; use humhub\modules\content\models\ContentTag; use Yii; @@ -24,9 +23,9 @@ class CalendarEntryType extends ContentTag implements CalendarTypeIF { public $moduleId = 'calendar'; - const DEFAULT_COLOR = '#59D6E4'; - const KEY = 'calendar_event'; - const ICON = 'fa-calendar'; + public const DEFAULT_COLOR = '#59D6E4'; + public const KEY = 'calendar_event'; + public const ICON = 'fa-calendar'; public function init() { @@ -60,4 +59,4 @@ public function getKey() { return static::KEY; } -} \ No newline at end of file +} diff --git a/models/ICS.php b/models/ICS.php index d61c808d..ec623584 100644 --- a/models/ICS.php +++ b/models/ICS.php @@ -17,8 +17,8 @@ */ class ICS { - const DT_FORMAT_TIME = 'php:His'; - const DT_FORMAT_DAY = 'php:Ymd'; + public const DT_FORMAT_TIME = 'php:His'; + public const DT_FORMAT_DAY = 'php:Ymd'; protected $summary; protected $description; @@ -79,7 +79,7 @@ private function buildProps() 'DTSTAMP:' . $this->formatTimestamp('now'), 'UID:' . uniqid(), 'END:VEVENT', - 'END:VCALENDAR' + 'END:VCALENDAR', ]; return $ics_props; } @@ -90,7 +90,7 @@ private function formatTimestamp($timestamp, $allDay = false) $result = Yii::$app->formatter->asDate($dt, self::DT_FORMAT_DAY); if(!$allDay) { - $result .= "T". Yii::$app->formatter->asTime($dt, self::DT_FORMAT_TIME); + $result .= "T" . Yii::$app->formatter->asTime($dt, self::DT_FORMAT_TIME); } return $result; @@ -98,6 +98,6 @@ private function formatTimestamp($timestamp, $allDay = false) private function escapeString($str) { - return preg_replace('/([\,;])/','\\\$1', $str); + return preg_replace('/([\,;])/', '\\\$1', $str); } } diff --git a/models/SnippetModuleSettings.php b/models/SnippetModuleSettings.php index 2668abb7..78f2fa3f 100644 --- a/models/SnippetModuleSettings.php +++ b/models/SnippetModuleSettings.php @@ -9,30 +9,30 @@ namespace humhub\modules\calendar\models; use Yii; -use \yii\base\Model; +use yii\base\Model; class SnippetModuleSettings extends Model { /** * Duration settings in days */ - const DURATION_WEEK = 7; - const DURATION_MONTH = 31; - const DURATION_HALF_YEAR = 182; - const DURATION_YEAR = 365; + public const DURATION_WEEK = 7; + public const DURATION_MONTH = 31; + public const DURATION_HALF_YEAR = 182; + public const DURATION_YEAR = 365; /** - * @var boolean determines if the dashboard widget should be shown or not (default true) + * @var bool determines if the dashboard widget should be shown or not (default true) */ public $upcomingEventsSnippetShow = true; /** - * @var boolean whether or not to include birthdays in the dashboard snippet + * @var bool whether or not to include birthdays in the dashboard snippet */ public $upcomingEventsSnippetIncludeBirthday = false; /** - * @var boolean duration of upcoming events for the dashboard widget (default 31 days) + * @var bool duration of upcoming events for the dashboard widget (default 31 days) */ public $upcomingEventsSnippetDuration = self::DURATION_MONTH; @@ -47,7 +47,7 @@ class SnippetModuleSettings extends Model public $upcomingEventsSnippetSortOrder = 300; /** - * @var boolean determines if the calendar top menu item adn dashboard widget should only be shown if the user installed the calendar module in his profile + * @var bool determines if the calendar top menu item adn dashboard widget should only be shown if the user installed the calendar module in his profile */ public $showIfInstalled = false; @@ -83,7 +83,7 @@ public function showGlobalCalendarItems() */ public static function instantiate() { - return new self; + return new self(); } /** @@ -95,7 +95,7 @@ public function rules() [['upcomingEventsSnippetShow', 'showIfInstalled', 'upcomingEventsSnippetIncludeBirthday'], 'boolean'], ['upcomingEventsSnippetDuration', 'number', 'min' => self::DURATION_WEEK, 'max' => self::DURATION_YEAR], ['upcomingEventsSnippetSortOrder', 'number', 'min' => 0], - ['upcomingEventsSnippetMaxItems', 'number', 'min' => 1, 'max' => 30] + ['upcomingEventsSnippetMaxItems', 'number', 'min' => 1, 'max' => 30], ]; } diff --git a/models/forms/BasicSettings.php b/models/forms/BasicSettings.php index 4720d100..78c281e7 100644 --- a/models/forms/BasicSettings.php +++ b/models/forms/BasicSettings.php @@ -17,7 +17,7 @@ class BasicSettings extends Model { - const SETTING_CONTENT_HIDDEN = 'defaults.contentHidden'; + public const SETTING_CONTENT_HIDDEN = 'defaults.contentHidden'; /** * @var ContentContainerActiveRecord diff --git a/models/forms/CalendarEntryForm.php b/models/forms/CalendarEntryForm.php index 6e1dc5da..da1275ea 100644 --- a/models/forms/CalendarEntryForm.php +++ b/models/forms/CalendarEntryForm.php @@ -37,7 +37,7 @@ class CalendarEntryForm extends Model { /** - * @var integer Content visibility + * @var int Content visibility */ public $is_public; @@ -112,7 +112,7 @@ class CalendarEntryForm extends Model public $recurrenceForm; /** - * @var boolean defines if the Task is created from wall stream + * @var bool defines if the Task is created from wall stream */ public $wall; @@ -211,7 +211,7 @@ public function updateDateRangeFromCalendar($start = null, $end = null, $timeZon if ($this->isAllDay()) { $this->translateFromMomentAfterToFormEndDate($endDT); - } else if (!empty($timeZone)) { + } elseif (!empty($timeZone)) { $startDT = CalendarUtils::translateTimezone($startDT, $timeZone, $this->timeZone); $endDT = CalendarUtils::translateTimezone($endDT, $timeZone, $this->timeZone); } @@ -230,7 +230,7 @@ private function translateFromMomentAfterToFormEndDate(DateTime $dt) if(!$this->isAllDay()) { return $dt; } - return $dt->modify('-1 day')->setTime(0,0,0); + return $dt->modify('-1 day')->setTime(0, 0, 0); } private function translateFromFormToMomentAfterEndDate(DateTime $dt) @@ -238,7 +238,7 @@ private function translateFromFormToMomentAfterEndDate(DateTime $dt) if(!$this->isAllDay()) { return $dt; } - return $dt->modify('+1 day')->setTime(0,0,0); + return $dt->modify('+1 day')->setTime(0, 0, 0); } public function setDefaultTime() @@ -407,7 +407,7 @@ private function handleDateValidationError() if(!$startDate) { if($this->original) { $startDate = $this->original->getStartDateTime(); - } else if($endDate instanceof DateTime) { + } elseif($endDate instanceof DateTime) { $startDate = clone $endDate; } else { $startDate = new DateTime(); @@ -418,7 +418,7 @@ private function handleDateValidationError() if(!$endDate) { if($this->original) { $endDate = $this->translateFromMomentAfterToFormEndDate($this->original->getEndDateTime()); - }else if($startDate instanceof DateTime) { + } elseif($startDate instanceof DateTime) { $endDate = clone $startDate; } else { $endDate = new DateTime(); @@ -541,7 +541,7 @@ public function showTimeFields() public function isAllDay() { - return (boolean) $this->entry->all_day; + return (bool) $this->entry->all_day; } public function getStartDateTime() @@ -550,7 +550,7 @@ public function getStartDateTime() $startDT = CalendarUtils::parseDateTimeString($this->start_date, $this->start_time, null, $timeZone); if($startDT && $this->isAllDay()) { - $startDT->setTime(0,0,0); + $startDT->setTime(0, 0, 0); } return $startDT; } @@ -560,7 +560,7 @@ public function getEndDateTime() $timeZone = $this->isAllDay() ? 'UTC' : $this->timeZone; $endDT = CalendarUtils::parseDateTimeString($this->end_date, $this->end_time, null, $timeZone); if($endDT && $this->isAllDay()) { - $endDT->setTime(0,0,0); + $endDT->setTime(0, 0, 0); } return $endDT; } diff --git a/models/forms/CalendarEntryParticipationForm.php b/models/forms/CalendarEntryParticipationForm.php index 6b6c3fe1..e2ed0ae8 100644 --- a/models/forms/CalendarEntryParticipationForm.php +++ b/models/forms/CalendarEntryParticipationForm.php @@ -29,7 +29,7 @@ class CalendarEntryParticipationForm extends Model public $sendUpdateNotification = 0; /** - * @var integer if set to true all space participants will be added to the event + * @var int if set to true all space participants will be added to the event */ public $forceJoin = 0; @@ -49,12 +49,12 @@ class CalendarEntryParticipationForm extends Model public $newParticipants; /** - * @var integer + * @var int */ public $newParticipantStatus; /** - * @var integer + * @var int */ public $newForceStatus; @@ -145,7 +145,7 @@ public static function getModeItems(): array return [ CalendarEntryParticipation::PARTICIPATION_MODE_NONE => Yii::t('CalendarModule.views_entry_edit', 'No participants'), CalendarEntryParticipation::PARTICIPATION_MODE_INVITE => Yii::t('CalendarModule.views_entry_edit', 'Only by Invite'), - CalendarEntryParticipation::PARTICIPATION_MODE_ALL => Yii::t('CalendarModule.views_entry_edit', 'Everybody can participate') + CalendarEntryParticipation::PARTICIPATION_MODE_ALL => Yii::t('CalendarModule.views_entry_edit', 'Everybody can participate'), ]; } diff --git a/models/forms/validators/CalendarDateFormatValidator.php b/models/forms/validators/CalendarDateFormatValidator.php index 03250672..a5d3b1cf 100644 --- a/models/forms/validators/CalendarDateFormatValidator.php +++ b/models/forms/validators/CalendarDateFormatValidator.php @@ -42,4 +42,4 @@ public function validateAttribute($model, $attribute) Yii::warning($e); } } -} \ No newline at end of file +} diff --git a/models/forms/validators/CalendarEndDateValidator.php b/models/forms/validators/CalendarEndDateValidator.php index fe391d07..db05dba7 100644 --- a/models/forms/validators/CalendarEndDateValidator.php +++ b/models/forms/validators/CalendarEndDateValidator.php @@ -15,7 +15,7 @@ /** * Validates the end date which should be bigger thant start date - * + * * @package humhub\modules\calendar\models\forms\validators */ class CalendarEndDateValidator extends Validator @@ -34,4 +34,4 @@ public function validateAttribute($model, $attribute) $this->addError($model, $attribute, Yii::t('CalendarModule.base', "End time must be after start time!")); } } -} \ No newline at end of file +} diff --git a/models/forms/validators/CalendarTypeValidator.php b/models/forms/validators/CalendarTypeValidator.php index 93b43242..7991c136 100644 --- a/models/forms/validators/CalendarTypeValidator.php +++ b/models/forms/validators/CalendarTypeValidator.php @@ -16,7 +16,7 @@ /** * Validates a date time field - * + * * @package humhub\modules\calendar\models\forms\validators */ class CalendarTypeValidator extends Validator @@ -37,4 +37,4 @@ public function validateAttribute($model, $attribute) $this->addError($model, $attribute, Yii::t('CalendarModule.base', "Invalid event type id selected.")); } } -} \ No newline at end of file +} diff --git a/models/fullcalendar/FullCalendar.php b/models/fullcalendar/FullCalendar.php index d92614ca..ce9f035d 100644 --- a/models/fullcalendar/FullCalendar.php +++ b/models/fullcalendar/FullCalendar.php @@ -7,7 +7,6 @@ namespace humhub\modules\calendar\models\fullcalendar; - use humhub\components\ActiveRecord; use humhub\modules\calendar\helpers\CalendarUtils; use humhub\modules\calendar\helpers\Url; @@ -46,7 +45,7 @@ public static function getFullCalendarArray(CalendarEventIF $entry) 'start' => static::toFullCalendarFormat($entry->getStartDateTime(), $entry->isAllDay()), 'end' => static::toFullCalendarFormat(static::getEndDate($entry), $entry->isAllDay()), 'eventDurationEditable' => true, - 'eventStartEditable' => true + 'eventStartEditable' => true, ]; if($entry instanceof ContentActiveRecord) { @@ -78,10 +77,10 @@ public static function getFullCalendarArray(CalendarEventIF $entry) } if($entry instanceof RecurrentEventIF) { - // $result['rrule'] = $entry->getRrule(); - // $result['exdate'] = $entry->getExdate(); + // $result['rrule'] = $entry->getRrule(); + // $result['exdate'] = $entry->getExdate(); } - + // Add CSS class for canceled events if($entry instanceof CalendarEventStatusIF && $entry->getEventStatus() === CalendarEventStatusIF::STATUS_CANCELLED) { $result['className'] = 'canceled'; @@ -118,7 +117,7 @@ private static function getEndDate(CalendarEventIF $entry) if($entry->isAllDay()) { // Note: In fullcalendar the end time is the moment AFTER the event. // But we store the exact event time 00:00:00 - 23:59:59 so add some time to the full day event. - $endDateTime->add(new \DateInterval('PT2H'))->setTime(0,0,0); + $endDateTime->add(new \DateInterval('PT2H'))->setTime(0, 0, 0); } return $endDateTime; @@ -143,4 +142,4 @@ public static function toFullCalendarFormat(DateTime $dt, $allDay = false) return $dt->format(CalendarUtils::DATE_FORMAT_ATOM); } -} \ No newline at end of file +} diff --git a/models/participation/CalendarEntryParticipation.php b/models/participation/CalendarEntryParticipation.php index 55ffd3c8..9b88c0c3 100644 --- a/models/participation/CalendarEntryParticipation.php +++ b/models/participation/CalendarEntryParticipation.php @@ -28,9 +28,9 @@ class CalendarEntryParticipation extends Model implements CalendarEventParticipa /** * Participation Modes */ - const PARTICIPATION_MODE_NONE = 0; - const PARTICIPATION_MODE_INVITE = 1; - const PARTICIPATION_MODE_ALL = 2; + public const PARTICIPATION_MODE_NONE = 0; + public const PARTICIPATION_MODE_INVITE = 1; + public const PARTICIPATION_MODE_ALL = 2; /** * @var array all given participation modes as array @@ -38,7 +38,7 @@ class CalendarEntryParticipation extends Model implements CalendarEventParticipa public static $participationModes = [ self::PARTICIPATION_MODE_NONE, self::PARTICIPATION_MODE_INVITE, - self::PARTICIPATION_MODE_ALL + self::PARTICIPATION_MODE_ALL, ]; /** @@ -105,7 +105,7 @@ public function setParticipationStatus(User $user, $status = self::PARTICIPATION } $participant = new CalendarEntryParticipant([ 'user_id' => $user->id, - 'calendar_entry_id' => $this->entry->id + 'calendar_entry_id' => $this->entry->id, ]); } @@ -142,7 +142,7 @@ public function findParticipants($status = []) return $this->entry->hasMany(User::class, ['id' => 'user_id'])->via('participantEntries'); } - return $this->entry->hasMany(User::class, ['id' => 'user_id'])->via('participantEntries', function($query) use ($status) { + return $this->entry->hasMany(User::class, ['id' => 'user_id'])->via('participantEntries', function ($query) use ($status) { /* @var $query ActiveQuery */ $query->andWhere(['IN', 'calendar_entry_participant.participation_state', $status]); }); @@ -216,7 +216,7 @@ public function addAllUsers($status = null) Yii::$app->queue->push(new ForceParticipation([ 'entry_id' => $this->entry->id, 'originator_id' => Yii::$app->user->getId(), - 'status' => $status + 'status' => $status, ])); } } @@ -254,7 +254,7 @@ public function findParticipant(User $user = null): ?CalendarEntryParticipant * Checks if given or current user can respond to this event * * @param User $user - * @return boolean + * @return bool * @throws \Throwable */ public function canRespond(User $user = null) @@ -308,8 +308,8 @@ public function maxParticipantCheck() public function isParticipant(User $user = null, $includeMaybe = true) { $states = $includeMaybe - ? [static::PARTICIPATION_STATUS_ACCEPTED, static::PARTICIPATION_STATUS_MAYBE] - : [static::PARTICIPATION_STATUS_ACCEPTED]; + ? [static::PARTICIPATION_STATUS_ACCEPTED, static::PARTICIPATION_STATUS_MAYBE] + : [static::PARTICIPATION_STATUS_ACCEPTED]; return in_array($this->getParticipationStatus($user), $states); } @@ -321,7 +321,7 @@ public static function isAllowedStatus(int $status): bool static::PARTICIPATION_STATUS_DECLINED, static::PARTICIPATION_STATUS_MAYBE, static::PARTICIPATION_STATUS_ACCEPTED, - static::PARTICIPATION_STATUS_INVITED + static::PARTICIPATION_STATUS_INVITED, ]); } @@ -354,7 +354,7 @@ public function getOrganizer() public function exportParticipants(?int $state, string $type): Response { $dataProvider = new ActiveDataProvider([ - 'query' => $this->findParticipants($state)->joinWith('profile') + 'query' => $this->findParticipants($state)->joinWith('profile'), ]); $statuses = ParticipantFilter::getStatuses(); @@ -367,15 +367,15 @@ public function exportParticipants(?int $state, string $type): Response 'label' => Yii::t('CalendarModule.base', 'Participation Status'), 'value' => function (User $user) use ($statuses) { return $statuses[$this->getParticipationStatus($user)] ?? ''; - } - ] + }, + ], ]; if (!Yii::$app->user->isGuest && Yii::$app->user->can(ManageUsers::class)) { $columns[] = [ 'label' => Yii::t('CalendarModule.base', 'Email'), 'value' => function (User $user) { return $user->email; - } + }, ]; $columns[] = 'profile.gender'; $columns[] = 'profile.city'; @@ -390,7 +390,7 @@ public function exportParticipants(?int $state, string $type): Response . (isset($statuses[$state]) ? '-' . $statuses[$state] : '') . '-' . $this->entry->title, 'writerType' => $type, - ] + ], ]); return $exporter->export()->send(); diff --git a/models/participation/FullCalendarSettings.php b/models/participation/FullCalendarSettings.php index d9b48ebd..c096b1dc 100644 --- a/models/participation/FullCalendarSettings.php +++ b/models/participation/FullCalendarSettings.php @@ -1,9 +1,7 @@ event->isAllDay()) { $this->targetTimezone = new DateTimeZone('UTC'); - } else if (!$this->targetTimezone) { + } elseif (!$this->targetTimezone) { $this->targetTimezone = CalendarUtils::getUserTimeZone(); - } else if (is_string($this->targetTimezone)) { + } elseif (is_string($this->targetTimezone)) { $this->targetTimezone = new DateTimeZone($this->targetTimezone); } @@ -125,7 +123,7 @@ public static function expandSingle(RecurrentEventIF $event, $recurrenceId, $sav * @return RecurrentEventIF[] * @throws Exception */ - public static function expandUpcoming(RecurrentEventIF $event, $count = 1, $start = null , $save = true) + public static function expandUpcoming(RecurrentEventIF $event, $count = 1, $start = null, $save = true) { $from = new DateTime(); $startIndex = 0; @@ -133,10 +131,10 @@ public static function expandUpcoming(RecurrentEventIF $event, $count = 1, $star if($start instanceof \DateTimeInterface) { $from = $start; $startIndex = 0; - } else if(is_bool($start)) { + } elseif(is_bool($start)) { $save = $start; $startIndex = 0; - } else if(is_int($start)) { + } elseif(is_int($start)) { $startIndex = $start; } @@ -160,7 +158,7 @@ public static function expandUpcoming(RecurrentEventIF $event, $count = 1, $star $result = []; // Add startIndex to count - $count += $startIndex; + $count += $startIndex; try { for ($i = 0; $i < $count && $it->valid(); $i++) { @@ -182,7 +180,7 @@ public static function expandUpcoming(RecurrentEventIF $event, $count = 1, $star private static function assureRootEvent(RecurrentEventIF $event) { - return RecurrenceHelper::isRecurrentRoot($event) ? $event : $event->getRecurrenceQuery()->getRecurrenceRoot(); + return RecurrenceHelper::isRecurrentRoot($event) ? $event : $event->getRecurrenceQuery()->getRecurrenceRoot(); } private static function stripTimezones(Component $component, $timeZone) @@ -238,7 +236,7 @@ private function calculateRecurrenceInstances(DateTime $start, DateTime $end) // Note: VObject supports the EXDATE property for exclusions, but not yet the RDATE and EXRULE properties // Note: VCalendar expand will translate all dates with time to UTC $vCalendar = (new VCalendar())->add($this->event, false); - $expandedVCalendar = $vCalendar->getInstance()->expand($start, $end, $this->event->isAllDay() ? null :$this->eventTimeZone); + $expandedVCalendar = $vCalendar->getInstance()->expand($start, $end, $this->event->isAllDay() ? null : $this->eventTimeZone); return $expandedVCalendar->select('VEVENT'); } @@ -300,13 +298,15 @@ private static function createRecurrenceInstanceModel(RecurrentEventIf $root, VE $model = $root->createRecurrence( CalendarUtils::toDBDateFormat($dtStart), - CalendarUtils::toDBDateFormat($dtEnd) + CalendarUtils::toDBDateFormat($dtEnd), ); $model->syncEventData($root, null); - RecurrenceHelper::syncRecurrentEventData($root, $model, - RecurrenceHelper::getRecurrenceIdFromVEvent($vEventUTC, $root->getTimezone()) + RecurrenceHelper::syncRecurrentEventData( + $root, + $model, + RecurrenceHelper::getRecurrenceIdFromVEvent($vEventUTC, $root->getTimezone()), ); if ($save) { @@ -328,4 +328,4 @@ private function findRecurrenceModel(VEvent $vEvent) $recurrenceId = RecurrenceHelper::getRecurrenceIdFromVEvent($vEvent, $this->event->getTimezone()); return $this->event->getRecurrenceQuery()->getRecurrenceInstance($recurrenceId); } -} \ No newline at end of file +} diff --git a/models/reminder/CalendarReminder.php b/models/reminder/CalendarReminder.php index fb99e35e..e33f4309 100644 --- a/models/reminder/CalendarReminder.php +++ b/models/reminder/CalendarReminder.php @@ -1,9 +1,7 @@ 60, self::UNIT_HOUR => 24, self::UNIT_DAY => 31, @@ -149,7 +147,7 @@ public function rules() $rules = [ [['unit'], 'in', 'range' => [static::UNIT_MINUTE, static::UNIT_HOUR, static::UNIT_DAY, static::UNIT_WEEK]], [['value'], 'number', 'min' => 1], - [['value'], 'validateValue'] + [['value'], 'validateValue'], ]; if ($this->active && !$this->disabled) { @@ -167,7 +165,7 @@ public function validateValue($attribute, $params) $max = static::MAX_VALUES[$this->unit]; if(!$this->validateMaxRange()) { - $this->addError('value',"Only values from 1 to $max are allowed"); + $this->addError('value', "Only values from 1 to $max are allowed"); } } @@ -185,7 +183,7 @@ public function ensureValidValue() if($this->validateMaxRange()) { return; } - + switch ($this->unit) { case static::UNIT_MINUTE: $this->unit = static::UNIT_HOUR; @@ -232,7 +230,7 @@ public static function initContainerDefault($unit, $value, ContentContainerActiv 'value' => $value, 'contentcontainer_id' => $container->contentcontainer_id, 'active' => 1, - 'disabled' => 0 + 'disabled' => 0, ]); } @@ -502,7 +500,7 @@ public static function getEntryLevelReminder(CalendarEventReminderIF $model, $us if($user === false) { $query->andWhere(['IS' ,'contentcontainer_id', new Expression('NULL')]); - } else if($user instanceof User) { + } elseif($user instanceof User) { $query->andWhere(['contentcontainer_id' => $user->contentcontainer_id]); } else { //$query->andWhere(['contentcontainer_id' => $model->getContentRecord()->contentcontainer_id]); @@ -591,7 +589,7 @@ private function getModify() } // add tolerance for cron delay.... - return '-'.$this->value.' '.$modifyUnit; + return '-' . $this->value . ' ' . $modifyUnit; } /** diff --git a/models/reminder/CalendarReminderSent.php b/models/reminder/CalendarReminderSent.php index 7264fde7..84892939 100644 --- a/models/reminder/CalendarReminderSent.php +++ b/models/reminder/CalendarReminderSent.php @@ -1,9 +1,7 @@ where($condition); } -} \ No newline at end of file +} diff --git a/models/reminder/ReminderProcessor.php b/models/reminder/ReminderProcessor.php index d6124d26..783e98fc 100644 --- a/models/reminder/ReminderProcessor.php +++ b/models/reminder/ReminderProcessor.php @@ -1,9 +1,7 @@ id; + $entryKey = get_class($entry) . ':' . $entry->id; if(!isset($entryHandled[$entryKey])) { $this->handleEntryLevelReminder($entry); $entryHandled[$entryKey] = true; @@ -275,10 +273,10 @@ private function sendReminder(CalendarReminder $reminder, CalendarEventReminderI if($entry->getStartDateTime() >= new \DateTime()) { Remind::instance()->from($entry->getContentRecord()->createdBy)->about($entry)->sendBulk($recipients); } else { - Yii::warning('Calendar reminder for past event detected with id: '.$reminder->id.' reminder not sent and disabled.'); + Yii::warning('Calendar reminder for past event detected with id: ' . $reminder->id . ' reminder not sent and disabled.'); } $reminder->acknowledge($entry); return true; } -} \ No newline at end of file +} diff --git a/models/reminder/ReminderService.php b/models/reminder/ReminderService.php index e6660ca5..ce0faa41 100644 --- a/models/reminder/ReminderService.php +++ b/models/reminder/ReminderService.php @@ -1,10 +1,7 @@ getModule('calendar')->get(CalendarService::class); (new ReminderProcessor(['calendarService' => $calendarService]))->run(); } -} \ No newline at end of file +} diff --git a/models/reminder/forms/ReminderSettings.php b/models/reminder/forms/ReminderSettings.php index f68c8e67..1da0eee2 100644 --- a/models/reminder/forms/ReminderSettings.php +++ b/models/reminder/forms/ReminderSettings.php @@ -1,9 +1,7 @@ hasDefaults && $this->isDefaultsLoaded()) { $this->reminderType = static::REMINDER_TYPE_DEFAULT; - } else if($this->isDisabled()) { + } elseif($this->isDisabled()) { $this->reminderType = static::REMINDER_TYPE_NONE; } else { $this->reminderType = static::REMINDER_TYPE_CUSTOM; @@ -159,7 +157,7 @@ public function load($data, $formName = null) if($this->isReminderType(static::REMINDER_TYPE_DEFAULT) || $this->isReminderType(static::REMINDER_TYPE_NONE)) { $this->reminders = []; - } else if(isset($data[CalendarReminder::instance()->formName()])) { + } elseif(isset($data[CalendarReminder::instance()->formName()])) { $this->reminders = []; $reminderLoaded = true; $maxReminders = $this->getMaxReminders(); @@ -266,20 +264,20 @@ public function isGlobalSettings() public function initReminder($disabled = false) { - if($this->entry) { - $result = $disabled - ? CalendarReminder::initDisableEntryLevelDefaults($this->entry, $this->user) - : CalendarReminder::initEntryLevel(null, null, $this->entry, $this->user); - } else if($this->container) { - $result = $disabled - ? CalendarReminder::initDisableContainerDefaults($this->container) - : CalendarReminder::initContainerDefault(null, null, $this->container); - } else { - // There is no disabled global reminder - $result = CalendarReminder::initGlobalDefault(null, null); - } - - return $result; + if($this->entry) { + $result = $disabled + ? CalendarReminder::initDisableEntryLevelDefaults($this->entry, $this->user) + : CalendarReminder::initEntryLevel(null, null, $this->entry, $this->user); + } elseif($this->container) { + $result = $disabled + ? CalendarReminder::initDisableContainerDefaults($this->container) + : CalendarReminder::initContainerDefault(null, null, $this->container); + } else { + // There is no disabled global reminder + $result = CalendarReminder::initGlobalDefault(null, null); + } + + return $result; } public function isDefaultsLoaded() diff --git a/notifications/CalendarNotificationCategory.php b/notifications/CalendarNotificationCategory.php index 43bf67b1..6fdc077b 100644 --- a/notifications/CalendarNotificationCategory.php +++ b/notifications/CalendarNotificationCategory.php @@ -39,4 +39,4 @@ public function getDescription() { return Yii::t('CalendarModule.notifications_CalendarNotificationCategory', 'Receive Calendar related Notifications.'); } -} \ No newline at end of file +} diff --git a/notifications/CanceledEvent.php b/notifications/CanceledEvent.php index 86804cb7..d4ea725c 100644 --- a/notifications/CanceledEvent.php +++ b/notifications/CanceledEvent.php @@ -49,12 +49,12 @@ public function html() return Yii::t('CalendarModule.notifications_views_CanceledEvent', '{displayName} canceled the event "{contentTitle}" in the space {spaceName}.', [ 'displayName' => Html::tag('strong', Html::encode($this->originator->displayName)), 'contentTitle' => $this->getContentInfo($this->source, false), - 'spaceName' => Html::encode($this->source->content->container->displayName) + 'spaceName' => Html::encode($this->source->content->container->displayName), ]); } else { return Yii::t('ContentModule.notifications_views_ContentCreated', '{displayName} canceled the event "{contentTitle}".', [ 'displayName' => Html::tag('strong', Html::encode($this->originator->displayName)), - 'contentTitle' => $this->getContentInfo($this->source, false) + 'contentTitle' => $this->getContentInfo($this->source, false), ]); } } @@ -66,7 +66,7 @@ public function getMailSubject() { return Yii::t('CalendarModule.notifications_views_CanceledEvent', '{displayName} canceled the event "{contentTitle}".', [ 'displayName' => Html::encode($this->originator->displayName), - 'contentTitle' => $this->getContentInfo($this->source, false) + 'contentTitle' => $this->getContentInfo($this->source, false), ]); } -} \ No newline at end of file +} diff --git a/notifications/Remind.php b/notifications/Remind.php index 7cf3b920..291cb740 100644 --- a/notifications/Remind.php +++ b/notifications/Remind.php @@ -54,7 +54,7 @@ public function html() if($this->source instanceof CalendarEventReminderIF) { return Yii::t('CalendarModule.reminder', 'You have an {type} coming up: {title}', [ 'type' => Html::encode($this->getEventType()), - 'title' => RichText::preview($this->source->getTitle(), 25) + 'title' => RichText::preview($this->source->getTitle(), 25), ]); } @@ -81,10 +81,10 @@ public function getMailSubject() if($this->source instanceof CalendarEventReminderIF) { return Yii::t('CalendarModule.reminder', 'Upcoming {type}: {title}', [ 'type' => $this->getEventType(), - 'title' => $this->source->getTitle() + 'title' => $this->source->getTitle(), ]); } return Yii::t('CalendarModule.reminder', 'Upcoming {type}', ['type' => $this->getEventType()]); } -} \ No newline at end of file +} diff --git a/permissions/CreateEntry.php b/permissions/CreateEntry.php index 749b069c..ebbf1870 100644 --- a/permissions/CreateEntry.php +++ b/permissions/CreateEntry.php @@ -30,7 +30,7 @@ class CreateEntry extends \humhub\libs\BasePermission Space::USERGROUP_ADMIN, Space::USERGROUP_MODERATOR, Space::USERGROUP_MEMBER, - User::USERGROUP_SELF + User::USERGROUP_SELF, ]; /** diff --git a/permissions/ManageEntry.php b/permissions/ManageEntry.php index ba37ce7f..b7501b80 100644 --- a/permissions/ManageEntry.php +++ b/permissions/ManageEntry.php @@ -30,7 +30,7 @@ class ManageEntry extends \humhub\libs\BasePermission Space::USERGROUP_OWNER, Space::USERGROUP_ADMIN, Space::USERGROUP_MODERATOR, - User::USERGROUP_SELF + User::USERGROUP_SELF, ]; /** diff --git a/tests/codeception/_support/AcceptanceTester.php b/tests/codeception/_support/AcceptanceTester.php index f36a2c96..31613548 100644 --- a/tests/codeception/_support/AcceptanceTester.php +++ b/tests/codeception/_support/AcceptanceTester.php @@ -1,4 +1,5 @@ waitForText('Create Event'); $this->fillField('CalendarEntry[title]', $title); - $this->fillField('#calendarentry-description .humhub-ui-richtext' , $description); + $this->fillField('#calendarentry-description .humhub-ui-richtext', $description); if ($startTime) { $this->click('[for="calendarentry-all_day"]'); diff --git a/tests/codeception/_support/ApiTester.php b/tests/codeception/_support/ApiTester.php index a38c32ee..77d89006 100644 --- a/tests/codeception/_support/ApiTester.php +++ b/tests/codeception/_support/ApiTester.php @@ -1,4 +1,5 @@ add(new DateInterval($days)); $fullDay = CalendarUtils::isAllDay($from, $to); - }else if (is_int($days)) { + } elseif (is_int($days)) { $fullDay = true; $to = clone $from; - $to->setTime(0,0,0)->add(new DateInterval("P" . $days . "D")); - } else if($days instanceof DateTime) { + $to->setTime(0, 0, 0)->add(new DateInterval("P" . $days . "D")); + } elseif($days instanceof DateTime) { $to = clone $days; - } else if($days instanceof DateInterval) { + } elseif($days instanceof DateInterval) { $to = clone $from; $to->add($days); - } else if(!$days) { + } elseif(!$days) { $to = clone $from; $to->add(new DateInterval('PT1H')); } @@ -58,8 +56,8 @@ protected function createEntry($from, $days, $title, $container = null, $visibil if($fullDay) { $entry->all_day = 1; - $from->setTime(0,0,0); - $to->modify('+1 hour')->setTime(0,0,0); + $from->setTime(0, 0, 0); + $to->modify('+1 hour')->setTime(0, 0, 0); } else { $entry->all_day = 0; } @@ -76,4 +74,4 @@ protected function createEntry($from, $days, $title, $container = null, $visibil $this->assertTrue($entry->save()); return $entry; } -} \ No newline at end of file +} diff --git a/tests/codeception/_support/FunctionalTester.php b/tests/codeception/_support/FunctionalTester.php index a1adab63..328f177e 100644 --- a/tests/codeception/_support/FunctionalTester.php +++ b/tests/codeception/_support/FunctionalTester.php @@ -1,4 +1,5 @@ rootEvent; } - $expandStart = (new DateTime)->setDate(2019, 12, $fromDay)->setTime(0,0,0); - $expandEnd = (new DateTime)->setDate(2019, 12, $toDay)->setTime(23,59,59); + $expandStart = (new DateTime())->setDate(2019, 12, $fromDay)->setTime(0, 0, 0); + $expandEnd = (new DateTime())->setDate(2019, 12, $toDay)->setTime(23, 59, 59); $result = []; return CalendarRecurrenceExpand::expand($entry, $expandStart, $expandEnd, $result, $save); } @@ -79,4 +77,4 @@ protected function getEntryDate() { return (new DateTime())->setDate(2019, 12, 1); } -} \ No newline at end of file +} diff --git a/tests/codeception/_support/UnitTester.php b/tests/codeception/_support/UnitTester.php index ee56b861..ae420050 100644 --- a/tests/codeception/_support/UnitTester.php +++ b/tests/codeception/_support/UnitTester.php @@ -1,4 +1,5 @@ amAdmin(); @@ -48,10 +47,10 @@ public function testInstallAndCreatEntry(AcceptanceTester $I) $I->amGoingTo('Save my new calendar entry'); $I->click('Next', '#globalModal'); $I->expectTo('see my event loaded into my modal'); - $I->waitForText('My Test Entry',null, '#globalModal'); - $I->waitForText('Next',null, '#globalModal'); + $I->waitForText('My Test Entry', null, '#globalModal'); + $I->waitForText('Next', null, '#globalModal'); $I->click('Next', '#globalModal'); - $I->waitForText('Save',null, '#globalModal'); + $I->waitForText('Save', null, '#globalModal'); $I->click('Save', '#globalModal'); $I->wait(1); @@ -91,7 +90,7 @@ public function testAddAll(AcceptanceTester $I) $I->expect('All space members to be attending'); $I->click('New Test Event'); - $I->waitForText('2 Invited', null,'#globalModal'); + $I->waitForText('2 Invited', null, '#globalModal'); $I->amOnSpace(1, '/calendar/view/index'); $I->wantToTest('Adding a new space member and using then using the add all members again'); @@ -110,7 +109,7 @@ public function testAddAll(AcceptanceTester $I) $I->waitForElementVisible('.fc-event'); $I->jsClick('.fc-event'); - $I->waitForText('New Test Event',null, '#globalModal'); + $I->waitForText('New Test Event', null, '#globalModal'); $I->click('Invite', '#globalModal .modal-footer'); $I->waitForText('Participants', null, '#globalModal'); @@ -122,7 +121,7 @@ public function testAddAll(AcceptanceTester $I) $memberCount = Membership::getSpaceMembersQuery(Space::findOne(['id' => 1]))->count(); - $I->waitForText($memberCount.' Invited', null,'#globalModal'); + $I->waitForText($memberCount . ' Invited', null, '#globalModal'); $I->amUser1(true); $I->waitForText('You are invited, please select your role:'); @@ -162,4 +161,4 @@ public function testAddAll(AcceptanceTester $I) $I->wait(1); $I->dontSeeElement('[for="calendarentryparticipationform-forcejoin"]'); } -} \ No newline at end of file +} diff --git a/tests/codeception/acceptance/GlobalCalendarCest.php b/tests/codeception/acceptance/GlobalCalendarCest.php index 5440263b..7643c4ee 100644 --- a/tests/codeception/acceptance/GlobalCalendarCest.php +++ b/tests/codeception/acceptance/GlobalCalendarCest.php @@ -34,7 +34,7 @@ public function testGlobalCalendarCreateEntry(AcceptanceTester $I) $I->amOnRoute(['/calendar/global/index']); $I->expectTo('see my space calendar entry'); $I->see('Select calendars'); - $I->waitForText('Space Event',null, '#calendar'); + $I->waitForText('Space Event', null, '#calendar'); // Active space and profile filter $I->click('.calendar_my_spaces'); @@ -42,7 +42,7 @@ public function testGlobalCalendarCreateEntry(AcceptanceTester $I) $I->wait(2); - $I->waitForText( 'Space Event', null,'#calendar'); + $I->waitForText('Space Event', null, '#calendar'); $I->wantToTest('the global calendar filters'); $I->amGoingTo('deselect the space clalendar filter'); @@ -64,14 +64,14 @@ public function testGlobalCalendarCreateEntry(AcceptanceTester $I) $I->waitForText('Create Event', null, '#globalModal'); $I->fillField('CalendarEntry[title]', 'My Test Profile Entry'); - $I->fillField('#calendarentry-description .humhub-ui-richtext', 'My Test Profile Entry Description'); + $I->fillField('#calendarentry-description .humhub-ui-richtext', 'My Test Profile Entry Description'); $I->click('Next', '#globalModal'); //$I->waitForText('Close', null, '#globalModal'); //$I->click('Close', '#globalModal'); //$I->wait(1); - $I->waitForText('My Test Profile Entry',null, '.fc-event-container'); + $I->waitForText('My Test Profile Entry', null, '.fc-event-container'); $I->waitForElementVisible('.calendar_my_spaces'); $I->click('.calendar_my_spaces'); @@ -98,17 +98,17 @@ public function testChangeEventTime(AcceptanceTester $I) $I->click('.fc-day-top.fc-today'); $I->waitForText('Create Event'); -// $I->click('[for="calendarentry-all_day"]'); -// $I->wait(1); + // $I->click('[for="calendarentry-all_day"]'); + // $I->wait(1); $I->wantToTest('how the end time will change value if the start time is changed'); $I->fillField('#calendarentryform-start_time', '01:00 PM'); -// $I->fillField('input[name="CalendarEntryForm[start_time]"]', '01:00 PM'); -// $I->executeJS('$(".field-calendarentryform-start_time .picker").click();'); -// $I->seeElement('input', ['name' => 'meridian']); -// $I->fillField('input[name="hour"]', '01'); -// $I->fillField('input[name="minute"]', '00'); -// $I->fillField('input[name="meridian"]', 'PM'); + // $I->fillField('input[name="CalendarEntryForm[start_time]"]', '01:00 PM'); + // $I->executeJS('$(".field-calendarentryform-start_time .picker").click();'); + // $I->seeElement('input', ['name' => 'meridian']); + // $I->fillField('input[name="hour"]', '01'); + // $I->fillField('input[name="minute"]', '00'); + // $I->fillField('input[name="meridian"]', 'PM'); $I->executeJS('$("#calendarentryform-start_time").focus().val("01:00 PM").change();'); $I->wait(1); $I->seeInField('#calendarentryform-end_time', '02:00 PM'); @@ -119,4 +119,4 @@ public function testChangeEventTime(AcceptanceTester $I) $I->wait(1); $I->seeInField('#calendarentryform-start_time', '01:00 AM'); } -} \ No newline at end of file +} diff --git a/tests/codeception/acceptance/GlobalGuestCalendarCest.php b/tests/codeception/acceptance/GlobalGuestCalendarCest.php index ab269e53..b7fb7de9 100644 --- a/tests/codeception/acceptance/GlobalGuestCalendarCest.php +++ b/tests/codeception/acceptance/GlobalGuestCalendarCest.php @@ -30,7 +30,7 @@ public function testGlobalGuestViewProtectedSpace(AcceptanceTester $I) $I->jsClick('#calendarentryform-is_public'); $I->click('Next', '#globalModal'); - $I->waitForText('Public Event',null, '.fc-event-container'); + $I->waitForText('Public Event', null, '.fc-event-container'); $I->click('Next', '#globalModal'); $I->click('Save', '#globalModal'); @@ -42,7 +42,7 @@ public function testGlobalGuestViewProtectedSpace(AcceptanceTester $I) $I->wait(1); $I->createEventToday('Private Event', 'Private Event Description'); - $I->waitForText('Next',null, '#globalModal'); + $I->waitForText('Next', null, '#globalModal'); $I->click('Next', '#globalModal'); $I->click('Save', '#globalModal'); $I->seeSuccess(); @@ -52,8 +52,8 @@ public function testGlobalGuestViewProtectedSpace(AcceptanceTester $I) $I->logout(); $I->amOnRoute(['/calendar/global']); $I->wait(3); - $I->dontSee('Public Event',null, '.fc-event-container'); - $I->dontSee('Private Event',null, '.fc-event-container'); + $I->dontSee('Public Event', null, '.fc-event-container'); + $I->dontSee('Private Event', null, '.fc-event-container'); } public function testGlobalGuestViewPublicSpace(AcceptanceTester $I) @@ -72,7 +72,7 @@ public function testGlobalGuestViewPublicSpace(AcceptanceTester $I) $I->jsClick('#calendarentryform-is_public'); $I->click('Next', '#globalModal'); - $I->waitForText('Public Event',null, '.fc-event-container'); + $I->waitForText('Public Event', null, '.fc-event-container'); $I->wait(1); $I->click('Next', '#globalModal'); $I->click('Save', '#globalModal'); @@ -92,8 +92,8 @@ public function testGlobalGuestViewPublicSpace(AcceptanceTester $I) $I->logout(); $I->amOnRoute(['/calendar/global']); - $I->waitForText('Public Event',null, '.fc-event-container'); - $I->dontSee('Private Event',null, '.fc-event-container'); + $I->waitForText('Public Event', null, '.fc-event-container'); + $I->dontSee('Private Event', null, '.fc-event-container'); $I->wantToTest('if a guest can opent the event'); $I->click('.fc-event-container'); @@ -109,4 +109,4 @@ public function testGlobalGuestViewPublicSpace(AcceptanceTester $I) $I->dontSeeInDropDown('#globalModal .dropdown-toggle', 'Delete'); $I->dontSeeInDropDown('#globalModal .dropdown-toggle', 'Cancel Event'); } -} \ No newline at end of file +} diff --git a/tests/codeception/acceptance/ParticipationCest.php b/tests/codeception/acceptance/ParticipationCest.php index b3cfc9ba..c5607351 100644 --- a/tests/codeception/acceptance/ParticipationCest.php +++ b/tests/codeception/acceptance/ParticipationCest.php @@ -44,13 +44,13 @@ public function testInstallAndCreatEntry(AcceptanceTester $I) $I->wait(1); $I->click('Participant Event'); - $I->waitForText('Participant Description',null,'#globalModal'); + $I->waitForText('Participant Description', null, '#globalModal'); $I->dontSee('Attend', '#globalModal button'); $I->dontSee('Maybe', '#globalModal button'); $I->dontSee('Decline', '#globalModal button'); $I->click('Invite', '#globalModal'); - $I->waitForText('Participants',null, '#globalModal'); + $I->waitForText('Participants', null, '#globalModal'); $I->selectOption('#calendarentry-participation_mode', 2); @@ -60,13 +60,13 @@ public function testInstallAndCreatEntry(AcceptanceTester $I) $I->click('[type="submit"]'); $I->seeSuccess(); $I->click('Participant Event'); - $I->waitForText('Participant Description',null, '#globalModal'); + $I->waitForText('Participant Description', null, '#globalModal'); $I->see('Attend', '#globalModal button'); $I->see('Maybe', '#globalModal button'); $I->see('Decline', '#globalModal button'); $I->click('Invite', '#globalModal'); - $I->waitForText('Participants',null, '#globalModal h4'); + $I->waitForText('Participants', null, '#globalModal h4'); $I->click('.tab-participation'); $I->click('[for="calendarentry-allow_decline"]', '#globalModal'); $I->click('[for="calendarentry-allow_maybe"]', '#globalModal'); @@ -74,7 +74,7 @@ public function testInstallAndCreatEntry(AcceptanceTester $I) $I->wait(1); $I->click('Participant Event'); - $I->waitForText('Participant Description',null, '#globalModal'); + $I->waitForText('Participant Description', null, '#globalModal'); $I->see('Attend', '#globalModal button'); $I->dontSee('Maybe', '#globalModal button'); $I->dontSee('Decline', '#globalModal button'); @@ -85,4 +85,4 @@ public function testInstallAndCreatEntry(AcceptanceTester $I) $I->waitForText('Participants', null, '#globalModal'); $I->see('Admin Tester', '#globalModal'); } -} \ No newline at end of file +} diff --git a/tests/codeception/acceptance/SettingsCest.php b/tests/codeception/acceptance/SettingsCest.php index 6c476e93..d608e752 100644 --- a/tests/codeception/acceptance/SettingsCest.php +++ b/tests/codeception/acceptance/SettingsCest.php @@ -36,10 +36,10 @@ public function testInstallAndCreatEntry(AcceptanceTester $I) $I->enableModule(1, 'calendar'); $I->amOnSpace1('/calendar/view'); - $I->createEventToday('Setting Event','Setting Description',null,null,false); + $I->createEventToday('Setting Event', 'Setting Description', null, null, false); $I->click('Next', '#globalModal'); - $I->waitForText('Participants',null, '#globalModal'); + $I->waitForText('Participants', null, '#globalModal'); $I->seeInField('#calendarentry-participation_mode', '0'); $I->dontSeeElement('.participationOnly'); @@ -58,9 +58,9 @@ public function testInstallAndCreatEntry(AcceptanceTester $I) $I->see('Reset', '.tab-pane.active'); $I->amOnSpace1('/calendar/view'); - $I->createEventToday('Setting Event','Setting Description',null,null,false); + $I->createEventToday('Setting Event', 'Setting Description', null, null, false); $I->click('Next', '#globalModal'); - $I->waitForText('Participants',null, '#globalModal h4'); + $I->waitForText('Participants', null, '#globalModal h4'); $I->seeInField('#calendarentry-participation_mode', '2'); $I->seeElement('.participationOnly'); $I->dontSeeCheckboxIsChecked('#calendarentry-allow_decline'); diff --git a/tests/codeception/acceptance/_bootstrap.php b/tests/codeception/acceptance/_bootstrap.php index 0f508ca5..9e54876d 100644 --- a/tests/codeception/acceptance/_bootstrap.php +++ b/tests/codeception/acceptance/_bootstrap.php @@ -3,4 +3,4 @@ * Initialize the HumHub Application for functional testing. The default application configuration for this suite can be overwritten * in @tests/config/functional.php */ -require(Yii::getAlias('@humhubTests/codeception/acceptance/_bootstrap.php')); \ No newline at end of file +require(Yii::getAlias('@humhubTests/codeception/acceptance/_bootstrap.php')); diff --git a/tests/codeception/api/_bootstrap.php b/tests/codeception/api/_bootstrap.php index 0f508ca5..9e54876d 100644 --- a/tests/codeception/api/_bootstrap.php +++ b/tests/codeception/api/_bootstrap.php @@ -3,4 +3,4 @@ * Initialize the HumHub Application for functional testing. The default application configuration for this suite can be overwritten * in @tests/config/functional.php */ -require(Yii::getAlias('@humhubTests/codeception/acceptance/_bootstrap.php')); \ No newline at end of file +require(Yii::getAlias('@humhubTests/codeception/acceptance/_bootstrap.php')); diff --git a/tests/codeception/config/unit.php b/tests/codeception/config/unit.php index 44c02338..15d04286 100644 --- a/tests/codeception/config/unit.php +++ b/tests/codeception/config/unit.php @@ -1,3 +1,3 @@ becomeUser('User1'); - $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime)->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_USERRELATED => [ActiveQueryContent::USER_RELATED_SCOPE_FOLLOWED_USERS]]); + $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime())->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_USERRELATED => [ActiveQueryContent::USER_RELATED_SCOPE_FOLLOWED_USERS]]); $this->assertEquals(0, count($result)); $this->follow('Admin'); - $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime)->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_USERRELATED => [ActiveQueryContent::USER_RELATED_SCOPE_FOLLOWED_USERS]]); + $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime())->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_USERRELATED => [ActiveQueryContent::USER_RELATED_SCOPE_FOLLOWED_USERS]]); $this->assertEquals(1, count($result)); $this->becomeFriendWith('User2'); - $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime)->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_USERRELATED => [ActiveQueryContent::USER_RELATED_SCOPE_FOLLOWED_USERS]]); + $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime())->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_USERRELATED => [ActiveQueryContent::USER_RELATED_SCOPE_FOLLOWED_USERS]]); $this->assertEquals(2, count($result)); } @@ -58,16 +58,16 @@ public function testFriendQuery() $this->becomeFriendWith('User2'); $this->enableFriendships(false); - $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime)->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_DASHBOARD]); + $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime())->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_DASHBOARD]); $this->assertEquals(0, count($result)); $this->enableFriendships(); - $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime)->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_DASHBOARD]); + $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime())->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_DASHBOARD]); $this->assertEquals(1, count($result)); $this->becomeUser('User2'); $this->becomeFriendWith('User1'); - $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime)->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_DASHBOARD]); + $result = BirthdayCalendarQuery::findForFilter(new DateTime(), (new DateTime())->add(new DateInterval('P10D')), null, [BirthdayCalendarQuery::FILTER_DASHBOARD]); $this->assertEquals(2, count($result)); } @@ -127,4 +127,4 @@ public function testDisabledUsers() } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/entry/CalendarEntryFormSequenceTest.php b/tests/codeception/unit/entry/CalendarEntryFormSequenceTest.php index 012e52a3..9833c070 100644 --- a/tests/codeception/unit/entry/CalendarEntryFormSequenceTest.php +++ b/tests/codeception/unit/entry/CalendarEntryFormSequenceTest.php @@ -1,9 +1,7 @@ '01:00 PM', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($this->form->save()); @@ -52,14 +50,14 @@ public function testSequenceIncrementDate() $calendarForm = new CalendarEntryForm(['entry' => $this->form->entry]); $calendarForm->load([ 'CalendarEntry' => [ - 'all_day' => '1' + 'all_day' => '1', ], 'CalendarEntryForm' => [ 'start_date' => '7/16/17', 'end_date' => '8/16/17', 'reminder' => 1, 'recurring' => 1, - ] + ], ]); $this->assertTrue($calendarForm->save()); @@ -72,13 +70,13 @@ public function testSequenceIncrementEndDate() $calendarForm = new CalendarEntryForm(['entry' => $this->form->entry]); $calendarForm->load([ 'CalendarEntry' => [ - 'all_day' => '1' + 'all_day' => '1', ], 'CalendarEntryForm' => [ 'end_date' => '8/16/17', 'reminder' => 1, 'recurring' => 1, - ] + ], ]); $this->assertTrue($calendarForm->save()); @@ -97,8 +95,8 @@ public function testSequenceIncrementRRule() ], 'RecurrenceFormModel' => [ 'frequency' => Frequency::DAILY, - 'interval' => 1 - ] + 'interval' => 1, + ], ]); $this->assertTrue($calendarForm->save()); @@ -122,4 +120,4 @@ public function testSequenceNotIncremented() $this->assertEquals(0, $this->form->entry->sequence); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/entry/CalendarEntryFormTest.php b/tests/codeception/unit/entry/CalendarEntryFormTest.php index ce4cf878..4004c574 100644 --- a/tests/codeception/unit/entry/CalendarEntryFormTest.php +++ b/tests/codeception/unit/entry/CalendarEntryFormTest.php @@ -18,7 +18,6 @@ class CalendarEntryFormTest extends CalendarUnitTest { - public function testDefaultData() { $this->becomeUser('Admin'); @@ -30,7 +29,7 @@ public function testDefaultData() 'all_day' => '0', 'title' => 'Test title', 'description' => 'TestDescription', - 'participation_mode' => 2 + 'participation_mode' => 2, ], 'CalendarEntryForm' => [ 'is_public' => '1', @@ -40,7 +39,7 @@ public function testDefaultData() 'end_time' => '01:00 PM', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($calendarForm->save()); @@ -132,14 +131,14 @@ public function testLoadSingleAllDay() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '1' + 'all_day' => '1', ], 'CalendarEntryForm' => [ 'start_date' => '2/1/20', 'start_time' => '10:00 AM', // will be ignored 'end_date' => '2/1/20', - 'end_time' => '10:30 AM' // will be ignored - ] + 'end_time' => '10:30 AM', // will be ignored + ], ])); $this->assertTrue($form->isAllDay()); @@ -160,14 +159,14 @@ public function testLoadMultipleAllDay() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '1' + 'all_day' => '1', ], 'CalendarEntryForm' => [ 'start_date' => '2/1/20', 'start_time' => '10:00 AM', // will be ignored 'end_date' => '2/2/20', - 'end_time' => '10:30 AM' // will be ignored - ] + 'end_time' => '10:30 AM', // will be ignored + ], ])); $this->assertTrue($form->isAllDay()); @@ -188,14 +187,14 @@ public function testLoadNonAllDay() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'start_date' => '2/1/20', 'start_time' => '10:00 AM', 'end_date' => '2/1/20', - 'end_time' => '10:30 AM' - ] + 'end_time' => '10:30 AM', + ], ])); $this->assertFalse($form->isAllDay()); @@ -216,14 +215,14 @@ public function testLoadNonAllDayMultiDaySpan() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'start_date' => '2/1/20', 'start_time' => '10:00 AM', 'end_date' => '2/2/20', - 'end_time' => '10:30 AM' - ] + 'end_time' => '10:30 AM', + ], ])); $this->assertFalse($form->isAllDay()); @@ -290,7 +289,7 @@ public function testEditAllDay() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '1' + 'all_day' => '1', ], 'CalendarEntryForm' => [ 'start_date' => '2/2/20', @@ -299,7 +298,7 @@ public function testEditAllDay() 'end_time' => '10:30 AM', // will be ignored 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($form->save()); @@ -324,14 +323,14 @@ public function testInvalidStartDate() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'start_date' => '03.01.20', 'start_time' => '10:00 AM', 'end_date' => '2/3/20', - 'end_time' => '10:30 AM' - ] + 'end_time' => '10:30 AM', + ], ])); $this->assertFalse($form->save()); @@ -356,14 +355,14 @@ public function testInvalidEndDate() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'start_date' => '2/3/20', 'start_time' => '10:00 AM', 'end_date' => '03.01.20', - 'end_time' => '10:30 AM' - ] + 'end_time' => '10:30 AM', + ], ])); $this->assertFalse($form->save()); @@ -388,14 +387,14 @@ public function testInvalidDates() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'start_date' => '03.01.20', 'start_time' => '10:00 AM', 'end_date' => '03.01.20', - 'end_time' => '10:30 AM' - ] + 'end_time' => '10:30 AM', + ], ])); $this->assertFalse($form->save()); @@ -420,14 +419,14 @@ public function testEditAllDayFail() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => null, - 'all_day' => '1' + 'all_day' => '1', ], 'CalendarEntryForm' => [ 'start_date' => '2/2/20', 'start_time' => '10:00 AM', // will be ignored 'end_date' => '2/3/20', - 'end_time' => '10:30 AM' // will be ignored - ] + 'end_time' => '10:30 AM', // will be ignored + ], ])); $this->assertFalse($form->save()); @@ -452,7 +451,7 @@ public function testEditNonAllDay() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'start_date' => '2/2/20', @@ -461,7 +460,7 @@ public function testEditNonAllDay() 'end_time' => '10:30 AM', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($form->save()); @@ -488,14 +487,14 @@ public function testEditNonAllDayFail() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => null, - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'start_date' => '2/2/20', 'start_time' => '10:00 AM', 'end_date' => '2/3/20', - 'end_time' => '10:30 AM' - ] + 'end_time' => '10:30 AM', + ], ])); $this->assertFalse($form->save()); @@ -523,7 +522,7 @@ public function testChangeFromAllDayToNonAllDay() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'start_date' => '2/2/20', @@ -532,7 +531,7 @@ public function testChangeFromAllDayToNonAllDay() 'end_time' => '10:30 AM', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($form->save()); @@ -561,14 +560,14 @@ public function testChangeFromNonAllDayToAllDay() $this->assertTrue($form->load([ 'CalendarEntry' => [ 'title' => 'Test', - 'all_day' => '1' + 'all_day' => '1', ], 'CalendarEntryForm' => [ 'start_date' => '2/2/20', 'end_date' => '2/3/20', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($form->save()); diff --git a/tests/codeception/unit/entry/CalendarEntryFormatTest.php b/tests/codeception/unit/entry/CalendarEntryFormatTest.php index dbe8dfa5..843cd1d4 100644 --- a/tests/codeception/unit/entry/CalendarEntryFormatTest.php +++ b/tests/codeception/unit/entry/CalendarEntryFormatTest.php @@ -28,7 +28,7 @@ public function testGetDurationDaysSingleDay() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-13 00:00:00', 'all_day' => 1, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); $this->assertEquals(1, $entry->formatter->getDurationDays()); } @@ -39,7 +39,7 @@ public function testGetDurationDaysMultipleDays() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-15 00:00:00', 'all_day' => 1, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); $this->assertEquals(3, $entry->formatter->getDurationDays()); } @@ -50,7 +50,7 @@ public function testGetDurationDaysMultipleDayNonAllDay() 'start_datetime' => '2017-09-12 10:00:00', 'end_datetime' => '2017-09-15 10:30:00', 'all_day' => 0, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); $this->assertEquals(3, $entry->formatter->getDurationDays()); } @@ -61,7 +61,7 @@ public function testGetDurationDaysMultipleDayNonAllDay2() 'start_datetime' => '2017-09-12 10:00:00', 'end_datetime' => '2017-09-15 09:30:00', 'all_day' => 0, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); $this->assertEquals(2, $entry->formatter->getDurationDays()); } @@ -77,7 +77,7 @@ public function testAllDayOneDayFormatSameTimezone() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-13 00:00:00', 'all_day' => 1, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); $this->assertEquals('12. September 2017', $entry->getFormattedTime()); @@ -95,7 +95,7 @@ public function testAllDayOneDayFormatDifferentTimezone() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-13 00:00:00', 'all_day' => 1, - 'time_zone' => 'Europe/Berlin' + 'time_zone' => 'Europe/Berlin', ]); $this->assertEquals("12. September 2017", $entry->getFormattedTime()); @@ -113,7 +113,7 @@ public function testAllDayOneDayFormatDifferentTimezone2() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-13 00:00:00', 'all_day' => 1, - 'time_zone' => 'UTC' + 'time_zone' => 'UTC', ]); // Date is not trnaslated since we use all_day = 1 @@ -132,7 +132,7 @@ public function testAllDayMultipleDayFormat() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-14 00:00:00', 'all_day' => 1, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); // Date is not trnaslated since we use all_day = 1 @@ -151,7 +151,7 @@ public function testAllDayMultipleDayFormatDifferentTimezone() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-14 00:00:00', 'all_day' => 1, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); // Date is not trnaslated since we use all_day = 1 @@ -170,7 +170,7 @@ public function testNonAllDayOneDayFormatDifferentTimezone() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-12 12:59:00', 'all_day' => 0, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); // Date is not trnaslated since we use all_day = 1 @@ -189,7 +189,7 @@ public function testNonAllDayMultipleDayFormatDifferentTimezone() 'start_datetime' => '2017-09-12 00:00:00', 'end_datetime' => '2017-09-13 12:59:00', 'all_day' => 0, - 'time_zone' => Yii::$app->timeZone + 'time_zone' => Yii::$app->timeZone, ]); // Date is not trnaslated since we use all_day = 1 @@ -197,4 +197,4 @@ public function testNonAllDayMultipleDayFormatDifferentTimezone() $this->assertEquals('11.09.2017, 22:00 - 13.09.2017, 10:59', $entry->getFormattedTime('medium')); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/entry/CalendarEntryQueryTest.php b/tests/codeception/unit/entry/CalendarEntryQueryTest.php index 0998ec4c..d3f71869 100644 --- a/tests/codeception/unit/entry/CalendarEntryQueryTest.php +++ b/tests/codeception/unit/entry/CalendarEntryQueryTest.php @@ -14,7 +14,6 @@ class CalendarEntryQueryTest extends CalendarUnitTest { - /** * Test find dates by open range query. */ @@ -24,16 +23,16 @@ public function testSimpleOpenRange() $s1 = Space::findOne(['id' => 1]); // Past (not included in range) - $entry1 = $this->createEntry((new DateTime)->sub(new DateInterval('P5D')), 1, 'Past Entry', $s1); + $entry1 = $this->createEntry((new DateTime())->sub(new DateInterval('P5D')), 1, 'Past Entry', $s1); // From now till 5 days in future (included) $entry2 = $this->createEntry(null, 5, 'Entry 1', $s1); // From 3 days in future to 13 days in future (included) - $entry3 = $this->createEntry((new DateTime)->add(new DateInterval('P3D')), 10, 'Entry 2', $s1); + $entry3 = $this->createEntry((new DateTime())->add(new DateInterval('P3D')), 10, 'Entry 2', $s1); // Starts in 4 days (not included) - $entry4 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Future Entry', $s1); + $entry4 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Future Entry', $s1); $entries = CalendarEntryQuery::find()->days(3)->all(); - + $this->assertEquals(2, count($entries)); $this->assertEquals($entry2->title, $entries[0]->title); $this->assertEquals($entry3->title, $entries[1]->title); @@ -46,28 +45,28 @@ public function testOpenRangeBoundary() { $this->becomeUser('Admin'); $s1 = Space::findOne(['id' => 1]); - + // Whole day yesterday should be excluded - $entry1 = $this->createEntry((new DateTime)->sub(new DateInterval('P1D'))->setTime(0,0,0), 1, 'Yesterday', $s1); - + $entry1 = $this->createEntry((new DateTime())->sub(new DateInterval('P1D'))->setTime(0, 0, 0), 1, 'Yesterday', $s1); + // Today - $entry2 = $this->createEntry(new DateTime, 1, 'Today', $s1); - + $entry2 = $this->createEntry(new DateTime(), 1, 'Today', $s1); + // Tomorrow - $entry3 = $this->createEntry((new DateTime)->add(new DateInterval('P1D')), 1, 'Tomorrow', $s1); - + $entry3 = $this->createEntry((new DateTime())->add(new DateInterval('P1D')), 1, 'Tomorrow', $s1); + // Get all entries from today by open range query $entries = CalendarEntryQuery::find()->days(0)->all(); - + $this->assertEquals(1, count($entries)); $this->assertEquals($entry2->title, $entries[0]->title); - + $entries = CalendarEntryQuery::find()->days(1)->all(); $this->assertEquals(2, count($entries)); $this->assertEquals($entry2->title, $entries[0]->title); $this->assertEquals($entry3->title, $entries[1]->title); } - + /** * Test finding entries for spaces content container */ @@ -78,22 +77,22 @@ public function testSpaceContainerQuery() $s2 = Space::findOne(['id' => 2]); // Some entry way in the past (not included) - $this->createEntry((new DateTime)->sub(new DateInterval('P30D')), 1, 'Past Entry', $s1); + $this->createEntry((new DateTime())->sub(new DateInterval('P30D')), 1, 'Past Entry', $s1); // Past but included for s1 - $entry1 = $this->createEntry((new DateTime)->sub(new DateInterval('P5D')), 1, 'Past Entry', $s1); + $entry1 = $this->createEntry((new DateTime())->sub(new DateInterval('P5D')), 1, 'Past Entry', $s1); // From now till 5 days in future (included for s1) $entry2 = $this->createEntry(null, 5, 'Entry 1', $s1); // From 3 days in future to 13 days in future (included for s2) - $entry3 = $this->createEntry((new DateTime)->add(new DateInterval('P3D')), 10, 'Entry 1', $s2); + $entry3 = $this->createEntry((new DateTime())->add(new DateInterval('P3D')), 10, 'Entry 1', $s2); // Starts in 4 days (not included for s2) - $entry4 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Future Entry', $s2); + $entry4 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Future Entry', $s2); // Entry way in the future (not included) - $this->createEntry((new DateTime)->add(new DateInterval('P20D')), 6, 'Future Entry', $s2); + $this->createEntry((new DateTime())->add(new DateInterval('P20D')), 6, 'Future Entry', $s2); // Find all within -5 till 13 day range $entries = CalendarEntryQuery::find()->from(-5)->to(13)->all(); @@ -131,10 +130,10 @@ public function testGuestQuery() $s2 = Space::findOne(['id' => 2]); // Create three included queries - $entry1 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Future Entry', $s2); - $entry2 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Future Entry1', $s2); - $entry3 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Future Entry2', $s2, Content::VISIBILITY_PRIVATE); - $entry4 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Future Entry3', $s1); + $entry1 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Future Entry', $s2); + $entry2 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Future Entry1', $s2); + $entry3 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Future Entry2', $s2, Content::VISIBILITY_PRIVATE); + $entry4 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Future Entry3', $s1); $this->allowGuestAccess(); $this->logout(); @@ -163,7 +162,7 @@ public function testGuestQuery() $this->assertEquals($entry1->title, $entries[0]->title); $this->assertEquals($entry2->title, $entries[1]->title); } - + /** * Test finding entries for user content container */ @@ -172,49 +171,49 @@ public function testUserContainerQuery() $this->becomeUser('Admin'); $u1 = User::findOne(['id' => 1]); $u2 = User::findOne(['id' => 2]); - + // Some entry way in the past (not included) - $this->createEntry((new DateTime)->sub(new DateInterval('P30D')), 1, 'Past Entry', $u1); - + $this->createEntry((new DateTime())->sub(new DateInterval('P30D')), 1, 'Past Entry', $u1); + // Past but included for s1 - $entry1 = $this->createEntry((new DateTime)->sub(new DateInterval('P5D')), 1, 'Past Entry', $u1); - + $entry1 = $this->createEntry((new DateTime())->sub(new DateInterval('P5D')), 1, 'Past Entry', $u1); + // From now till 5 days in future (included for s1) $entry2 = $this->createEntry(null, 5, 'Entry 1', $u1); - + // From 3 days in future to 13 days in future (included for s2) - $entry3 = $this->createEntry((new DateTime)->add(new DateInterval('P3D')), 10, 'Entry 1', $u2); - + $entry3 = $this->createEntry((new DateTime())->add(new DateInterval('P3D')), 10, 'Entry 1', $u2); + // Starts in 4 days (not included for s2) - $entry4 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Future Entry', $u2); - + $entry4 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Future Entry', $u2); + // Entry way in the future (not included) - $this->createEntry((new DateTime)->add(new DateInterval('P20D')), 6, 'Future Entry', $u2); - + $this->createEntry((new DateTime())->add(new DateInterval('P20D')), 6, 'Future Entry', $u2); + // Find all within -5 till 13 day range $entries = CalendarEntryQuery::find()->from(-5)->to(13)->all(); - + $this->assertEquals(4, count($entries)); $this->assertEquals($entry1->title, $entries[0]->title); $this->assertEquals($entry2->title, $entries[1]->title); $this->assertEquals($entry3->title, $entries[2]->title); $this->assertEquals($entry4->title, $entries[3]->title); - + // Find all s1 entries within -5 till 13 day range $entries = CalendarEntryQuery::find()->container($u1)->from(-5)->to(13)->all(); - + $this->assertEquals(2, count($entries)); $this->assertEquals($entry1->title, $entries[0]->title); $this->assertEquals($entry2->title, $entries[1]->title); - + // Find all s1 entries within -5 till 13 day range $entries = CalendarEntryQuery::find()->container($u2)->from(-5)->to(13)->all(); - + $this->assertEquals(2, count($entries)); $this->assertEquals($entry3->title, $entries[0]->title); $this->assertEquals($entry4->title, $entries[1]->title); } - + public function testUserRelated() { $this->becomeUser('Admin'); @@ -222,46 +221,46 @@ public function testUserRelated() $s2 = Space::findOne(['id' => 2]); $u1 = User::findOne(['id' => 1]); $u2 = User::findOne(['id' => 2]); - + // User related (include) - $entry0 = $this->createEntry((new DateTime)->sub(new DateInterval('P30D')), 1, 'Past Entry From User', $u1); - + $entry0 = $this->createEntry((new DateTime())->sub(new DateInterval('P30D')), 1, 'Past Entry From User', $u1); + // User related (include) - $entry1 = $this->createEntry((new DateTime)->sub(new DateInterval('P5D')), 1, 'Past Entry From User2', $u1); - + $entry1 = $this->createEntry((new DateTime())->sub(new DateInterval('P5D')), 1, 'Past Entry From User2', $u1); + // Other user (do not include) $entry2 = $this->createEntry(null, 5, 'Entry from other user', $u2); - + // Member Space related (include) - $entry3 = $this->createEntry((new DateTime)->add(new DateInterval('P3D')), 10, 'Entry in member space', $s1); - + $entry3 = $this->createEntry((new DateTime())->add(new DateInterval('P3D')), 10, 'Entry in member space', $s1); + // Non member space (do not include) - $entry4 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Entry in non member space', $s2); - + $entry4 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Entry in non member space', $s2); + // By default select all user space and user profile related $entries = CalendarEntryQuery::find()->userRelated()->limit(20)->all(); $this->assertEquals(3, count($entries)); $this->assertEquals($entry0->title, $entries[0]->title); $this->assertEquals($entry1->title, $entries[1]->title); $this->assertEquals($entry3->title, $entries[2]->title); - + // All user space entries $entries = CalendarEntryQuery::find()->userRelated(ActiveQueryContent::USER_RELATED_SCOPE_SPACES)->limit(20)->all(); $this->assertEquals(1, count($entries)); $this->assertEquals($entry3->title, $entries[0]->title); - + // Add container user1 filter $entries = CalendarEntryQuery::find()->container($u1)->userRelated()->limit(20)->all(); $this->assertEquals(2, count($entries)); $this->assertEquals($entry0->title, $entries[0]->title); $this->assertEquals($entry1->title, $entries[1]->title); - + $s2->follow(null, false); - + $entries = CalendarEntryQuery::find()->userRelated([ActiveQueryContent::USER_RELATED_SCOPE_FOLLOWED_SPACES])->limit(20)->all(); $this->assertEquals(1, count($entries)); $this->assertEquals($entry4->title, $entries[0]->title); - + } /** @@ -272,40 +271,40 @@ public function testFilterParticipate() $this->becomeUser('Admin'); $s1 = Space::findOne(['id' => 1]); $s3 = Space::findOne(['id' => 3]); - + // User2 is member of both spaces $u2 = User::findOne(['id' => 3]); - - $entry0 = $this->createEntry((new DateTime)->sub(new DateInterval('P30D')), 1, 'Past Entry', $s1); - - $entry1 = $this->createEntry((new DateTime)->sub(new DateInterval('P5D')), 1, 'Past Entry', $s1); - + + $entry0 = $this->createEntry((new DateTime())->sub(new DateInterval('P30D')), 1, 'Past Entry', $s1); + + $entry1 = $this->createEntry((new DateTime())->sub(new DateInterval('P5D')), 1, 'Past Entry', $s1); + $entry2 = $this->createEntry(null, 5, 'Entry 1', $s1); - - $entry3 = $this->createEntry((new DateTime)->add(new DateInterval('P3D')), 10, 'Entry 1', $s3); - - $entry4 = $this->createEntry((new DateTime)->add(new DateInterval('P4D')), 6, 'Future Entry', $s1); - - $entry5 = $this->createEntry((new DateTime)->add(new DateInterval('P20D')), 6, 'Future Entry', $s3); - + + $entry3 = $this->createEntry((new DateTime())->add(new DateInterval('P3D')), 10, 'Entry 1', $s3); + + $entry4 = $this->createEntry((new DateTime())->add(new DateInterval('P4D')), 6, 'Future Entry', $s1); + + $entry5 = $this->createEntry((new DateTime())->add(new DateInterval('P20D')), 6, 'Future Entry', $s3); + // Create own date (automaticaly participant) $this->becomeUser('User2'); - $entry6 = $this->createEntry((new DateTime)->add(new DateInterval('P20D')), 6, 'Future Entry2', $s3); - + $entry6 = $this->createEntry((new DateTime())->add(new DateInterval('P20D')), 6, 'Future Entry2', $s3); + $entry1->setParticipationStatus($u2, CalendarEntryParticipant::PARTICIPATION_STATE_ACCEPTED); - + $entries = CalendarEntryQuery::find($u2)->participate()->limit(20)->all(); $this->assertEquals(1, count($entries)); $this->assertEquals($entry1->title, $entries[0]->title); } - + /** * Test find dates within a 1 day range (not open range). - * + * * E1: [Today - 5D] -> [Today - 4D] * E2: [Today] -> [Today + 1D] * E3: [Today + 1D] -> [Today - 7D] - * + * * T: [[Today] -> [Today + 1D]] --> Start and end date within interval */ public function testSimpleRange() @@ -313,9 +312,9 @@ public function testSimpleRange() $this->becomeUser('Admin'); $s1 = Space::findOne(['id' => 1]); - $entry1 = $this->createEntry((new DateTime)->sub(new DateInterval('P5D')), 1, 'Past Entry', $s1); + $entry1 = $this->createEntry((new DateTime())->sub(new DateInterval('P5D')), 1, 'Past Entry', $s1); $entry2 = $this->createEntry(null, 1, 'Entry 1', $s1); - $entry3 = $this->createEntry((new DateTime)->add(new DateInterval('P1D')), 6, 'Future Entry', $s1); + $entry3 = $this->createEntry((new DateTime())->add(new DateInterval('P1D')), 6, 'Future Entry', $s1); $entries = CalendarEntryQuery::find()->days(1)->openRange(false)->all(); $this->assertEquals(1, count($entries)); diff --git a/tests/codeception/unit/entry/CalendarFormTimezoneTest.php b/tests/codeception/unit/entry/CalendarFormTimezoneTest.php index a2ea3302..b5e962a1 100644 --- a/tests/codeception/unit/entry/CalendarFormTimezoneTest.php +++ b/tests/codeception/unit/entry/CalendarFormTimezoneTest.php @@ -1,9 +1,7 @@ UTC + 1 Yii::$app->user->getIdentity()->time_zone = 'Europe/London'; - $calendarForm = CalendarEntryForm::createEntry( Space::findOne(['id' => 1])); + $calendarForm = CalendarEntryForm::createEntry(Space::findOne(['id' => 1])); $this->assertTrue($calendarForm->load([ 'CalendarEntry' => [ 'all_day' => '0', 'title' => 'Test title', 'description' => 'TestDescription', - 'participation_mode' => 2 + 'participation_mode' => 2, ], 'CalendarEntryForm' => [ 'is_public' => '1', @@ -68,7 +66,7 @@ public function testTimeZone() 'end_time' => '01:00 PM', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($calendarForm->save()); @@ -91,7 +89,7 @@ public function testTimeZone() // Change timezone of event to Europe/Sofia -> UTC +3 $this->assertTrue($calendarForm->load([ 'CalendarEntry' => [ - 'all_day' => '0' + 'all_day' => '0', ], 'CalendarEntryForm' => [ 'is_public' => '1', @@ -102,7 +100,7 @@ public function testTimeZone() 'end_time' => '01:00 PM', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($calendarForm->save()); @@ -141,7 +139,7 @@ public function testAllDayTimeZone() 'all_day' => '1', 'title' => 'Test title', 'description' => 'TestDescription', - 'participation_mode' => 2 + 'participation_mode' => 2, ], 'CalendarEntryForm' => [ 'is_public' => '1', @@ -149,7 +147,7 @@ public function testAllDayTimeZone() 'end_date' => '6/27/17', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($calendarForm->save()); @@ -185,7 +183,7 @@ public function testCreateAllDayTimeZone() 'all_day' => '1', 'title' => 'Test title', 'description' => 'TestDescription', - 'participation_mode' => 2 + 'participation_mode' => 2, ], 'CalendarEntryForm' => [ 'is_public' => '1', @@ -193,7 +191,7 @@ public function testCreateAllDayTimeZone() 'end_date' => '8/16/17', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($calendarForm->save()); @@ -206,4 +204,4 @@ public function testCreateAllDayTimeZone() $this->assertEquals('2017-08-16', $calendarForm->end_date); $this->assertEquals('2017-08-17 00:00:00', $calendarForm->entry->end_datetime); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/entry/CalendarServiceTest.php b/tests/codeception/unit/entry/CalendarServiceTest.php index 1a07fb6c..e76ee8dc 100644 --- a/tests/codeception/unit/entry/CalendarServiceTest.php +++ b/tests/codeception/unit/entry/CalendarServiceTest.php @@ -52,7 +52,7 @@ public function testAllDayStartNotIncludedBoundary() $entryStart->modify('-1 day'); // Entry from '2019-12-29 00:00:00' - '2020-12-30 00:00:00' should not be included in search - $this->createEntry($entryStart , 1, 'e1', $s1); + $this->createEntry($entryStart, 1, 'e1', $s1); $entries = $this->service->getCalendarItems($searchDateStart, $searchDateEnd); $this->assertCount(0, $entries); } @@ -117,7 +117,7 @@ public function testAllDayStartNotIncludedBoundaryTZ() $entryStart->modify('-1 day'); // Entry from '2019-12-29 00:00:00' - '2020-12-30 00:00:00' should not be included in search - $this->createEntry($entryStart , 1, 'e1', $s1); + $this->createEntry($entryStart, 1, 'e1', $s1); $entries = $this->service->getCalendarItems($searchDateStart, $searchDateEnd); $this->assertCount(0, $entries); } @@ -156,9 +156,9 @@ public function testAllDayEndIncludedBoundaryTZ() /** * [] = Event {} = Search - * + * * [------{]------} - * + * * @throws \Exception */ public function testNonAllDayStartIncludedBoundary() @@ -172,7 +172,7 @@ public function testNonAllDayStartIncludedBoundary() // Entry from '2019-12-29T00:00:00' - '2019-12-29T00:00:00' should be included in search $entryStart = new DateTime('2019-12-28T12:00:00'); $entryEnd = new DateTime('2019-12-29T00:01:00'); - + $entry1 = $this->createEntry($entryStart, $entryEnd, 'e1', $s1); $entries = $this->service->getCalendarItems($searchDateStart, $searchDateEnd); $this->assertCount(1, $entries); diff --git a/tests/codeception/unit/entry/LegacyCalendarEntryTest.php b/tests/codeception/unit/entry/LegacyCalendarEntryTest.php index 03e922a8..da6a634d 100644 --- a/tests/codeception/unit/entry/LegacyCalendarEntryTest.php +++ b/tests/codeception/unit/entry/LegacyCalendarEntryTest.php @@ -17,7 +17,6 @@ class LegacyCalendarEntryTest extends CalendarUnitTest { - public function testLegacyAllDayEventWithTimezonetranslationSingleDaySpan() { Yii::$app->timeZone = 'Europe/Berlin'; @@ -37,7 +36,7 @@ public function testLegacyAllDayEventWithTimezonetranslationSingleDaySpan() 'start_datetime' => '2019-11-12 23:00:00', // Should be 2019-11-13 00:00:00 'end_datetime' => '2019-11-13 22:59:00', // Should be 2019-11-14 00:00:00 'time_zone' => 'Europe/Bucharest', - 'all_day' => 1 + 'all_day' => 1, ]); $entry = CalendarEntry::findOne(['id' => $calendarForm->entry->id]); @@ -67,7 +66,7 @@ public function testLegacyAllDayEventWithTimezonetranslationMultiDaySpan() 'start_datetime' => '2019-11-12 23:00:00', // Should be 2019-11-13 00:00:00 'end_datetime' => '2019-11-14 22:59:00', // Should be 2019-11-14 00:00:00 'time_zone' => 'Europe/Bucharest', - 'all_day' => 1 + 'all_day' => 1, ]); $entry = CalendarEntry::findOne(['id' => $calendarForm->entry->id]); @@ -96,7 +95,7 @@ public function testLegacyMomentBeforeEventSingleDaySpan() $calendarForm->entry->updateAttributes([ 'start_datetime' => '2019-11-12 00:00:00', // Should be 2019-11-13 00:00:00 'end_datetime' => '2019-11-12 23:59:00', // Should be 2019-11-14 00:00:00 - 'all_day' => 1 + 'all_day' => 1, ]); $entry = CalendarEntry::findOne(['id' => $calendarForm->entry->id]); @@ -125,7 +124,7 @@ public function testLegacyMomentBeforeEventMultiDaySpan() $calendarForm->entry->updateAttributes([ 'start_datetime' => '2019-11-12 00:00:00', // Should be 2019-11-13 00:00:00 'end_datetime' => '2019-11-13 23:59:00', // Should be 2019-11-14 00:00:00 - 'all_day' => 1 + 'all_day' => 1, ]); $entry = CalendarEntry::findOne(['id' => $calendarForm->entry->id]); diff --git a/tests/codeception/unit/entry/LocaleTest.php b/tests/codeception/unit/entry/LocaleTest.php index 82bf9416..f6d03568 100644 --- a/tests/codeception/unit/entry/LocaleTest.php +++ b/tests/codeception/unit/entry/LocaleTest.php @@ -1,9 +1,7 @@ $endTime, 'reminder' => 1, 'recurring' => 1, - ] + ], ]), "Error loading form with locale $locale"); $this->assertTrue($form->save(), "Error saving form with locale $locale"); $entry = CalendarEntry::findOne(['id' => $form->entry->id]); $this->assertEquals($start, $entry->getStartDateTime(), "Invalid start time with locale $locale"); - $expectedEnd = ($allDay) ? $end->modify('+1 day')->setTime(0,0,0) : $end; + $expectedEnd = ($allDay) ? $end->modify('+1 day')->setTime(0, 0, 0) : $end; $this->assertEquals($expectedEnd, $entry->getEndDateTime(), "Invalid end time with locale $locale"); } @@ -115,7 +113,7 @@ public function testSubmitFormForNewEventDateFormat() 'title' => 'Test title', 'all_day' => '0', 'description' => 'TestDescription', - 'participation_mode' => 2 + 'participation_mode' => 2, ], 'CalendarEntryForm' => [ 'is_public' => '1', @@ -125,7 +123,7 @@ public function testSubmitFormForNewEventDateFormat() 'end_time' => '3:00 PM', 'reminder' => 1, 'recurring' => 1, - ] + ], ])); $this->assertTrue($calendarForm->save()); @@ -136,4 +134,4 @@ public function testSubmitFormForNewEventDateFormat() $this->assertEquals('2019-11-11 00:00:00', $calendarForm->entry->start_datetime); $this->assertEquals('2019-11-11 15:00:00', $calendarForm->entry->end_datetime); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/helpers/CalendarUtilTest.php b/tests/codeception/unit/helpers/CalendarUtilTest.php index 36de8c6a..54a2abb8 100644 --- a/tests/codeception/unit/helpers/CalendarUtilTest.php +++ b/tests/codeception/unit/helpers/CalendarUtilTest.php @@ -152,4 +152,4 @@ public function testFullDayStrictNonMomentAfter() $end = new DateTime('2019-11-14 23:59:59'); $this->assertTrue(CalendarUtils::isAllDay($start, $end, false)); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/interface/ItemTypeInterfaceTest.php b/tests/codeception/unit/interface/ItemTypeInterfaceTest.php index 86e84fdd..539af44b 100644 --- a/tests/codeception/unit/interface/ItemTypeInterfaceTest.php +++ b/tests/codeception/unit/interface/ItemTypeInterfaceTest.php @@ -1,6 +1,5 @@ on(CalendarService::EVENT_GET_ITEM_TYPES, function(CalendarItemTypesEvent $event) { + $service->on(CalendarService::EVENT_GET_ITEM_TYPES, function (CalendarItemTypesEvent $event) { $event->addType(TestEventType::ITEM_TYPE, new TestEventType()); }); @@ -27,7 +26,7 @@ public function testExportCalendarItemType() public function testExportMultipleCalendarItemType() { $service = new CalendarService(); - $service->on(CalendarService::EVENT_GET_ITEM_TYPES, function(CalendarItemTypesEvent $event) { + $service->on(CalendarService::EVENT_GET_ITEM_TYPES, function (CalendarItemTypesEvent $event) { $event->addType(TestEventType::ITEM_TYPE, new TestEventType()); $event->addType(OtherTestEventType::ITEM_TYPE, new OtherTestEventType()); }); @@ -41,22 +40,22 @@ public function testExportMultipleCalendarItemType() public function testLegacyCalendarItemTypeInterface() { $service = new CalendarService(); - $service->on(CalendarService::EVENT_GET_ITEM_TYPES, function(CalendarItemTypesEvent $event) { + $service->on(CalendarService::EVENT_GET_ITEM_TYPES, function (CalendarItemTypesEvent $event) { $event->addType('arrayType', [ 'title' => 'Array Test Type', 'description' => 'Array Test Type Description', 'color' => '#111111', - 'icon' => 'fa-calendar-o' + 'icon' => 'fa-calendar-o', ]); }); $types = $service->getCalendarItemTypes(); $found = $this->assertContainsType($types, 'arrayType'); - $this->assertEquals('Array Test Type',$found->getTitle()); - $this->assertEquals('Array Test Type Description',$found->getDescription()); - $this->assertEquals('#111111',$found->getDefaultColor()); - $this->assertEquals('fa-calendar-o',$found->getIcon()); + $this->assertEquals('Array Test Type', $found->getTitle()); + $this->assertEquals('Array Test Type Description', $found->getDescription()); + $this->assertEquals('#111111', $found->getDefaultColor()); + $this->assertEquals('fa-calendar-o', $found->getIcon()); } public function testAddItemToContainer() @@ -65,7 +64,7 @@ public function testAddItemToContainer() $space2 = Space::findOne(['id' => 2]); $service = new CalendarService(); - $service->on(CalendarService::EVENT_GET_ITEM_TYPES, function(CalendarItemTypesEvent $event) { + $service->on(CalendarService::EVENT_GET_ITEM_TYPES, function (CalendarItemTypesEvent $event) { $container = $event->contentContainer; if(!$container || $container->id === 1) { @@ -93,17 +92,19 @@ public function testAddItemToContainer() * @param CalendarTypeIF|string $searchType * @return CalendarEntryType */ - private function assertContainsType($result, $searchType) { + private function assertContainsType($result, $searchType) + { $searchType = $searchType instanceof CalendarTypeIF ? $searchType->getKey() : $searchType; - $found = $this->findTypeInArray($result,$searchType); - $this->assertNotNull($found, 'Could not find type: '.$searchType); + $found = $this->findTypeInArray($result, $searchType); + $this->assertNotNull($found, 'Could not find type: ' . $searchType); return $found; } - private function assertNotContainsType($result, $searchType) { + private function assertNotContainsType($result, $searchType) + { $searchType = $searchType instanceof CalendarTypeIF ? $searchType->getKey() : $searchType; - $found = $this->findTypeInArray($result,$searchType); - $this->assertFalse($found, 'Should not find type: '.$searchType); + $found = $this->findTypeInArray($result, $searchType); + $this->assertFalse($found, 'Should not find type: ' . $searchType); return $found; } @@ -112,7 +113,8 @@ private function assertNotContainsType($result, $searchType) { * @param CalendarTypeIF|string $searchType * @return false|CalendarEntryType */ - private function findTypeInArray($result, $searchType) { + private function findTypeInArray($result, $searchType) + { $found = false; foreach ($result as $type) { if($type->getKey() === $searchType) { @@ -122,4 +124,4 @@ private function findTypeInArray($result, $searchType) { return $found; } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/models/OtherTestEventType.php b/tests/codeception/unit/models/OtherTestEventType.php index fe4d2ba1..ad1f8fd8 100644 --- a/tests/codeception/unit/models/OtherTestEventType.php +++ b/tests/codeception/unit/models/OtherTestEventType.php @@ -1,14 +1,12 @@ becomeUser('admin'); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', Space::findOne(['id' => 1])); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', Space::findOne(['id' => 1])); $this->assertNotEmpty($entry->participation); $this->assertEquals(CalendarEntryParticipation::PARTICIPATION_MODE_ALL, $entry->participation_mode); } @@ -21,8 +21,8 @@ public function testDefault() public function testGetGuestParticipation() { $this->becomeUser('admin'); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', Space::findOne(['id' => 1])); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', Space::findOne(['id' => 1])); $participationOfGuest = $entry->getParticipationStatus(null); $this->assertEquals($participationOfGuest, CalendarEntryParticipation::PARTICIPATION_STATUS_NONE); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/recurrence/RecurrenceEditTest.php b/tests/codeception/unit/recurrence/RecurrenceEditTest.php index 9ccdd78c..06b49b6e 100644 --- a/tests/codeception/unit/recurrence/RecurrenceEditTest.php +++ b/tests/codeception/unit/recurrence/RecurrenceEditTest.php @@ -110,7 +110,7 @@ public function testEditThisEventOnNonRoot() 'title' => 'Overwritten title', 'all_day' => '0', 'description' => 'Overwritten description', - 'participation_mode' => CalendarEntryParticipation::PARTICIPATION_MODE_NONE + 'participation_mode' => CalendarEntryParticipation::PARTICIPATION_MODE_NONE, ], 'CalendarEntryForm' => [ 'is_public' => '1', @@ -122,8 +122,8 @@ public function testEditThisEventOnNonRoot() 'recurring' => 1, ], 'RecurrenceFormModel' => [ - 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_THIS - ] + 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_THIS, + ], ])); $this->assertTrue($form->save()); @@ -168,7 +168,7 @@ public function testEditThisEventOnRoot() 'title' => 'Overwritten title', 'all_day' => '0', 'description' => 'Overwritten description', - 'participation_mode' => CalendarEntryParticipation::PARTICIPATION_MODE_NONE + 'participation_mode' => CalendarEntryParticipation::PARTICIPATION_MODE_NONE, ], 'CalendarEntryForm' => [ 'is_public' => '1', @@ -180,8 +180,8 @@ public function testEditThisEventOnRoot() 'recurring' => 1, ], 'RecurrenceFormModel' => [ - 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_THIS - ] + 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_THIS, + ], ])); $this->assertTrue($form->save()); @@ -225,8 +225,8 @@ public function testEditFollowingEventsOnNonRootChangeRecurrence() 'recurring' => 1, ], 'RecurrenceFormModel' => [ - 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_FOLLOWING - ] + 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_FOLLOWING, + ], ])); $this->assertTrue($form->save()); @@ -259,8 +259,8 @@ public function testEditFollowingEventsOnRootChangeRecurrence() 'recurring' => 1, ], 'RecurrenceFormModel' => [ - 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_FOLLOWING - ] + 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_FOLLOWING, + ], ])); $this->assertTrue($form->save()); @@ -285,7 +285,7 @@ public function testEditAllEvents() 'CalendarEntry' => [ 'title' => 'Overwritten title', 'description' => 'Overwritten description', - 'participation_mode' => CalendarEntryParticipation::PARTICIPATION_MODE_NONE + 'participation_mode' => CalendarEntryParticipation::PARTICIPATION_MODE_NONE, ], 'CalendarEntryForm' => [ 'is_public' => '0', @@ -298,8 +298,8 @@ public function testEditAllEvents() 'RecurrenceFormModel' => [ 'recurrenceEditMode' => RecurrenceFormModel::EDIT_MODE_ALL, 'frequency' => Frequency::DAILY, - 'interval' => 2 - ] + 'interval' => 2, + ], ])); $this->assertTrue($form->save()); diff --git a/tests/codeception/unit/recurrence/RecurrenceFormTest.php b/tests/codeception/unit/recurrence/RecurrenceFormTest.php index 02c547f4..8da47401 100644 --- a/tests/codeception/unit/recurrence/RecurrenceFormTest.php +++ b/tests/codeception/unit/recurrence/RecurrenceFormTest.php @@ -67,9 +67,9 @@ public function testLoadWeeklyRule() { $this->initForm(); $this->form->load([ - 'interval' => 2, - 'frequency' => Frequency::WEEKLY, - 'weekDays' => [CalendarUtils::DOW_SUNDAY, CalendarUtils::DOW_MONDAY] + 'interval' => 2, + 'frequency' => Frequency::WEEKLY, + 'weekDays' => [CalendarUtils::DOW_SUNDAY, CalendarUtils::DOW_MONDAY], ], ''); @@ -79,7 +79,7 @@ public function testLoadWeeklyRule() public function testEditWeeklyRule() { - $this->initForm( 'FREQ=WEEKLY;INTERVAL=2;BYDAY=SU,MO'); + $this->initForm('FREQ=WEEKLY;INTERVAL=2;BYDAY=SU,MO'); $this->assertEquals(2, $this->form->interval); $this->assertEquals(Frequency::WEEKLY, $this->form->frequency); $this->assertCount(2, $this->form->weekDays); @@ -94,7 +94,7 @@ public function testLoadMonthlyRuleByDayOfMonth() $this->form->load([ 'interval' => 2, 'frequency' => Frequency::MONTHLY, - 'monthDaySelection' => RecurrenceFormModel::MONTHLY_BY_DAY_OF_MONTH + 'monthDaySelection' => RecurrenceFormModel::MONTHLY_BY_DAY_OF_MONTH, ], ''); $this->assertTrue($this->form->save()); @@ -117,7 +117,7 @@ public function testLoadMonthlyRuleByOccurrence() 'interval' => 2, 'frequency' => Frequency::MONTHLY, 'monthDaySelection' => RecurrenceFormModel::MONTHLY_BY_OCCURRENCE, - 'weekDays' => [CalendarUtils::DOW_SUNDAY, CalendarUtils::DOW_MONDAY] // SHOULD BE IGNORED + 'weekDays' => [CalendarUtils::DOW_SUNDAY, CalendarUtils::DOW_MONDAY], // SHOULD BE IGNORED ], ''); $this->assertTrue($this->form->save()); @@ -141,7 +141,7 @@ public function testLoadRuleWithEndByDate() 'frequency' => Frequency::MONTHLY, 'monthDaySelection' => RecurrenceFormModel::MONTHLY_BY_OCCURRENCE, 'end' => RecurrenceFormModel::ENDS_ON_DATE, - 'endDate' => '12/11/22' + 'endDate' => '12/11/22', ], ''); $this->assertTrue($this->form->save()); @@ -167,7 +167,7 @@ public function testLoadRuleWithEndByOccurrence() 'frequency' => Frequency::MONTHLY, 'monthDaySelection' => RecurrenceFormModel::MONTHLY_BY_OCCURRENCE, 'end' => RecurrenceFormModel::ENDS_AFTER_OCCURRENCES, - 'endOccurrences' => 20 + 'endOccurrences' => 20, ], ''); $this->assertTrue($this->form->save()); @@ -207,7 +207,7 @@ public function testLoadMonthlyRuleLastWeekDayOfMonthEndAfterOccurrence() 'frequency' => Frequency::MONTHLY, 'monthDaySelection' => RecurrenceFormModel::MONTHLY_LAST_DAY_OF_MONTH, 'end' => RecurrenceFormModel::ENDS_AFTER_OCCURRENCES, - 'endOccurrences' => 2 + 'endOccurrences' => 2, ], ''); $this->assertTrue($this->form->save()); @@ -236,4 +236,4 @@ public function testEditRuleWithMonthlyRuleLastWeekDayOfMonthEndAfterOccurrence( $this->assertTrue($this->form->validate()); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/recurrence/RecurrenceQueryTest.php b/tests/codeception/unit/recurrence/RecurrenceQueryTest.php index 1bb483a1..d77c053c 100644 --- a/tests/codeception/unit/recurrence/RecurrenceQueryTest.php +++ b/tests/codeception/unit/recurrence/RecurrenceQueryTest.php @@ -13,7 +13,7 @@ public function testExpandMultipleDays() $this->becomeUser('Admin'); $this->space = Space::findOne(['id' => 1]); - $from = $this->getEntryDate()->setTime(0,0,0); + $from = $this->getEntryDate()->setTime(0, 0, 0); $this->rootEvent = $this->createEntry($from, 2, 'Two Day Event', $this->space); $this->setDefaults($this->rootEvent, 'FREQ=DAILY;INTERVAL=2'); @@ -36,7 +36,7 @@ public function testExpandUpcomingEventOnRootNonExpanded() $instances = $this->rootEvent->getRecurrenceQuery()->expandUpcoming(2, true); $this->assertCount(2, $instances); - $today = (new DateTime())->setTime(0,0,0); + $today = (new DateTime())->setTime(0, 0, 0); $this->assertEquals($today, $instances[0]->getStartDateTime()); $next = $today->modify('+2 day'); @@ -48,7 +48,7 @@ public function testExpandUpcomingEventOnRootExpanded() // Create a recurrent event starting today repeating every two days, but don't expand yet $this->initRecurrentEvents('FREQ=DAILY;INTERVAL=2', new DateTime(), false); - $today = (new DateTime())->setTime(0,0,0); + $today = (new DateTime())->setTime(0, 0, 0); $expandEnd = clone $today; $expandEnd->modify('+3 day'); @@ -72,7 +72,7 @@ public function testExpandUpcomingWithFrom() // Create a recurrent event starting today repeating every two days, but don't expand yet $this->initRecurrentEvents('FREQ=DAILY;INTERVAL=2', new DateTime(), false); - $first = (new DateTime())->setTime(0,0,0); + $first = (new DateTime())->setTime(0, 0, 0); $second = clone $first; $second->modify('+2 day'); $third = clone $first; @@ -109,4 +109,4 @@ public function testExpandUpcomingWithFrom() $this->assertEquals($third, $upcoming[2]->getStartDateTime()); $this->assertEquals($fourth, $upcoming[3]->getStartDateTime()); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/recurrence/RecurrenceServiceTest.php b/tests/codeception/unit/recurrence/RecurrenceServiceTest.php index 28a268da..899555f3 100644 --- a/tests/codeception/unit/recurrence/RecurrenceServiceTest.php +++ b/tests/codeception/unit/recurrence/RecurrenceServiceTest.php @@ -15,7 +15,6 @@ class RecurrenceServiceTest extends RecurrenceUnitTest { - /** * @var CalendarService */ @@ -36,7 +35,7 @@ public function testGetUpcommingEntries() $this->becomeUser('Admin'); $this->space = Space::findOne(['id' => 1]); - $today = (new DateTime())->setTime(0,0,0); + $today = (new DateTime())->setTime(0, 0, 0); $this->rootEvent = $this->createEntry($today, 1, 'Recurrent Event', $this->space); $this->setDefaults($this->rootEvent, 'FREQ=DAILY;INTERVAL=1'); @@ -62,7 +61,7 @@ public function testGetAndSaveUpcommingEntries() $this->becomeUser('Admin'); $this->space = Space::findOne(['id' => 1]); - $today = (new DateTime())->setTime(0,0,0); + $today = (new DateTime())->setTime(0, 0, 0); $this->rootEvent = $this->createEntry($today, 1, 'Recurrent Event', $this->space); $this->setDefaults($this->rootEvent, 'FREQ=DAILY;INTERVAL=1'); @@ -115,7 +114,7 @@ public function testGetEntriesFilteredByAttending() $admin = $this->becomeUser('Admin'); $this->space = Space::findOne(['id' => 1]); - $today = (new DateTime())->setTime(0,0,0); + $today = (new DateTime())->setTime(0, 0, 0); $this->rootEvent = $this->createEntry($today, 1, 'Recurrent Event', $this->space); $this->setDefaults($this->rootEvent, 'FREQ=DAILY;INTERVAL=1'); @@ -151,4 +150,4 @@ public function testGetEntriesFilteredByAttending() $this->assertEquals(CalendarUtils::toDBDateFormat((clone $today)->modify('+1 day')), $filteredRecurrences[0]->start_datetime); $this->assertEquals(CalendarUtils::toDBDateFormat((clone $today)->modify('+3 day')), $filteredRecurrences[1]->start_datetime); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/reminder/ReminderProcessTest.php b/tests/codeception/unit/reminder/ReminderProcessTest.php index 69b91bae..3b44c680 100644 --- a/tests/codeception/unit/reminder/ReminderProcessTest.php +++ b/tests/codeception/unit/reminder/ReminderProcessTest.php @@ -18,7 +18,7 @@ use humhub\modules\user\models\User; use Yii; -class ReminderProcessTest extends CalendarUnitTest +class ReminderProcessTest extends CalendarUnitTest { protected function setUp(): void { @@ -35,7 +35,7 @@ public function testDisableReminderSpaceLevel() $user = User::findOne(['id' => 1]); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Set a global reminder $globalReminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 1); @@ -61,7 +61,7 @@ public function testDisableEntryLevelReminderLevel() $user = User::findOne(['id' => 1]); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Set a global reminder $globalReminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 1); @@ -91,7 +91,7 @@ public function testDisableUserEntryLevelReminderLevel() $user = User::findOne(['id' => 1]); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $entry->updateAttributes(['participation_mode' => CalendarEntryParticipation::PARTICIPATION_MODE_NONE]); // Set a global reminder @@ -142,7 +142,7 @@ public function testMultipleMatchingUserEntryReminder() $user = User::findOne(['id' => 1]); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $reminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry, $user); $this->assertTrue($reminder->save()); @@ -177,7 +177,7 @@ public function testMultipleMatchingEntryReminder() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $reminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry); $this->assertTrue($reminder->save()); @@ -220,7 +220,7 @@ public function testMultipleMatchingDefaultReminder() $this->assertTrue($reminder2->save()); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); (new ReminderService())->sendAllReminder(); @@ -257,19 +257,19 @@ public function testOverwriteContainerDefaultByContainerWideEntryLevel() $space = Space::findOne(['id' => 3]); $this->becomeUser('admin'); - $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1 ); + $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1); $this->assertTrue($reminder->save()); - $spaceReminder = CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR,1, $space); + $spaceReminder = CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 1, $space); $this->assertTrue($spaceReminder->save()); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Entry2 begins exactly in one hour - $entry2 = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test2', $space); + $entry2 = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test2', $space); - $entryLevelContainerWideReminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR,1, $entry2); + $entryLevelContainerWideReminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry2); $this->assertTrue($entryLevelContainerWideReminder->save()); (new ReminderService())->sendAllReminder(); @@ -310,22 +310,22 @@ public function testOverwriteContainerLevelByUserLevelEntry() { $space = Space::findOne(['id' => 3]); $this->becomeUser('admin'); - $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1 ); + $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1); $this->assertTrue($reminder->save()); - $spaceReminder = CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR,1, $space); + $spaceReminder = CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 1, $space); $this->assertTrue($spaceReminder->save()); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Entry2 begins exactly in one hour - $entry2 = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test2', $space); + $entry2 = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test2', $space); - $entryLevelContainerWideReminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR,1, $entry2); + $entryLevelContainerWideReminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry2); $this->assertTrue($entryLevelContainerWideReminder->save()); - $userEntryLevelContainerWideReminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR,1, $entry2, User::findOne(['id' => 1])); + $userEntryLevelContainerWideReminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry2, User::findOne(['id' => 1])); $this->assertTrue($userEntryLevelContainerWideReminder->save()); (new ReminderService())->sendAllReminder(); @@ -377,18 +377,18 @@ public function testOverwriteGlobalDefaultByContainer() { $space = Space::findOne(['id' => 3]); $this->becomeUser('admin'); - $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1 ); + $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1); $this->assertTrue($reminder->save()); - $spaceReminder = CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR,1, $space); + $spaceReminder = CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 1, $space); $this->assertTrue($spaceReminder->save()); // Entry begins exactly in one day - $entry = $this->createEntry((new DateTime)->add(new DateInterval('P1D')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('P1D')), null, 'Test', $space); // Entry2 begins exactly in one hour - $entry2 = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test2', $space); + $entry2 = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test2', $space); (new ReminderService())->sendAllReminder(); @@ -423,23 +423,23 @@ public function testSingleGlobalReminderNotSent() $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1); $this->assertTrue($reminder->save()); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('P2D')), null, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('P2D')), null, 'Test', Space::findOne(['id' => 3])); // Check Only sent to not declined user (new ReminderService())->sendAllReminder(); $this->assertFalse(CalendarReminderSent::check($reminder, $entry)); - $this->assertSentEmail( 0); + $this->assertSentEmail(0); } public function testSentReminderToNonSpaceMemberParticipant() { $this->becomeUser('admin'); - $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1 ); + $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1); $this->assertTrue($reminder->save()); - $entry = $this->createEntry((new DateTime)->modify('+23 hours'), null, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->modify('+23 hours'), null, 'Test', Space::findOne(['id' => 3])); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->saveEvent(); @@ -488,7 +488,7 @@ public function testSingleGlobalReminderOnSpaceParticipationAll() $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1); $this->assertTrue($reminder->save()); - $entry = $this->createEntry((new DateTime)->modify('+23 hours'), null, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->modify('+23 hours'), null, 'Test', Space::findOne(['id' => 3])); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->saveEvent(); @@ -525,9 +525,9 @@ public function testSingleGlobalReminderOnSpaceParticipationAllDeclined() { $this->becomeUser('admin'); - $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1 ); + $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1); $this->assertTrue($reminder->save()); - $entry = $this->createEntry((new DateTime)->modify('+23 hours'), null, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->modify('+23 hours'), null, 'Test', Space::findOne(['id' => 3])); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->saveEvent(); @@ -562,9 +562,9 @@ public function testSingleGlobalReminderOnSpaceParticipationAllDeclined() public function testSingleGlobalReminderOnSpaceParticipationNone() { $this->becomeUser('admin'); - $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1 ); + $reminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 1); $this->assertTrue($reminder->save()); - $entry = $this->createEntry((new DateTime)->modify('+23 hours'), null, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->modify('+23 hours'), null, 'Test', Space::findOne(['id' => 3])); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_NONE; $entry->saveEvent(); @@ -588,7 +588,7 @@ public function testRemindRecurrentInstance() $this->assertTrue($reminder->save()); // create recurrent event today tomorrow recurring every day - $entry = $this->createEntry(new DateTime(), 1, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry(new DateTime(), 1, 'Test', Space::findOne(['id' => 3])); $entry->rrule = 'FREQ=DAILY;INTERVAL=1'; $entry->saveEvent(); @@ -624,7 +624,7 @@ public function testSimpleGlobalDefaultReminder() $this->becomeUser('Admin'); $globalReminder = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_DAY, 2); $this->assertTrue($globalReminder->save()); - $entry = $this->createEntry((new DateTime())->modify('+1 day'), 1, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->modify('+1 day'), 1, 'Test', Space::findOne(['id' => 3])); (new ReminderService())->sendAllReminder(); $this->assertTrue(CalendarReminderSent::check($globalReminder, $entry)); } @@ -634,7 +634,7 @@ public function testSimpleSpaceDefaultReminder() $this->becomeUser('Admin'); $default = CalendarReminder::initContainerDefault(CalendarReminder::UNIT_DAY, 2, Space::findOne(['id' => 3])); $this->assertTrue($default->save()); - $entry = $this->createEntry((new DateTime())->modify('+1 day'), 1, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->modify('+1 day'), 1, 'Test', Space::findOne(['id' => 3])); (new ReminderService())->sendAllReminder(); $this->assertTrue(CalendarReminderSent::check($default, $entry)); } @@ -642,7 +642,7 @@ public function testSimpleSpaceDefaultReminder() public function testSimpleEntryLevelContainerReminder() { $this->becomeUser('Admin'); - $entry = $this->createEntry((new DateTime())->modify('+1 day'), 1, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->modify('+1 day'), 1, 'Test', Space::findOne(['id' => 3])); $reminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_DAY, 2, $entry); $this->assertTrue($reminder->save()); (new ReminderService())->sendAllReminder(); @@ -652,7 +652,7 @@ public function testSimpleEntryLevelContainerReminder() public function testSimpleEntryLevelUserReminder() { $this->becomeUser('Admin'); - $entry = $this->createEntry((new DateTime())->modify('+1 day'), 1, 'Test', Space::findOne(['id' => 3])); + $entry = $this->createEntry((new DateTime())->modify('+1 day'), 1, 'Test', Space::findOne(['id' => 3])); $reminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_DAY, 2, $entry, Yii::$app->user->identity); $this->assertTrue($reminder->save()); (new ReminderService())->sendAllReminder(); diff --git a/tests/codeception/unit/reminder/ReminderSettingsTest.php b/tests/codeception/unit/reminder/ReminderSettingsTest.php index 1e252ce7..92a87c43 100644 --- a/tests/codeception/unit/reminder/ReminderSettingsTest.php +++ b/tests/codeception/unit/reminder/ReminderSettingsTest.php @@ -23,12 +23,12 @@ public function testDisableContainerReminder() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], - ] + ], ])); $this->assertTrue($form->save()); @@ -36,11 +36,11 @@ public function testDisableContainerReminder() $form = new ReminderSettings(['container' => $space]); $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ - ['unit' => CalendarReminder::UNIT_HOUR, 'value' => null] - ] + ['unit' => CalendarReminder::UNIT_HOUR, 'value' => null], + ], ])); $this->assertTrue($form->save()); @@ -48,7 +48,7 @@ public function testDisableContainerReminder() $this->assertCount(2, $form->reminders); $this->assertEquals(1, $form->reminders[0]->disabled); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Load entry form $form = new ReminderSettings(['entry' => $entry]); @@ -71,26 +71,26 @@ public function testDisableEntryReminder() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], - ] + ], ])); $this->assertTrue($form->save()); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $form = new ReminderSettings(['entry' => $entry]); $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ - ['unit' => CalendarReminder::UNIT_HOUR, 'value' => null] - ] + ['unit' => CalendarReminder::UNIT_HOUR, 'value' => null], + ], ])); $this->assertTrue($form->save()); @@ -115,26 +115,26 @@ public function testDisableUserEntryReminder() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], - ] + ], ])); $this->assertTrue($form->save()); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $form = new ReminderSettings(['entry' => $entry, 'user' => User::findOne(['id' => 1])]); $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ - ['unit' => CalendarReminder::UNIT_HOUR, 'value' => null] - ] + ['unit' => CalendarReminder::UNIT_HOUR, 'value' => null], + ], ])); $this->assertTrue($form->save()); @@ -158,12 +158,12 @@ public function testSaveGlobal() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], - ] + ], ])); $this->assertTrue($form->save()); @@ -176,7 +176,7 @@ public function testSaveGlobal() $form = new ReminderSettings(['container' => $space]); $this->assertCount(3, $form->reminders); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Load entry form $form = new ReminderSettings(['entry' => $entry]); @@ -197,12 +197,12 @@ public function testSaveContainer() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], - ] + ], ])); $this->assertTrue($form->save()); @@ -215,13 +215,13 @@ public function testSaveContainer() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 3], - ] + ], ])); $this->assertTrue($form->save()); @@ -230,7 +230,7 @@ public function testSaveContainer() $form = new ReminderSettings(['container' => $space]); $this->assertCount(4, $form->reminders); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Load entry form $form = new ReminderSettings(['entry' => $entry]); @@ -253,12 +253,12 @@ public function testSaveEntryLevel() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], - ] + ], ])); $this->assertTrue($form->save()); @@ -271,18 +271,18 @@ public function testSaveEntryLevel() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 3], - ] + ], ])); $this->assertTrue($form->save()); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Load entry form $form = new ReminderSettings(['entry' => $entry]); @@ -290,14 +290,14 @@ public function testSaveEntryLevel() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 3], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 4], - ] + ], ])); $this->assertTrue($form->save()); @@ -323,12 +323,12 @@ public function testSaveUserEntryLevel() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], - ] + ], ])); $this->assertTrue($form->save()); @@ -341,18 +341,18 @@ public function testSaveUserEntryLevel() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 3], - ] + ], ])); $this->assertTrue($form->save()); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); // Load entry form @@ -361,14 +361,14 @@ public function testSaveUserEntryLevel() // Save global $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 2], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 3], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 4], - ] + ], ])); $this->assertTrue($form->save()); @@ -378,7 +378,7 @@ public function testSaveUserEntryLevel() $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM + 'reminderType' => ReminderSettings::REMINDER_TYPE_CUSTOM, ], 'CalendarReminder' => [ ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], @@ -386,7 +386,7 @@ public function testSaveUserEntryLevel() ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 3], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 4], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 5], - ] + ], ])); $this->assertTrue($form->save()); @@ -473,7 +473,7 @@ public function testFlagsEntryLevelWithoutDefaults() $this->becomeUser('admin'); $space = Space::findOne(['id' => 3]); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry)->save(); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 2, $entry)->save(); @@ -496,7 +496,7 @@ public function testFlagsEntryLevelWithGlobalDefaults() CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 1)->save(); CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 2)->save(); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry)->save(); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 2, $entry)->save(); @@ -519,7 +519,7 @@ public function testFlagsEntryLevelWithContainerDefaults() CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 1, $space)->save(); CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 2, $space)->save(); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry)->save(); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 2, $entry)->save(); @@ -542,7 +542,7 @@ public function testFlagsEntryLevelWithContainerDefaultsLoaded() CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 1, $space)->save(); CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 2, $space)->save(); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $form = new ReminderSettings(['entry' => $entry]); $this->assertEquals(ReminderSettings::REMINDER_TYPE_DEFAULT, $form->reminderType); @@ -563,7 +563,7 @@ public function testFlagsEntryLevelWithGlobalDefaultsLoaded() CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 1)->save(); CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 2)->save(); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $form = new ReminderSettings(['entry' => $entry]); $this->assertEquals(ReminderSettings::REMINDER_TYPE_DEFAULT, $form->reminderType); @@ -581,7 +581,7 @@ public function testFlagsUserEntryLevelWithoutDefaults() $space = Space::findOne(['id' => 3]); $user = User::findOne(['id' => 1]); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $form = new ReminderSettings(['entry' => $entry, 'user' => $user]); $this->assertEquals(ReminderSettings::REMINDER_TYPE_NONE, $form->reminderType); @@ -602,7 +602,7 @@ public function testFlagsUserEntryLevelWithGlobalDefaults() CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 1)->save(); CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 2)->save(); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry, $user)->save(); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 2, $entry, $user)->save(); @@ -626,7 +626,7 @@ public function testFlagsUserEntryLevelWithContainerDefaults() CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 1, $space)->save(); CalendarReminder::initContainerDefault(CalendarReminder::UNIT_HOUR, 2, $space)->save(); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry, $user)->save(); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 2, $entry, $user)->save(); @@ -647,7 +647,7 @@ public function testFlagsUserEntryLevelWithEntryDefaults() $space = Space::findOne(['id' => 3]); $user = User::findOne(['id' => 1]); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry)->save(); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 2, $entry)->save(); @@ -671,7 +671,7 @@ public function testFlagsUserEntryLevelWithEntryDefaultsLoaded() $space = Space::findOne(['id' => 3]); $user = User::findOne(['id' => 1]); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry)->save(); CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 2, $entry)->save(); @@ -699,7 +699,7 @@ public function testUseDefaultsContainer() $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_DEFAULT + 'reminderType' => ReminderSettings::REMINDER_TYPE_DEFAULT, ], 'CalendarReminder' => [ // Will be irgnored ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], @@ -707,7 +707,7 @@ public function testUseDefaultsContainer() ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 3], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 4], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 5], - ] + ], ])); $this->assertTrue($form->save()); @@ -737,7 +737,7 @@ public function testUseDefaultsContainerWithReset() $this->assertTrue($form->load([ 'ReminderSettings' => [ - 'reminderType' => ReminderSettings::REMINDER_TYPE_DEFAULT + 'reminderType' => ReminderSettings::REMINDER_TYPE_DEFAULT, ], 'CalendarReminder' => [ // Will be irgnored ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 1], @@ -745,7 +745,7 @@ public function testUseDefaultsContainerWithReset() ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 3], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 4], ['unit' => CalendarReminder::UNIT_HOUR, 'value' => 5], - ] + ], ])); $this->assertTrue($form->save()); @@ -756,4 +756,4 @@ public function testUseDefaultsContainerWithReset() $this->assertTrue($form->isDefaultsLoaded()); $this->assertCount(3, $form->reminders); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/reminder/ReminderTest.php b/tests/codeception/unit/reminder/ReminderTest.php index 57e1890e..cb6c0482 100644 --- a/tests/codeception/unit/reminder/ReminderTest.php +++ b/tests/codeception/unit/reminder/ReminderTest.php @@ -21,7 +21,7 @@ public function testDeleteReminder() { $this->becomeUser('admin'); $space = Space::findOne(['id' => 1]); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), new DateInterval('PT1H'), 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), new DateInterval('PT1H'), 'Test', $space); $reminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_DAY, 1, $entry); $reminder->save(); $reminder->acknowledge($entry); @@ -41,17 +41,17 @@ public function testSimpleEntryLevelCheck() $this->becomeUser('admin'); // Event starts in one hour and reminder is set to one hour -> should pass - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), new DateInterval('PT1H'), 'Test'); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), new DateInterval('PT1H'), 'Test'); $reminder = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 1, $entry); $reminder->save(); $this->assertTrue($reminder->checkMaturity($entry)); // Event starts in two hour and reminder is set to one hour -> should not pass - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT2H')), new DateInterval('PT1H'), 'Test'); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT2H')), new DateInterval('PT1H'), 'Test'); $reminder->save(); // Event starts in one day and reminder is set to one hour -> should not pass - $entry = $this->createEntry((new DateTime)->add(new DateInterval('P1D')), new DateInterval('PT1H'), 'Test'); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('P1D')), new DateInterval('PT1H'), 'Test'); $this->assertFalse($reminder->checkMaturity($entry)); } @@ -87,7 +87,7 @@ public function testEntryLevelQueryOrder() $space = Space::findOne(['id' => 1]); $user = User::findOne(['id' => 2]); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), new DateInterval('PT1H'), 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), new DateInterval('PT1H'), 'Test', $space); $reminder1 = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_DAY, 2, $entry, $user); $reminder2 = CalendarReminder::initEntryLevel(CalendarReminder::UNIT_HOUR, 2, $entry); @@ -123,7 +123,7 @@ public function testGetEntryLevelReminder() { $this->becomeUser('admin'); $space = Space::findOne(['id' => 1]); - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), new DateInterval('PT1H'), 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), new DateInterval('PT1H'), 'Test', $space); // Create Global Default Reminder $reminder1 = CalendarReminder::initGlobalDefault(CalendarReminder::UNIT_HOUR, 1); @@ -180,4 +180,4 @@ public function testDaysInFuture2() $this->assertEquals(28, CalendarReminder::getMaxReminderDaysInFuture()); } -} \ No newline at end of file +} diff --git a/tests/codeception/unit/reminder/ReminderUserQueryTest.php b/tests/codeception/unit/reminder/ReminderUserQueryTest.php index feb5537c..308c8741 100644 --- a/tests/codeception/unit/reminder/ReminderUserQueryTest.php +++ b/tests/codeception/unit/reminder/ReminderUserQueryTest.php @@ -9,9 +9,8 @@ use DateInterval; use DateTime; -class ReminderUserQueryTest extends CalendarUnitTest +class ReminderUserQueryTest extends CalendarUnitTest { - /** * SPACE */ @@ -22,7 +21,7 @@ public function testSpaceEntryWithoutParticipationRemindAllMembers() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_NONE; $result = $entry->getReminderUserQuery()->all(); static::assertCount(3, $result); @@ -37,7 +36,7 @@ public function testSpaceEntryWithParticipationRemindNoneIfNoParticipants() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $result = $entry->getReminderUserQuery()->all(); static::assertCount(0, $result); @@ -49,7 +48,7 @@ public function testSpaceEntryWithParticipationRemindAcceptedParticipant() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->participation->setParticipationStatus(User::findOne(['id' => 2]), CalendarEntryParticipation::PARTICIPATION_STATUS_ACCEPTED); $result = $entry->getReminderUserQuery()->all(); @@ -63,7 +62,7 @@ public function testSpaceEntryWithParticipationRemindMaybeParticipant() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->participation->setParticipationStatus(User::findOne(['id' => 2]), CalendarEntryParticipation::PARTICIPATION_STATUS_MAYBE); $result = $entry->getReminderUserQuery()->all(); @@ -77,7 +76,7 @@ public function testSpaceEntryWithParticipationNotRemindDeclinedParticipant() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $space); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $space); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->participation->setParticipationStatus(User::findOne(['id' => 2]), CalendarEntryParticipation::PARTICIPATION_STATUS_DECLINED); $result = $entry->getReminderUserQuery()->all(); @@ -94,7 +93,7 @@ public function testUserEntryWithoutParticipationRemindOnlyUser() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $user); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $user); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_NONE; $result = $entry->getReminderUserQuery()->all(); static::assertCount(1, $result); @@ -108,7 +107,7 @@ public function testUserEntryWithParticipationRemindOnlyUserIfNoParticipants() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $user); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $user); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $result = $entry->getReminderUserQuery()->all(); static::assertCount(1, $result); @@ -122,7 +121,7 @@ public function testUserEntryWithParticipationRemindUserAndAcceptedParticipant() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $user); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $user); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->setParticipationStatus($participant, CalendarEntryParticipation::PARTICIPATION_STATUS_ACCEPTED); $result = $entry->getReminderUserQuery()->all(); @@ -138,7 +137,7 @@ public function testUserEntryWithParticipationRemindUserAndMaybeParticipant() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $user); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $user); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->setParticipationStatus($participant, CalendarEntryParticipation::PARTICIPATION_STATUS_MAYBE); $result = $entry->getReminderUserQuery()->all(); @@ -154,7 +153,7 @@ public function testUserEntryWithParticipationRemindUserAndNotDeclinedUser() $this->becomeUser('admin'); // Entry begins exactly in one hour - $entry = $this->createEntry((new DateTime)->add(new DateInterval('PT1H')), null, 'Test', $user); + $entry = $this->createEntry((new DateTime())->add(new DateInterval('PT1H')), null, 'Test', $user); $entry->participation_mode = CalendarEntryParticipation::PARTICIPATION_MODE_ALL; $entry->setParticipationStatus($participant, CalendarEntryParticipation::PARTICIPATION_STATUS_DECLINED); $result = $entry->getReminderUserQuery()->all(); @@ -178,4 +177,4 @@ private static function assertParticipantInResult(User $user, array $participant static::assertTrue($found); } -} \ No newline at end of file +} diff --git a/tests/config/test.php b/tests/config/test.php index 7c458e80..98570288 100644 --- a/tests/config/test.php +++ b/tests/config/test.php @@ -4,9 +4,6 @@ 'modules' => ['calendar'], 'fixtures' => [ 'default', - 'calendar_entry' => 'humhub\modules\calendar\tests\codeception\fixtures\CalendarEntryFixture' - ] + 'calendar_entry' => 'humhub\modules\calendar\tests\codeception\fixtures\CalendarEntryFixture', + ], ]; - - - diff --git a/widgets/CalendarControls.php b/widgets/CalendarControls.php index 74fd34d3..0a65129e 100644 --- a/widgets/CalendarControls.php +++ b/widgets/CalendarControls.php @@ -7,7 +7,6 @@ namespace humhub\modules\calendar\widgets; - use humhub\modules\content\components\ContentActiveRecord; use humhub\modules\content\helpers\ContentContainerHelper; use humhub\widgets\BaseStack; @@ -30,4 +29,4 @@ public function init() parent::init(); } -} \ No newline at end of file +} diff --git a/widgets/CalendarFilterBar.php b/widgets/CalendarFilterBar.php index c285699b..227c001c 100644 --- a/widgets/CalendarFilterBar.php +++ b/widgets/CalendarFilterBar.php @@ -8,7 +8,6 @@ namespace humhub\modules\calendar\widgets; - use humhub\components\Widget; use Yii; diff --git a/widgets/CalendarTypeListView.php b/widgets/CalendarTypeListView.php index 8ffb3b61..d8c7fc7c 100644 --- a/widgets/CalendarTypeListView.php +++ b/widgets/CalendarTypeListView.php @@ -15,7 +15,6 @@ namespace humhub\modules\calendar\widgets; - use humhub\components\Widget; use yii\data\ActiveDataProvider; @@ -25,4 +24,4 @@ public function run() { } -} \ No newline at end of file +} diff --git a/widgets/CloseLink.php b/widgets/CloseLink.php index a5baafe9..a0373c00 100644 --- a/widgets/CloseLink.php +++ b/widgets/CloseLink.php @@ -39,11 +39,11 @@ public function init() $this->options = [ 'data-action-click' => 'toggleClose', - 'data-action-target' =>"[data-calendar-entry='".$this->entry->id."']", - 'data-action-url' => Url::toEntryToggleClose($this->entry) + 'data-action-target' => "[data-calendar-entry='" . $this->entry->id . "']", + 'data-action-url' => Url::toEntryToggleClose($this->entry), ]; parent::init(); } -} \ No newline at end of file +} diff --git a/widgets/ConfigureButton.php b/widgets/ConfigureButton.php index 5ce09ecc..ddea284c 100644 --- a/widgets/ConfigureButton.php +++ b/widgets/ConfigureButton.php @@ -7,7 +7,6 @@ namespace humhub\modules\calendar\widgets; - use humhub\modules\calendar\helpers\Url; use humhub\modules\user\models\User; use humhub\widgets\ModalButton; @@ -71,4 +70,4 @@ public function canConfigure() } -} \ No newline at end of file +} diff --git a/widgets/ContainerConfigMenu.php b/widgets/ContainerConfigMenu.php index 6b1be104..26011d87 100644 --- a/widgets/ContainerConfigMenu.php +++ b/widgets/ContainerConfigMenu.php @@ -71,13 +71,13 @@ public function initItems() 'label' => Yii::t('CalendarModule.widgets_GlobalConfigMenu', 'Defaults'), 'url' => Url::toConfig($this->contentContainer), 'active' => $this->isCurrentRoute('calendar', 'container-config', 'index'), - 'visible' => $canConfigure + 'visible' => $canConfigure, ], [ 'label' => Yii::t('CalendarModule.widgets_GlobalConfigMenu', 'Event Types'), 'url' => Url::toConfigTypes($this->contentContainer), 'active' => $this->isCurrentRoute('calendar', 'container-config', 'types'), - 'visible' => $canConfigure + 'visible' => $canConfigure, ], ]; @@ -86,9 +86,9 @@ public function initItems() 'label' => Yii::t('CalendarModule.widgets_GlobalConfigMenu', 'Calendars'), 'url' => Url::toConfigCalendars($this->contentContainer), 'active' => $this->isCurrentRoute('calendar', 'container-config', 'calendars'), - 'visible' => $canConfigure + 'visible' => $canConfigure, ]; } } -} \ No newline at end of file +} diff --git a/widgets/DeleteLink.php b/widgets/DeleteLink.php index ee314707..8d1c2687 100644 --- a/widgets/DeleteLink.php +++ b/widgets/DeleteLink.php @@ -34,11 +34,11 @@ public function init() $this->options = [ 'data-action-click' => 'calendar.deleteEvent', - 'data-action-target' =>"[data-content-key='".$this->entry->content->id."']", - 'data-action-url' => Url::toEntryDelete($this->entry, 1) + 'data-action-target' => "[data-content-key='" . $this->entry->content->id . "']", + 'data-action-url' => Url::toEntryDelete($this->entry, 1), ]; parent::init(); } -} \ No newline at end of file +} diff --git a/widgets/DownloadIcsLink.php b/widgets/DownloadIcsLink.php index 2841abd9..a5d3a3ce 100644 --- a/widgets/DownloadIcsLink.php +++ b/widgets/DownloadIcsLink.php @@ -14,14 +14,12 @@ use humhub\modules\calendar\models\CalendarEntry; use Yii; - /** * Class DownloadIcsLink * @package humhub\modules\calendar\widgets */ class DownloadIcsLink extends Widget { - /** * @var CalendarEventIF */ @@ -35,4 +33,4 @@ public function run() return Html::a(Yii::t('CalendarModule.base', 'Download ICS'), Url::toEntryDownloadICS($this->calendarEntry), ['target' => '_blank']); } -} \ No newline at end of file +} diff --git a/widgets/EditLink.php b/widgets/EditLink.php index 88e6183b..e930ef44 100644 --- a/widgets/EditLink.php +++ b/widgets/EditLink.php @@ -33,11 +33,11 @@ public function init() $this->icon = 'fa-pencil'; $this->options = [ 'data-action-click' => 'calendar.editModal', - 'data-action-target' =>"[data-content-key='".$this->entry->content->id."']", - 'data-action-url' => Url::toEditEntry($this->entry, 1) + 'data-action-target' => "[data-content-key='" . $this->entry->content->id . "']", + 'data-action-url' => Url::toEditEntry($this->entry, 1), ]; parent::init(); } -} \ No newline at end of file +} diff --git a/widgets/EntryParticipants.php b/widgets/EntryParticipants.php index 2cffe31b..c59ed6a6 100644 --- a/widgets/EntryParticipants.php +++ b/widgets/EntryParticipants.php @@ -16,7 +16,6 @@ */ class EntryParticipants extends Widget { - /** * @var CalendarEntry */ @@ -74,5 +73,5 @@ public static function participateButton(CalendarEntry $calendarEntry, $state, $ } return $button; - } + } } diff --git a/widgets/ExportParticipantsButton.php b/widgets/ExportParticipantsButton.php index 87d5032b..c1f9a597 100644 --- a/widgets/ExportParticipantsButton.php +++ b/widgets/ExportParticipantsButton.php @@ -1,69 +1,69 @@ -state === null) { - $this->state = Yii::$app->request->get('state', Yii::$app->request->post('state', '')); - } - } - - /** - * @inheritdoc - */ - public function beforeRun() - { - return parent::beforeRun() && $this->entry->content->canEdit(); - } - - /** - * @inheritdoc - */ - public function run() - { - echo $this->render('exportParticipantsButton', [ - 'buttons' => $this->getButtons() - ]); - } - - /** - * @return Button[] - */ - private function getButtons(): array - { - return [ - Button::none(Yii::t('CalendarModule.base', 'Export as {type}', ['type' => 'csv'])) - ->link(Url::toExportParticipations('csv', $this->entry, $this->state)) - ->icon('file-code-o'), - Button::none(Yii::t('CalendarModule.base', 'Export as {type}', ['type' => 'xlsx'])) - ->link(Url::toExportParticipations('xlsx', $this->entry, $this->state)) - ->icon('file-excel-o') - ]; - } -} +state === null) { + $this->state = Yii::$app->request->get('state', Yii::$app->request->post('state', '')); + } + } + + /** + * @inheritdoc + */ + public function beforeRun() + { + return parent::beforeRun() && $this->entry->content->canEdit(); + } + + /** + * @inheritdoc + */ + public function run() + { + echo $this->render('exportParticipantsButton', [ + 'buttons' => $this->getButtons(), + ]); + } + + /** + * @return Button[] + */ + private function getButtons(): array + { + return [ + Button::none(Yii::t('CalendarModule.base', 'Export as {type}', ['type' => 'csv'])) + ->link(Url::toExportParticipations('csv', $this->entry, $this->state)) + ->icon('file-code-o'), + Button::none(Yii::t('CalendarModule.base', 'Export as {type}', ['type' => 'xlsx'])) + ->link(Url::toExportParticipations('xlsx', $this->entry, $this->state)) + ->icon('file-excel-o'), + ]; + } +} diff --git a/widgets/FullCalendar.php b/widgets/FullCalendar.php index ea43c64c..4abac4b5 100644 --- a/widgets/FullCalendar.php +++ b/widgets/FullCalendar.php @@ -92,7 +92,7 @@ public function getData() ]; } - const LOCALE_MAPPING = [ + public const LOCALE_MAPPING = [ 'nb-no' => 'nb', 'fa-ir' => 'fa', ]; @@ -111,7 +111,7 @@ private function canCreate() { if ($this->contentContainer && !Yii::$app->user->isGuest) { return (new CalendarEntry($this->contentContainer))->content->canEdit(); - } else if (!Yii::$app->user->isGuest) { + } elseif (!Yii::$app->user->isGuest) { return Yii::$app->user->getIdentity()->isCurrentUser(); } diff --git a/widgets/GlobalConfigMenu.php b/widgets/GlobalConfigMenu.php index 59dfbf4c..4d03aebd 100644 --- a/widgets/GlobalConfigMenu.php +++ b/widgets/GlobalConfigMenu.php @@ -15,7 +15,6 @@ namespace humhub\modules\calendar\widgets; - use humhub\modules\calendar\helpers\Url; use Yii; use humhub\modules\calendar\interfaces\CalendarService; @@ -23,7 +22,6 @@ class GlobalConfigMenu extends SettingsTabs { - /** * @inheritdoc */ @@ -37,25 +35,25 @@ public function init() 'label' => Yii::t('CalendarModule.widgets_GlobalConfigMenu', 'Defaults'), 'url' => Url::toConfig(), 'active' => $this->isCurrentRoute('calendar', 'config', 'index'), - 'sortOrder' => 10 + 'sortOrder' => 10, ], [ 'label' => Yii::t('CalendarModule.widgets_GlobalConfigMenu', 'Event Types'), 'url' => Url::toConfigTypes(), 'active' => $this->isCurrentRoute('calendar', 'config', 'types'), - 'sortOrder' => 20 + 'sortOrder' => 20, ], [ 'label' => Yii::t('CalendarModule.widgets_GlobalConfigMenu', 'Snippet'), 'url' => Url::toConfigSnippets(), 'active' => $this->isCurrentRoute('calendar', 'config', 'snippet'), - 'sortOrder' => 30 + 'sortOrder' => 30, ], [ 'label' => Yii::t('CalendarModule.widgets_GlobalConfigMenu', 'Menu'), 'url' => Url::toConfigMenu(), 'active' => $this->isCurrentRoute('calendar', 'config', 'menu'), - 'sortOrder' => 40 + 'sortOrder' => 40, ], ]; @@ -64,11 +62,11 @@ public function init() 'label' => Yii::t('CalendarModule.widgets_GlobalConfigMenu', 'Calendars'), 'url' => Url::toConfigCalendars(), 'active' => $this->isCurrentRoute('calendar', 'config', 'calendars'), - 'sortOrder' => 25 + 'sortOrder' => 25, ]; } parent::init(); } -} \ No newline at end of file +} diff --git a/widgets/ParticipantAddForm.php b/widgets/ParticipantAddForm.php index ade00a95..7acd8a52 100644 --- a/widgets/ParticipantAddForm.php +++ b/widgets/ParticipantAddForm.php @@ -63,7 +63,7 @@ public function run() 'model' => $this->model, 'searchUsersUrl' => $content->container->createUrl('/calendar/entry/search-participants', ['entryId' => $this->model->entry->id]), 'addParticipantsUrl' => $content->container->createUrl('/calendar/entry/add-participants'), - 'statuses' => ParticipantItem::getStatuses($this->model->entry, CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE) + 'statuses' => ParticipantItem::getStatuses($this->model->entry, CalendarEntryParticipant::PARTICIPATION_STATE_MAYBE), ]); } } diff --git a/widgets/ParticipantsLink.php b/widgets/ParticipantsLink.php index 62fb077e..16582867 100644 --- a/widgets/ParticipantsLink.php +++ b/widgets/ParticipantsLink.php @@ -27,10 +27,10 @@ public function init() 'data-action-click' => 'editModal', 'data-action-url' => $this->entry->content->canEdit() ? Url::toEditEntryParticipation($this->entry) - : Url::toParticipationUserList($this->entry) + : Url::toParticipationUserList($this->entry), ]; parent::init(); } -} \ No newline at end of file +} diff --git a/widgets/ReminderLink.php b/widgets/ReminderLink.php index c327f582..c1db0daa 100644 --- a/widgets/ReminderLink.php +++ b/widgets/ReminderLink.php @@ -14,14 +14,12 @@ use humhub\widgets\ModalButton; use Yii; - /** * Class DownloadIcsLink * @package humhub\modules\calendar\widgets */ class ReminderLink extends Widget { - /** * @var ContentActiveRecord */ @@ -35,4 +33,4 @@ public function run() return ModalButton::asLink(Yii::t('CalendarModule.base', 'Set reminder'))->load(Url::toUserLevelReminderConfig($this->entry))->loader(true); } -} \ No newline at end of file +} diff --git a/widgets/UpcomingEvents.php b/widgets/UpcomingEvents.php index f5bf7b56..ba8de69e 100644 --- a/widgets/UpcomingEvents.php +++ b/widgets/UpcomingEvents.php @@ -18,7 +18,6 @@ */ class UpcomingEvents extends Widget { - /** * ContentContainer to limit events to. (Optional) * diff --git a/widgets/WallEntry.php b/widgets/WallEntry.php index 52bef148..ecd25feb 100644 --- a/widgets/WallEntry.php +++ b/widgets/WallEntry.php @@ -16,7 +16,7 @@ class WallEntry extends WallStreamModuleEntryWidget */ public $createRoute = '/calendar/entry/add-from-wall'; - const VIEW_CONTEXT_FULLCALENDAR = 'fullCalendar'; + public const VIEW_CONTEXT_FULLCALENDAR = 'fullCalendar'; /** * @var CalendarEntry @@ -32,7 +32,7 @@ class WallEntry extends WallStreamModuleEntryWidget * @inheritdoc */ public $editRoute = "/calendar/entry/edit"; - + /** * @inheritdoc */ @@ -107,7 +107,7 @@ protected function renderContent() 'calendarEntry' => $entry, 'collapse' => $this->collapse, 'participantSate' => $entry->getParticipationStatus(Yii::$app->user->identity), - 'contentContainer' => $entry->content->container + 'contentContainer' => $entry->content->container, ]); } @@ -119,5 +119,3 @@ protected function getTitle() return $this->model->title; } } - -?> diff --git a/widgets/mails/CalendarEventMailInfo.php b/widgets/mails/CalendarEventMailInfo.php index 73418e0f..45d95cc6 100644 --- a/widgets/mails/CalendarEventMailInfo.php +++ b/widgets/mails/CalendarEventMailInfo.php @@ -12,11 +12,11 @@ class CalendarEventMailInfo extends \humhub\components\Widget { - const RENDER_TYPE_TEXT = 'text'; - const RENDER_TYPE_HTML = 'html'; + public const RENDER_TYPE_TEXT = 'text'; + public const RENDER_TYPE_HTML = 'html'; - const VIEW_HTML = 'eventInfoHtml'; - const VIEW_Text = 'eventInfoText'; + public const VIEW_HTML = 'eventInfoHtml'; + public const VIEW_Text = 'eventInfoText'; /** * @var CalendarEventIF @@ -47,23 +47,23 @@ class CalendarEventMailInfo extends \humhub\components\Widget */ public $extraInfo; - public static function html($event, $url = null, $extraInfo = null) + public static function html($event, $url = null, $extraInfo = null) { return static::widget([ 'event' => $event, 'url' => $url, 'type' => static::RENDER_TYPE_HTML, - 'extraInfo' => $extraInfo + 'extraInfo' => $extraInfo, ]); } - public static function text($event, $url = null, $extraInfo = null) + public static function text($event, $url = null, $extraInfo = null) { return static::widget([ 'event' => $event, 'url' => $url, 'type' => static::RENDER_TYPE_TEXT, - 'extraInfo' => $extraInfo + 'extraInfo' => $extraInfo, ]); } @@ -72,4 +72,4 @@ public function run() $view = $this->type === static::RENDER_TYPE_TEXT ? static::VIEW_Text : static::VIEW_HTML; return $this->render($view, ['event' => $this->event, 'url' => $this->url, 'extraInfo' => $this->extraInfo]); } -} \ No newline at end of file +}