diff --git a/Pages/Ajax/ReservationAttributesPage.php b/Pages/Ajax/ReservationAttributesPage.php index f3c3ff5de..70f9fcdf0 100644 --- a/Pages/Ajax/ReservationAttributesPage.php +++ b/Pages/Ajax/ReservationAttributesPage.php @@ -10,7 +10,7 @@ interface IReservationAttributesPage public function GetRequestedUserId(); /** - * @return int + * @return string */ public function GetRequestedReferenceNumber(); diff --git a/Pages/Ajax/ReservationAttributesPrintPage.php b/Pages/Ajax/ReservationAttributesPrintPage.php index f0be1b860..27aa574bd 100644 --- a/Pages/Ajax/ReservationAttributesPrintPage.php +++ b/Pages/Ajax/ReservationAttributesPrintPage.php @@ -10,7 +10,7 @@ interface IReservationAttributesPrintPage public function GetRequestedUserId(); /** - * @return int + * @return string */ public function GetRequestedReferenceNumber(); diff --git a/phpstan_next.neon b/phpstan_next.neon index dc5bb17bd..33c7a11c7 100644 --- a/phpstan_next.neon +++ b/phpstan_next.neon @@ -40,6 +40,5 @@ parameters: - Presenters/ - WebServices/ - lib/ - - tests/Presenters/ bootstrapFiles: - vendor/autoload.php diff --git a/tests/Presenters/Admin/ManageConfigurationPresenterTest.php b/tests/Presenters/Admin/ManageConfigurationPresenterTest.php index 53a1a4f6a..45405e9c1 100644 --- a/tests/Presenters/Admin/ManageConfigurationPresenterTest.php +++ b/tests/Presenters/Admin/ManageConfigurationPresenterTest.php @@ -263,8 +263,7 @@ public function SetConfigFileOptions($configFiles) */ public function GetConfigFileToEdit() { - // TODO: Implement GetConfigFileToEdit() method. - return null; + return ''; } /** @@ -362,7 +361,6 @@ public function SetExportPluginValues($values) */ public function GetHomePageId() { - // TODO: Implement GetHomePageId() method. - return null; + return 0; } } diff --git a/tests/Presenters/Admin/ManagePaymentsPresenterTest.php b/tests/Presenters/Admin/ManagePaymentsPresenterTest.php index 813658850..c01deac3b 100644 --- a/tests/Presenters/Admin/ManagePaymentsPresenterTest.php +++ b/tests/Presenters/Admin/ManagePaymentsPresenterTest.php @@ -29,12 +29,12 @@ public function setUp(): void public function testPageLoadSetsCurrentCreditValues() { $creditCost = new CreditCost(44.4, 'USD'); - $this->paymentRepository->_CreditCost = $creditCost; + $this->paymentRepository->_CreditCost = [$creditCost]; $this->presenter->PageLoad(); - $this->assertEquals($creditCost->Cost(), $this->page->_CreditCost->Cost()); - $this->assertEquals($creditCost->Currency(), $this->page->_CreditCost->Currency()); + $this->assertEquals($creditCost->Cost(), $this->page->_CreditCost[0]->Cost()); + $this->assertEquals($creditCost->Currency(), $this->page->_CreditCost[0]->Currency()); } public function testPageLoadSetsGatewayValues() @@ -120,6 +120,7 @@ public function testIssuesPayPalRefund() $this->page->_RefundAmount = 100; $this->paymentRepository->_TransactionLogView = $this->GetTransactionLogView(); + /** @var FakePayPalGateway $gateway */ $gateway = $this->paymentRepository->_PayPal; $gateway->_Refund->state = 'completed'; diff --git a/tests/Presenters/Admin/ManageUsersPresenterTest.php b/tests/Presenters/Admin/ManageUsersPresenterTest.php index 27d50698e..bf253a107 100644 --- a/tests/Presenters/Admin/ManageUsersPresenterTest.php +++ b/tests/Presenters/Admin/ManageUsersPresenterTest.php @@ -659,20 +659,17 @@ public function BindGroups($groups) public function GetReservationColor() { - // TODO: Implement GetReservationColor() method. - return null; + return ''; } public function GetValue() { - // TODO: Implement GetValue() method. - return null; + return ''; } public function GetName() { - // TODO: Implement GetName() method. - return null; + return ''; } public function ShowTemplateCSV($attributes) @@ -682,8 +679,13 @@ public function ShowTemplateCSV($attributes) public function GetImportFile() { - // TODO: Implement GetImportFile() method. - return null; + return new UploadedFile([ + 'name' => 'users.csv', + 'tmp_name' => __FILE__, + 'type' => 'text/csv', + 'size' => filesize(__FILE__), + 'error' => UPLOAD_ERR_OK, + ]); } public function SetImportResult($importResult) @@ -693,8 +695,7 @@ public function SetImportResult($importResult) public function GetInvitedEmails() { - // TODO: Implement GetInvitedEmails() method. - return null; + return ''; } public function ShowExportCsv() @@ -714,14 +715,12 @@ public function GetDeletedUserIds() public function SendEmailNotification() { - // TODO: Implement SendEmailNotification() method. - return null; + return false; } public function GetUpdateOnImport() { - // TODO: Implement GetUpdateOnImport() method. - return null; + return false; } public function ShowUserUpdate(User $user, $attributes) diff --git a/tests/Presenters/CalendarSubscriptionPresenterTest.php b/tests/Presenters/CalendarSubscriptionPresenterTest.php index 61bcfb833..1670294a8 100644 --- a/tests/Presenters/CalendarSubscriptionPresenterTest.php +++ b/tests/Presenters/CalendarSubscriptionPresenterTest.php @@ -222,8 +222,7 @@ public function GetResourceGroupId() public function GetAccessoryIds() { - // TODO: Implement GetAccessoryIds() method. - return null; + return 0; } public function GetPastNumberOfDays() diff --git a/tests/Presenters/EmbeddedCalendarPresenterTest.php b/tests/Presenters/EmbeddedCalendarPresenterTest.php index 41748f568..2dea4f49d 100644 --- a/tests/Presenters/EmbeddedCalendarPresenterTest.php +++ b/tests/Presenters/EmbeddedCalendarPresenterTest.php @@ -196,8 +196,7 @@ public function GetDisplayType() */ public function GetTitleFormat() { - // TODO: Implement GetTitleFormat() method. - return null; + return ''; } /** diff --git a/tests/Presenters/LoginPresenterTest.php b/tests/Presenters/LoginPresenterTest.php index 29c693afd..52f1ee197 100644 --- a/tests/Presenters/LoginPresenterTest.php +++ b/tests/Presenters/LoginPresenterTest.php @@ -47,15 +47,13 @@ public function setUp(): void $this->fakeServer->SetSession(SessionKeys::USER_SESSION, new UserSession(1)); - $this->presenter = new LoginPresenter($this->page, $this->auth, $this->captchaService, $this->announcementRepository); + $loginPage = $this->page; + $this->presenter = new LoginPresenter($loginPage, $this->auth, $this->captchaService, $this->announcementRepository); } public function teardown(): void { parent::teardown(); - - $this->auth = null; - $this->page = null; } public function testLoginCallsAuthValidate() @@ -423,8 +421,7 @@ public function SetPasswordResetUrl($url) public function GetCaptcha() { - // TODO: Implement GetCaptcha() method. - return null; + return ''; } public function SetAnnouncements($announcements) diff --git a/tests/Presenters/RegisterPresenterTest.php b/tests/Presenters/RegisterPresenterTest.php index 6bb651874..d75c9cc8e 100644 --- a/tests/Presenters/RegisterPresenterTest.php +++ b/tests/Presenters/RegisterPresenterTest.php @@ -69,10 +69,6 @@ public function setUp(): void public function teardown(): void { parent::teardown(); - - $this->page = null; - $this->fakeReg = null; - $this->fakeAuth = null; } public function testSetsSelectedTimezoneToServerDefault() diff --git a/tests/Presenters/Reports/GenerateReportPresenterTest.php b/tests/Presenters/Reports/GenerateReportPresenterTest.php index 96115a135..2b9ad88ec 100644 --- a/tests/Presenters/Reports/GenerateReportPresenterTest.php +++ b/tests/Presenters/Reports/GenerateReportPresenterTest.php @@ -201,7 +201,7 @@ class FakeGenerateReportPage extends GenerateReportPage */ public $_BoundReport; /** - * @var Report_Usage + * @var string|Report_Usage */ public $_Usage; @@ -273,7 +273,7 @@ public function GetEnd() public function GetResourceIds() { - return $this->_ResourceId; + return is_array($this->_ResourceId) ? $this->_ResourceId : [$this->_ResourceId]; } public function GetResourceTypeIds() @@ -283,7 +283,7 @@ public function GetResourceTypeIds() public function GetScheduleIds() { - return $this->_ScheduleId; + return is_array($this->_ScheduleId) ? $this->_ScheduleId : [$this->_ScheduleId]; } public function GetUserId() @@ -298,7 +298,7 @@ public function GetParticipantId() public function GetGroupIds() { - return $this->_GroupId; + return is_array($this->_GroupId) ? $this->_GroupId : [$this->_GroupId]; } public function BindReport(IReport $report, IReportDefinition $definition, $selectedColumns) @@ -314,7 +314,7 @@ public function GetUsage() public function GetAccessoryIds() { - return $this->_AccessoryId; + return is_array($this->_AccessoryId) ? $this->_AccessoryId : [$this->_AccessoryId]; } public function GetReportName() diff --git a/tests/Presenters/Reports/SavedReportsPresenterTest.php b/tests/Presenters/Reports/SavedReportsPresenterTest.php index a0df07fe8..8a77f29b5 100644 --- a/tests/Presenters/Reports/SavedReportsPresenterTest.php +++ b/tests/Presenters/Reports/SavedReportsPresenterTest.php @@ -136,7 +136,7 @@ class FakeSavedReportsPage extends SavedReportsPage */ public $_BoundReport; /** - * @var ReportDefinition + * @var IReportDefinition */ public $_BoundDefinition; /** diff --git a/tests/Presenters/Reservation/GuestReservationPresenterTest.php b/tests/Presenters/Reservation/GuestReservationPresenterTest.php index 8c6e8092a..0db7ea3c5 100644 --- a/tests/Presenters/Reservation/GuestReservationPresenterTest.php +++ b/tests/Presenters/Reservation/GuestReservationPresenterTest.php @@ -146,20 +146,17 @@ public function GetRequestedScheduleId() public function GetReservationDate() { - // TODO: Implement GetReservationDate() method. - return null; + return Date::Now(); } public function GetStartDate() { - // TODO: Implement GetStartDate() method. - return null; + return Date::Now(); } public function GetEndDate() { - // TODO: Implement GetEndDate() method. - return null; + return Date::Now(); } public function BindPeriods($startPeriods, $endPeriods, $lockPeriods) @@ -281,8 +278,7 @@ public function MakeUnavailable() public function IsUnavailable() { - // TODO: Implement IsUnavailable() method. - return null; + return false; } public function SetTermsAccepted($accepted) diff --git a/tests/Presenters/Reservation/ReservationAttributesPresenterTest.php b/tests/Presenters/Reservation/ReservationAttributesPresenterTest.php index 03321d595..4bfa952e0 100644 --- a/tests/Presenters/Reservation/ReservationAttributesPresenterTest.php +++ b/tests/Presenters/Reservation/ReservationAttributesPresenterTest.php @@ -220,7 +220,7 @@ class FakeReservationAttributesPage implements IReservationAttributesPage public $_RequestedUserId; /** - * @var int + * @var string */ public $_RequestedReferenceNumber; @@ -233,15 +233,16 @@ public function GetRequestedUserId() } /** - * @param LBAttribute[] $attributes + * @param Attribute[] $attributes */ public function SetAttributes($attributes) { + /** @var LBAttribute[] $attributes */ $this->_Attributes = $attributes; } /** - * @return int + * @return string */ public function GetRequestedReferenceNumber() { @@ -253,7 +254,6 @@ public function GetRequestedReferenceNumber() */ public function GetRequestedResourceIds() { - // TODO: Implement GetRequestedResourceIds() method. - return null; + return []; } } diff --git a/tests/Presenters/Reservation/ReservationInitializationTest.php b/tests/Presenters/Reservation/ReservationInitializationTest.php index a3085d042..00aa46a47 100644 --- a/tests/Presenters/Reservation/ReservationInitializationTest.php +++ b/tests/Presenters/Reservation/ReservationInitializationTest.php @@ -29,7 +29,7 @@ class ReservationInitializationTest extends TestBase private $page; /** - * @var NewReservationInitializer|PHPUnit\Framework\MockObject\MockObject + * @var NewReservationInitializer */ private $initializer; diff --git a/tests/Presenters/Reservation/ReservationMovePresenterTest.php b/tests/Presenters/Reservation/ReservationMovePresenterTest.php index a4392af9c..06cf47d9c 100644 --- a/tests/Presenters/Reservation/ReservationMovePresenterTest.php +++ b/tests/Presenters/Reservation/ReservationMovePresenterTest.php @@ -229,8 +229,7 @@ public function SetRetryParameters($retryParameters) */ public function GetRetryParameters() { - // TODO: Implement GetRetryParameters() method. - return null; + return []; } /** diff --git a/tests/Presenters/Reservation/ReservationWaitlistPresenterTest.php b/tests/Presenters/Reservation/ReservationWaitlistPresenterTest.php index 12747b912..287d90cf8 100644 --- a/tests/Presenters/Reservation/ReservationWaitlistPresenterTest.php +++ b/tests/Presenters/Reservation/ReservationWaitlistPresenterTest.php @@ -139,8 +139,7 @@ public function SetRetryParameters($retryParameters) */ public function GetRetryParameters() { - // TODO: Implement GetRetryParameters() method. - return null; + return []; } /** @@ -156,8 +155,7 @@ public function SetCanJoinWaitList($canJoinWaitlist) */ public function GetReferenceNumber() { - // TODO: Implement GetReferenceNumber() method. - return null; + return ''; } /** @@ -165,8 +163,7 @@ public function GetReferenceNumber() */ public function GetAction() { - // TODO: Implement GetAction() method. - return null; + return ''; } /** diff --git a/tests/Presenters/ResourceDisplayPresenterTest.php b/tests/Presenters/ResourceDisplayPresenterTest.php index 9b41d4ace..c87c57c36 100644 --- a/tests/Presenters/ResourceDisplayPresenterTest.php +++ b/tests/Presenters/ResourceDisplayPresenterTest.php @@ -433,8 +433,7 @@ public function GetDataRequest() public function GetResourceId() { - // TODO: Implement GetResourceId() method. - return null; + return ''; } public function DisplayLogin() @@ -575,8 +574,7 @@ public function SetTerms($termsOfService) */ public function GetTermsOfServiceAcknowledgement() { - // TODO: Implement GetTermsOfServiceAcknowledgement() method. - return null; + return false; } public function DisplayInstructions() diff --git a/tests/Presenters/SchedulePresenterTest.php b/tests/Presenters/SchedulePresenterTest.php index 0714e2f66..02e70f2b4 100644 --- a/tests/Presenters/SchedulePresenterTest.php +++ b/tests/Presenters/SchedulePresenterTest.php @@ -974,7 +974,7 @@ public function SetDailyLayout($dailyLayout) public function GetScheduleId() { - return null; + return 0; } /** @@ -1020,7 +1020,7 @@ public function SetPreviousNextDates($previousDate, $nextDate) */ public function GetSelectedDate() { - return null; + return ''; } /** @@ -1041,7 +1041,7 @@ public function ShowFullWeekToggle($showShowFullWeekToggle) */ public function GetShowFullWeek() { - return null; + return false; } /** @@ -1056,7 +1056,7 @@ public function SetLayoutResponse($layoutResponse) */ public function GetLayoutDate() { - return null; + return ''; } /** @@ -1065,7 +1065,7 @@ public function GetLayoutDate() */ public function GetScheduleStyle($scheduleId) { - return null; + return ''; } /** @@ -1170,12 +1170,12 @@ public function ShowPermissionError($shouldShow) public function GetDisplayTimezone(UserSession $user, Schedule $schedule) { - return null; + return ''; } public function GetResourceId() { - return null; + return 0; } public function GetSelectedDates() @@ -1197,7 +1197,7 @@ public function GetSortDirection() public function FilterCleared() { - return null; + return false; } public function BindScheduleAvailability($availability, $tooEarly) @@ -1234,13 +1234,11 @@ public function GetParticipantId() public function GetOwnerText() { - // TODO: Implement GetOwnerText() method. - return null; + return ''; } public function GetParticipantText() { - // TODO: Implement GetParticipantText() method. - return null; + return ''; } } diff --git a/tests/Presenters/Search/SearchReservationsPresenterTest.php b/tests/Presenters/Search/SearchReservationsPresenterTest.php index 20295cde8..a6f7875bf 100644 --- a/tests/Presenters/Search/SearchReservationsPresenterTest.php +++ b/tests/Presenters/Search/SearchReservationsPresenterTest.php @@ -114,13 +114,13 @@ public function GetRequestedRange() public function GetRequestedStartDate() { - return null; + return ''; } public function GetRequestedEndDate() { - return null; + return ''; } public function GetResources() diff --git a/tests/Presenters/SearchAvailabilityPresenterTest.php b/tests/Presenters/SearchAvailabilityPresenterTest.php index 7646a7278..63c53fad3 100644 --- a/tests/Presenters/SearchAvailabilityPresenterTest.php +++ b/tests/Presenters/SearchAvailabilityPresenterTest.php @@ -116,7 +116,7 @@ public function testWhenThisWeekSelected() $tz = $this->fakeUser->Timezone; - $resource = new FakeBookableResource($resourceId); + $resource = new TestResourceDto($resourceId); $this->resourceService->_AllResources = [$resource]; Date::_SetNow(Date::Parse('2016-07-09 12:00')); @@ -524,7 +524,7 @@ public function GetRepeatType() public function GetRepeatInterval() { - return $this->_RepeatInterval; + return $this->_RepeatInterval === null ? null : (string)$this->_RepeatInterval; } public function GetRepeatWeekdays() diff --git a/tests/fakes/FakeAttributeService.php b/tests/fakes/FakeAttributeService.php index 5675be3ea..9c6ff94cf 100644 --- a/tests/fakes/FakeAttributeService.php +++ b/tests/fakes/FakeAttributeService.php @@ -12,7 +12,7 @@ class FakeAttributeService implements IAttributeService */ public $_ValidationResult; /** - * @var CustomAttribute[] + * @var array> */ public $_ByCategory = []; public $_EntityAttributeList; diff --git a/tests/fakes/FakePaymentRepository.php b/tests/fakes/FakePaymentRepository.php index 466287e7b..47c4b1381 100644 --- a/tests/fakes/FakePaymentRepository.php +++ b/tests/fakes/FakePaymentRepository.php @@ -7,7 +7,7 @@ class FakePaymentRepository implements IPaymentRepository */ public $_LastCost; /** - * @var array|CreditCost[] + * @var CreditCost[] */ public $_CreditCost; /** @@ -19,7 +19,7 @@ class FakePaymentRepository implements IPaymentRepository */ public $_LastStripe; /** - * @var FakePayPalGateway + * @var PayPalGateway */ public $_PayPal; /** diff --git a/tests/fakes/FakeReservationViewRepository.php b/tests/fakes/FakeReservationViewRepository.php index 74d49ef04..e568feb08 100644 --- a/tests/fakes/FakeReservationViewRepository.php +++ b/tests/fakes/FakeReservationViewRepository.php @@ -39,7 +39,7 @@ class FakeReservationViewRepository implements IReservationViewRepository public $_LastResourceIds; /** - * @var ReservationItemView[] + * @var array> */ public $_ReservationsIteration = [];