Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion phpstan_next.neon
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ parameters:
- Presenters/
- WebServices/
- lib/
- tests/fakes/
- tests/Presenters/
bootstrapFiles:
- vendor/autoload.php
6 changes: 3 additions & 3 deletions tests/fakes/DBFakes.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public function GetRow()
if (sizeof($this->rows) > $this->idx) {
return $this->rows[$this->idx++];
}
return false;
return [];
}

public function NumRows()
Expand Down Expand Up @@ -177,7 +177,7 @@ public function Disconnect()
public function Query(ISqlCommand $command)
{
$this->_LastSqlCommand = $command;
return null;
return new FakeReader([]);
}

public function Execute(ISqlCommand $command)
Expand All @@ -200,7 +200,7 @@ public function GetLastInsertId()
public function LimitQuery(ISqlCommand $command, $limit, $offset = null)
{
$this->_LimitQueryCalled = true;
return null;
return new FakeReader([]);
}
}

Expand Down
22 changes: 11 additions & 11 deletions tests/fakes/DBRows.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class CustomAttributeValueRow
{
private $rows = [];

public function Rows()
public function Rows(): array
{
return $this->rows;
}
Expand Down Expand Up @@ -303,7 +303,7 @@ private function AddRow($referenceNumber, $userId, $levelId)
* @param array|int[] $participantIds
* @return ReservationUserRow
*/
public function WithParticipants($instance, $participantIds)
public function WithParticipants(Reservation $instance, array $participantIds): ReservationUserRow
{
foreach ($participantIds as $id) {
$this->AddRow($instance->ReferenceNumber(), $id, ReservationUserLevel::PARTICIPANT);
Expand All @@ -316,7 +316,7 @@ public function WithParticipants($instance, $participantIds)
* @param array|int[] $inviteeIds
* @return ReservationUserRow
*/
public function WithInvitees($instance, $inviteeIds)
public function WithInvitees(Reservation $instance, array $inviteeIds): ReservationUserRow
{
foreach ($inviteeIds as $id) {
$this->AddRow($instance->ReferenceNumber(), $id, ReservationUserLevel::INVITEE);
Expand All @@ -329,7 +329,7 @@ class ReservationGuestRow
{
private $rows = [];

public function Rows()
public function Rows(): array
{
return $this->rows;
}
Expand All @@ -344,9 +344,9 @@ private function AddRow($referenceNumber, $email, $levelId)
/**
* @param Reservation $instance
* @param array|string[] $participants
* @return ReservationUserRow
* @return ReservationGuestRow
*/
public function WithParticipants($instance, $participants)
public function WithParticipants(Reservation $instance, array $participants): ReservationGuestRow
{
foreach ($participants as $email) {
$this->AddRow($instance->ReferenceNumber(), $email, ReservationUserLevel::PARTICIPANT);
Expand All @@ -356,13 +356,13 @@ public function WithParticipants($instance, $participants)

/**
* @param Reservation $instance
* @param array|int[] $invitees
* @return ReservationUserRow
* @param array|string[] $invitees
* @return ReservationGuestRow
*/
public function WithInvitees($instance, $invitees)
public function WithInvitees(Reservation $instance, array $invitees): ReservationGuestRow
{
foreach ($invitees as $email) {
$this->AddRow($instance->ReferenceNumber(), $email, ReservationUserLevel::INVITEE);
foreach ($invitees as $inviteeEmail) {
$this->AddRow($instance->ReferenceNumber(), $inviteeEmail, ReservationUserLevel::INVITEE);
}
return $this;
}
Expand Down
7 changes: 3 additions & 4 deletions tests/fakes/FakeAccessoryRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ public function AddAccessory(Accessory $accessory)
*/
public function LoadById($accessoryId)
{
// TODO: Implement LoadById() method.
return null;
throw new LogicException('LoadById() not implemented in FakeAccessoryRepository');
}

/**
Expand All @@ -34,8 +33,8 @@ public function LoadAll()
*/
public function Add(Accessory $accessory)
{
// TODO: Implement Add() method.
return null;
$this->_AllAccessories[] = $accessory;
return count($this->_AllAccessories);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/fakes/FakeAnnouncements.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public function GetExpectedRows()

public function GetAll($sortField = null, $sortDirection = null)
{
return null;
return [];
}

/**
Expand Down Expand Up @@ -97,6 +97,6 @@ public function Update(Announcement $announcement)
*/
public function LoadById($announcementId)
{
return null;
throw new LogicException('LoadById() not implemented in FakeAnnouncementRepository');
}
}
14 changes: 6 additions & 8 deletions tests/fakes/FakeAttributeList.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,25 @@ public function __construct($attributes = [])
/**
* @return array|string[]
*/
public function GetLabels()
public function GetLabels(): array
{
// TODO: Implement GetLabels() method.
return null;
return [];
}

/**
* @param null $entityId
* @return array|CustomAttribute[]
*/
public function GetDefinitions($entityId = null)
public function GetDefinitions($entityId = null): array
{
// TODO: Implement GetDefinitions() method.
return null;
return [];
}

/**
* @param $entityId int|null
* @return array|Attribute[]
* @return array|LBAttribute[]
*/
public function GetAttributes($entityId = null)
public function GetAttributes($entityId = null): array
{
if (array_key_exists($entityId, $this->_entityAttributes)) {
return $this->_entityAttributes[$entityId];
Expand Down
5 changes: 2 additions & 3 deletions tests/fakes/FakeAttributeService.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function Validate($category, $attributeValues, $entityIds = [], $ignoreEm
*/
public function GetByCategory($category)
{
return $this->_ByCategory[$category];
return $this->_ByCategory[$category] ?? [];
}

/**
Expand All @@ -55,8 +55,7 @@ public function GetByCategory($category)
*/
public function GetById($attributeId)
{
// TODO: Implement GetById() method.
return null;
throw new LogicException('GetById() not implemented in FakeAttributeService');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion tests/fakes/FakeBlackoutRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class FakeBlackoutRepository implements IBlackoutRepository
public function Add(BlackoutSeries $blackoutSeries)
{
$this->_Added = $blackoutSeries;
return null;
return 1;
}

/**
Expand Down
15 changes: 4 additions & 11 deletions tests/fakes/FakeConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public function Register($configFile, $envFile, $configId, $overwrite = false, $

public function __construct()
{
$this->_configs[self::DEFAULT_CONFIG_ID] = new FakeConfigFile();
$this->SetFile(self::DEFAULT_CONFIG_ID, new FakeConfigFile());
}

public function SetFile($configId, $file)
Expand All @@ -22,7 +22,9 @@ public function SetFile($configId, $file)

public function SetKey($configDef, $value)
{
$this->File(self::DEFAULT_CONFIG_ID)->SetKey($configDef, $value);
/** @var FakeConfigFile $file */
$file = $this->_configs[self::DEFAULT_CONFIG_ID];
$file->SetKey($configDef, $value);
}

public function SetTimezone($timezone)
Expand All @@ -39,15 +41,6 @@ public function EnableSubscription()
{
}

/**
* @param string $configId
* @return FakeConfigFile
*/

public function File($configId)
{
return $this->_configs[$configId];
}
}

class FakeConfigFile extends ConfigurationFile implements IConfigurationFile
Expand Down
9 changes: 3 additions & 6 deletions tests/fakes/FakeDailyLayout.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public function GetLayout(Date $date, $resourceId)
*/
public function IsDateReservable(Date $date)
{
// TODO: Implement IsDateReservable() method.
return null;
return true;
}

/**
Expand All @@ -31,8 +30,7 @@ public function IsDateReservable(Date $date)
*/
public function GetLabels(Date $displayDate)
{
// TODO: Implement GetLabels() method.
return null;
return [];
}

/**
Expand All @@ -51,8 +49,7 @@ public function GetPeriods(Date $displayDate)
*/
public function GetSummary(Date $date, $resourceId)
{
// TODO: Implement GetSummary() method.
return null;
throw new LogicException('GetSummary() not implemented in FakeDailyLayout');
}

/**
Expand Down
6 changes: 3 additions & 3 deletions tests/fakes/FakeExistingReservationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class FakeExistingReservationPage extends FakePageBase implements IExistingReser
public $_CheckInRequired = false;
public $_CheckOutRequired = false;
public $_AutoReleaseMinutes = null;
public $_IsUnavailable = false;

public function BindViewableResourceReservations($resourceIds)
{
Expand Down Expand Up @@ -241,13 +242,12 @@ public function SetFirstWeekday($weekday)

public function MakeUnavailable()
{
// TODO: Implement MakeUnavailable() method.
$this->_IsUnavailable = true;
}

public function IsUnavailable()
{
// TODO: Implement IsUnavailable() method.
return null;
return $this->_IsUnavailable;
}

public function SetTerms($termsOfService)
Expand Down
9 changes: 3 additions & 6 deletions tests/fakes/FakeGroupRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ public function GetUsersInGroup(
$filter = null,
$accountStatus = AccountStatus::ALL
) {
// TODO: Implement GetUsersInGroup() method.
return null;
return [];
}

/**
Expand All @@ -60,13 +59,11 @@ public function GetUsersInGroup(
*/
public function GetGroupsByRole($roleLevel)
{
// TODO: Implement GetGroupsByRole() method.
return null;
return [];
}

public function GetPermissionList()
{
// TODO: Implement GetPermissionList() method.
return null;
return [];
}
}
6 changes: 3 additions & 3 deletions tests/fakes/FakePaymentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class FakePaymentRepository implements IPaymentRepository
*/
public $_LastCost;
/**
* @var CreditCost
* @var array|CreditCost[]
*/
public $_CreditCost;
/**
Expand All @@ -32,7 +32,7 @@ class FakePaymentRepository implements IPaymentRepository
public $_LastSavedPayPalResult;

/**
* @var PageablePage
* @var PageableData|null
*/
public $_TransactionLogs;
public $_LastPage;
Expand Down Expand Up @@ -98,7 +98,7 @@ public function GetList($pageNumber, $pageSize, $userId = -1, $sortField = null,
$this->_LastPageSize = $pageSize;
$this->_LastUserId = $userId;

return $this->_TransactionLogs;
return $this->_TransactionLogs ?? new PageableData();
}

public function GetTransactionLogView($transactionLogId)
Expand Down
2 changes: 1 addition & 1 deletion tests/fakes/FakePermissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class FakePermissionService implements IPermissionService
{
/**
* @var array|IResource[]
* @var array|IPermissibleResource[]
*/
public $Resources;

Expand Down
4 changes: 2 additions & 2 deletions tests/fakes/FakeRegistrationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,9 @@ public function SetAttributes($attributeValues)
}

/**
* @return array|AttributeValue[]
* @return array|AttributeFormElement[]
*/
public function GetAttributes()
public function GetAttributes(): array
{
return $this->_AttributeValues;
}
Expand Down
4 changes: 2 additions & 2 deletions tests/fakes/FakeReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ public function GetAll()
}

/**
* @return string[]
* @return AttributeReportColumn[]
*/
public function GetCustomAttributes()
public function GetCustomAttributes(): array
{
return [];
}
Expand Down
Loading