mirror of
https://github.com/Karaka-Management/oms-Calendar.git
synced 2026-01-11 07:08:43 +00:00
phpstan, phpcs, phpunit fixes
This commit is contained in:
parent
c493398c64
commit
8130bee71a
|
|
@ -55,22 +55,20 @@
|
|||
"schedule_date": {
|
||||
"name": "schedule_date",
|
||||
"type": "DATETIME",
|
||||
"null": false
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"schedule_start": {
|
||||
"name": "schedule_start",
|
||||
"type": "DATETIME",
|
||||
"null": false
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"schedule_end": {
|
||||
"name": "schedule_end",
|
||||
"type": "DATETIME",
|
||||
"null": false
|
||||
},
|
||||
"schedule_numberofoccurrences": {
|
||||
"name": "schedule_numberofoccurrences",
|
||||
"type": "TINYINT(1)",
|
||||
"null": false
|
||||
"null": true,
|
||||
"default": null
|
||||
},
|
||||
"schedule_pattern_numberofoccurrences": {
|
||||
"name": "schedule_pattern_numberofoccurrences",
|
||||
|
|
@ -233,6 +231,13 @@
|
|||
"foreignTable": "calendar_event",
|
||||
"foreignKey": "calendar_event_id"
|
||||
},
|
||||
"calendar_event_calendar": {
|
||||
"name": "calendar_event_calendar",
|
||||
"type": "INT",
|
||||
"null": false,
|
||||
"foreignTable": "calendar",
|
||||
"foreignKey": "calendar_id"
|
||||
},
|
||||
"calendar_event_created_at": {
|
||||
"name": "calendar_event_created_at",
|
||||
"type": "DATETIME",
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ final class CalendarMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
|
|
|
|||
|
|
@ -106,6 +106,25 @@ class Event
|
|||
*/
|
||||
public Location $location;
|
||||
|
||||
public \DateTime $start;
|
||||
public \DateTime $end;
|
||||
|
||||
public int $showAs = 0;
|
||||
|
||||
public bool $hiddenAttendees = false;
|
||||
|
||||
public bool $isAllDay = true;
|
||||
|
||||
public bool $isCancelled = false;
|
||||
|
||||
public bool $isDraft = false;
|
||||
|
||||
public bool $isOnlineMeeting = false;
|
||||
|
||||
public string $webLink = '';
|
||||
|
||||
public string $externalId = '';
|
||||
|
||||
/**
|
||||
* Calendar
|
||||
*
|
||||
|
|
@ -142,6 +161,8 @@ class Event
|
|||
$this->location = new Location();
|
||||
$this->schedule = new Schedule();
|
||||
$this->calendar = 0;
|
||||
$this->start = new \DateTime('now');
|
||||
$this->end = new \DateTime('now');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -41,8 +41,18 @@ final class EventMapper extends DataMapperFactory
|
|||
'calendar_event_location' => ['name' => 'calendar_event_location', 'type' => 'Serializable', 'internal' => 'location'],
|
||||
'calendar_event_type' => ['name' => 'calendar_event_type', 'type' => 'int', 'internal' => 'type'],
|
||||
'calendar_event_status' => ['name' => 'calendar_event_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'calendar_event_show_as' => ['name' => 'calendar_event_show_as', 'type' => 'int', 'internal' => 'showAs'],
|
||||
'calendar_event_hidden_attendees' => ['name' => 'calendar_event_hidden_attendees', 'type' => 'bool', 'internal' => 'hiddenAttendees'],
|
||||
'calendar_event_is_all_day' => ['name' => 'calendar_event_is_all_day', 'type' => 'bool', 'internal' => 'isAllDay'],
|
||||
'calendar_event_is_cancelled' => ['name' => 'calendar_event_is_cancelled', 'type' => 'bool', 'internal' => 'isCancelled'],
|
||||
'calendar_event_is_draft' => ['name' => 'calendar_event_is_draft', 'type' => 'bool', 'internal' => 'isDraft'],
|
||||
'calendar_event_is_online_meeting' => ['name' => 'calendar_event_is_online_meeting', 'type' => 'bool', 'internal' => 'isOnlineMeeting'],
|
||||
'calendar_event_web_link' => ['name' => 'calendar_event_web_link', 'type' => 'string', 'internal' => 'webLink'],
|
||||
'calendar_event_external_id' => ['name' => 'calendar_event_external_id', 'type' => 'string', 'internal' => 'externalId'],
|
||||
'calendar_event_schedule' => ['name' => 'calendar_event_schedule', 'type' => 'int', 'internal' => 'schedule'],
|
||||
'calendar_event_calendar' => ['name' => 'calendar_event_calendar', 'type' => 'int', 'internal' => 'calendar'],
|
||||
'calendar_event_start' => ['name' => 'calendar_event_start', 'type' => 'DateTime', 'internal' => 'start'],
|
||||
'calendar_event_end' => ['name' => 'calendar_event_end', 'type' => 'DateTime', 'internal' => 'end'],
|
||||
'calendar_event_created_by' => ['name' => 'calendar_event_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
'calendar_event_created_at' => ['name' => 'calendar_event_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||
];
|
||||
|
|
@ -50,7 +60,7 @@ final class EventMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has one relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @var array<string, array{mapper:class-string, external:string, by?:string, column?:string, conditional?:bool}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const OWNS_ONE = [
|
||||
|
|
@ -63,7 +73,7 @@ final class EventMapper extends DataMapperFactory
|
|||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
|
||||
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const BELONGS_TO = [
|
||||
|
|
@ -76,7 +86,7 @@ final class EventMapper extends DataMapperFactory
|
|||
/**
|
||||
* Has many relation.
|
||||
*
|
||||
* @var array<string, array{mapper:string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @var array<string, array{mapper:class-string, table:string, self?:?string, external?:?string, column?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const HAS_MANY = [
|
||||
|
|
|
|||
|
|
@ -60,21 +60,15 @@ class Schedule
|
|||
*/
|
||||
private int $freqType = FrequencyType::ONCE;
|
||||
|
||||
/**
|
||||
* Frequency interval.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $freqInterval = FrequencyInterval::DAY;
|
||||
public int $dayOfMonth = 0;
|
||||
|
||||
/**
|
||||
* Frequency relative.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $relativeInternal = FrequencyRelative::FIRST;
|
||||
public int $daysOfWeek = 0;
|
||||
|
||||
public int $patternIndex = 0;
|
||||
|
||||
public int $patternMonth = 0;
|
||||
|
||||
public int $intervalType = 0;
|
||||
|
||||
/**
|
||||
* Interval type.
|
||||
|
|
@ -82,7 +76,7 @@ class Schedule
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
private int $intervalType = IntervalType::ABSOLUTE;
|
||||
private int $patternInterval = IntervalType::ABSOLUTE;
|
||||
|
||||
/**
|
||||
* Recurrence factor.
|
||||
|
|
@ -90,31 +84,31 @@ class Schedule
|
|||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $recurrenceFactor = 0;
|
||||
public int $numberOfOccurrences = 0;
|
||||
|
||||
/**
|
||||
* Date.
|
||||
*
|
||||
* @var null|\DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public ?\DateTime $date = null;
|
||||
|
||||
/**
|
||||
* Start.
|
||||
*
|
||||
* @var \DateTime
|
||||
* @var null|\DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public \DateTime $start;
|
||||
|
||||
/**
|
||||
* Duration.
|
||||
*
|
||||
* @var int
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public int $duration = 3600;
|
||||
public ?\DateTime $start = null;
|
||||
|
||||
/**
|
||||
* End.
|
||||
*
|
||||
* @var \DateTime
|
||||
* @var null|\DateTime
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public \DateTime $end;
|
||||
public ?\DateTime $end = null;
|
||||
|
||||
/**
|
||||
* Created at.
|
||||
|
|
@ -141,9 +135,6 @@ class Schedule
|
|||
{
|
||||
$this->createdBy = new NullAccount();
|
||||
$this->createdAt = new \DateTimeImmutable('now');
|
||||
$this->start = new \DateTime('now');
|
||||
$this->end = new \DateTime('now');
|
||||
$this->end->setTimestamp($this->end->getTimestamp() + $this->duration);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -219,83 +210,27 @@ class Schedule
|
|||
*/
|
||||
public function getIntervalType() : int
|
||||
{
|
||||
return $this->intervalType;
|
||||
return $this->patternInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $intervalType Interval type
|
||||
* @param int $patternInterval Interval type
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setIntervalType(int $intervalType) : self
|
||||
public function setIntervalType(int $patternInterval) : self
|
||||
{
|
||||
if (!IntervalType::isValidValue($intervalType)) {
|
||||
throw new InvalidEnumValue($intervalType);
|
||||
if (!IntervalType::isValidValue($patternInterval)) {
|
||||
throw new InvalidEnumValue($patternInterval);
|
||||
}
|
||||
|
||||
$this->intervalType = $intervalType;
|
||||
$this->patternInterval = $patternInterval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFrequencyRelative() : int
|
||||
{
|
||||
return $this->relativeInternal;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $relativeInterval Relative interval
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFrequencyRelative(int $relativeInterval) : self
|
||||
{
|
||||
if (!FrequencyRelative::isValidValue($relativeInterval)) {
|
||||
throw new InvalidEnumValue($relativeInterval);
|
||||
}
|
||||
|
||||
$this->relativeInternal = $relativeInterval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $freqInterval Frequency interval
|
||||
*
|
||||
* @return $this
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function setFreqInterval(int $freqInterval) : self
|
||||
{
|
||||
if (!FrequencyInterval::isValidValue($freqInterval)) {
|
||||
throw new InvalidEnumValue($freqInterval);
|
||||
}
|
||||
|
||||
$this->freqInterval = $freqInterval;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function getFreqInterval() : int
|
||||
{
|
||||
return $this->freqInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
@ -306,10 +241,7 @@ class Schedule
|
|||
'uuid' => $this->uid,
|
||||
'status' => $this->status,
|
||||
'freqType' => $this->freqType,
|
||||
'freqInterval' => $this->freqInterval,
|
||||
'relativeInternal' => $this->relativeInternal,
|
||||
'intervalType' => $this->intervalType,
|
||||
'recurrenceFactor' => $this->recurrenceFactor,
|
||||
'patternInterval' => $this->patternInterval,
|
||||
'start' => $this->start,
|
||||
'createdAt' => $this->createdAt,
|
||||
];
|
||||
|
|
|
|||
|
|
@ -34,25 +34,28 @@ final class ScheduleMapper extends DataMapperFactory
|
|||
* @since 1.0.0
|
||||
*/
|
||||
public const COLUMNS = [
|
||||
'schedule_id' => ['name' => 'schedule_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'schedule_uid' => ['name' => 'schedule_uid', 'type' => 'string', 'internal' => 'uid'],
|
||||
'schedule_status' => ['name' => 'schedule_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'schedule_freq_type' => ['name' => 'schedule_freq_type', 'type' => 'int', 'internal' => 'freqType'],
|
||||
'schedule_freq_interval' => ['name' => 'schedule_freq_interval', 'type' => 'int', 'internal' => 'freqInterval'],
|
||||
'schedule_freq_interval_type' => ['name' => 'schedule_freq_interval_type', 'type' => 'int', 'internal' => 'intervalType'],
|
||||
'schedule_freq_relative_interval' => ['name' => 'schedule_freq_relative_interval', 'type' => 'int', 'internal' => 'relativeInternal'],
|
||||
'schedule_freq_recurrence_factor' => ['name' => 'schedule_freq_recurrence_factor', 'type' => 'int', 'internal' => 'recurrenceFactor'],
|
||||
'schedule_start' => ['name' => 'schedule_start', 'type' => 'DateTime', 'internal' => 'start'],
|
||||
'schedule_duration' => ['name' => 'schedule_duration', 'type' => 'int', 'internal' => 'duration'],
|
||||
'schedule_end' => ['name' => 'schedule_end', 'type' => 'DateTime', 'internal' => 'end'],
|
||||
'schedule_created_at' => ['name' => 'schedule_created_at', 'type' => 'DateTimeImmutable', 'internal' => 'createdAt', 'readonly' => true],
|
||||
'schedule_created_by' => ['name' => 'schedule_created_by', 'type' => 'int', 'internal' => 'createdBy', 'readonly' => true],
|
||||
'schedule_id' => ['name' => 'schedule_id', 'type' => 'int', 'internal' => 'id'],
|
||||
'schedule_uid' => ['name' => 'schedule_uid', 'type' => 'string', 'internal' => 'uid'],
|
||||
'schedule_status' => ['name' => 'schedule_status', 'type' => 'int', 'internal' => 'status'],
|
||||
'schedule_freq_type' => ['name' => 'schedule_freq_type', 'type' => 'int', 'internal' => 'freqType'],
|
||||
'schedule_date' => ['name' => 'schedule_date', 'type' => 'DateTime', 'internal' => 'date'],
|
||||
'schedule_start' => ['name' => 'schedule_start', 'type' => 'DateTime', 'internal' => 'start'],
|
||||
'schedule_end' => ['name' => 'schedule_end', 'type' => 'DateTime', 'internal' => 'end'],
|
||||
'schedule_pattern_numberofoccurrences' => ['name' => 'schedule_pattern_numberofoccurrences', 'type' => 'int', 'internal' => 'numberOfOccurrences'],
|
||||
'schedule_pattern_type' => ['name' => 'schedule_pattern_type', 'type' => 'int', 'internal' => 'intervalType'],
|
||||
'schedule_pattern_pattern_interval' => ['name' => 'schedule_pattern_pattern_interval', 'type' => 'int', 'internal' => 'patternInterval'],
|
||||
'schedule_pattern_dayofmonth' => ['name' => 'schedule_pattern_dayofmonth', 'type' => 'int', 'internal' => 'dayOfMonth'],
|
||||
'schedule_pattern_daysofweek' => ['name' => 'schedule_pattern_daysofweek', 'type' => 'int', 'internal' => 'daysOfWeek'],
|
||||
'schedule_pattern_index' => ['name' => 'schedule_pattern_index', 'type' => 'int', 'internal' => 'patternIndex'],
|
||||
'schedule_pattern_month' => ['name' => 'schedule_pattern_month', 'type' => 'int', 'internal' => 'patternMonth'],
|
||||
'schedule_created_by' => ['name' => 'schedule_created_by', 'type' => 'int', 'internal' => 'createdBy'],
|
||||
'schedule_created_at' => ['name' => 'schedule_created_at', 'type' => 'DateTime', 'internal' => 'createdAt'],
|
||||
];
|
||||
|
||||
/**
|
||||
* Belongs to.
|
||||
*
|
||||
* @var array<string, array{mapper:string, external:string, column?:string, by?:string}>
|
||||
* @var array<string, array{mapper:class-string, external:string, column?:string, by?:string}>
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public const BELONGS_TO = [
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Karaka
|
||||
*
|
||||
* PHP Version 8.1
|
||||
*
|
||||
* @package Modules\Calendar
|
||||
* @copyright Dennis Eichhorn
|
||||
* @license OMS License 1.0
|
||||
* @version 1.0.0
|
||||
* @link https://jingga.app
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
return ['Calendar' => [
|
||||
]];
|
||||
|
|
@ -46,8 +46,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase
|
|||
self::assertEquals(ScheduleStatus::ACTIVE, $this->schedule->getStatus());
|
||||
self::assertEquals(FrequencyType::ONCE, $this->schedule->getFreqType());
|
||||
self::assertEquals(IntervalType::ABSOLUTE, $this->schedule->getIntervalType());
|
||||
self::assertEquals(FrequencyRelative::FIRST, $this->schedule->getFrequencyRelative());
|
||||
self::assertEquals(FrequencyInterval::DAY, $this->schedule->getFreqInterval());
|
||||
self::assertInstanceOf('\Modules\Admin\Models\NullAccount', $this->schedule->createdBy);
|
||||
}
|
||||
|
||||
|
|
@ -71,26 +69,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase
|
|||
$this->schedule->setStatus(999);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Calendar\Models\Schedule
|
||||
* @group module
|
||||
*/
|
||||
public function testFreqIntervalInputOutput() : void
|
||||
{
|
||||
$this->schedule->setFreqInterval(FrequencyInterval::DAY);
|
||||
self::assertEquals(FrequencyInterval::DAY, $this->schedule->getFreqInterval());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Calendar\Models\Schedule
|
||||
* @group module
|
||||
*/
|
||||
public function testInvalidFreqInterval() : void
|
||||
{
|
||||
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
|
||||
$this->schedule->setFreqInterval(999);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Calendar\Models\Schedule
|
||||
* @group module
|
||||
|
|
@ -111,26 +89,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase
|
|||
$this->schedule->setFreqType(999);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Calendar\Models\Schedule
|
||||
* @group module
|
||||
*/
|
||||
public function testFrequencyRelativeInputOutput() : void
|
||||
{
|
||||
$this->schedule->setFrequencyRelative(FrequencyRelative::LAST);
|
||||
self::assertEquals(FrequencyRelative::LAST, $this->schedule->getFrequencyRelative());
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Calendar\Models\Schedule
|
||||
* @group module
|
||||
*/
|
||||
public function testInvalidFrequencyRelative() : void
|
||||
{
|
||||
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
|
||||
$this->schedule->setFrequencyRelative(999);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers Modules\Calendar\Models\Schedule
|
||||
* @group module
|
||||
|
|
@ -159,8 +117,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase
|
|||
{
|
||||
$this->schedule->setStatus(ScheduleStatus::INACTIVE);
|
||||
$this->schedule->setFreqType(FrequencyType::YEARLY);
|
||||
$this->schedule->setFreqInterval(FrequencyInterval::DAY);
|
||||
$this->schedule->setFrequencyRelative(FrequencyRelative::LAST);
|
||||
$this->schedule->setIntervalType(IntervalType::RELATIVE);
|
||||
|
||||
$serialized = $this->schedule->jsonSerialize();
|
||||
|
|
@ -173,10 +129,6 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase
|
|||
'uuid' => '',
|
||||
'status' => ScheduleStatus::INACTIVE,
|
||||
'freqType' => FrequencyType::YEARLY,
|
||||
'freqInterval' => FrequencyInterval::DAY,
|
||||
'relativeInternal' => FrequencyRelative::LAST,
|
||||
'intervalType' => IntervalType::RELATIVE,
|
||||
'recurrenceFactor' => 0,
|
||||
],
|
||||
$serialized
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user