mirror of
https://github.com/Karaka-Management/oms-Calendar.git
synced 2026-02-16 08:28:42 +00:00
test fixes
This commit is contained in:
parent
00c343c30a
commit
97f7fb6f91
|
|
@ -193,4 +193,25 @@ class Calendar
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function toArray() : array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'description' => $this->description,
|
||||||
|
'createdAt' => $this->createdAt,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return $this->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -349,4 +349,32 @@ class Event
|
||||||
{
|
{
|
||||||
return $this->tags[$id] ?? new NullTag();
|
return $this->tags[$id] ?? new NullTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function toArray() : array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'name' => $this->name,
|
||||||
|
'description' => $this->description,
|
||||||
|
'type' => $this->type,
|
||||||
|
'status' => $this->status,
|
||||||
|
'schedule' => $this->schedule,
|
||||||
|
'location' => $this->location,
|
||||||
|
'calendar' => $this->calendar,
|
||||||
|
'people' => $this->people,
|
||||||
|
'tags' => $this->tags,
|
||||||
|
'createdAt' => $this->createdAt,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return $this->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -295,4 +295,31 @@ class Schedule
|
||||||
{
|
{
|
||||||
return $this->freqInterval;
|
return $this->freqInterval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function toArray() : array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'id' => $this->id,
|
||||||
|
'uuid' => $this->uid,
|
||||||
|
'status' => $this->status,
|
||||||
|
'freqType' => $this->freqType,
|
||||||
|
'freqInterval' => $this->freqInterval,
|
||||||
|
'relativeInternal' => $this->relativeInternal,
|
||||||
|
'intervalType' => $this->intervalType,
|
||||||
|
'recurrenceFactor' => $this->recurrenceFactor,
|
||||||
|
'start' => $this->start,
|
||||||
|
'createdAt' => $this->createdAt,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritdoc}
|
||||||
|
*/
|
||||||
|
public function jsonSerialize()
|
||||||
|
{
|
||||||
|
return $this->toArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -138,4 +138,26 @@ final class CalendarTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertEquals([], $this->calendar->getEventsOnDate(new \DateTime('2005-10-10')));
|
self::assertEquals([], $this->calendar->getEventsOnDate(new \DateTime('2005-10-10')));
|
||||||
self::assertEquals([$event], $this->calendar->getEventsOnDate(new \DateTime('2005-10-09')));
|
self::assertEquals([$event], $this->calendar->getEventsOnDate(new \DateTime('2005-10-09')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Modules\Calendar\Models\Calendar
|
||||||
|
* @group module
|
||||||
|
*/
|
||||||
|
public function testSerialize() : void
|
||||||
|
{
|
||||||
|
$this->calendar->name = 'Name';
|
||||||
|
$this->calendar->description = 'Description';
|
||||||
|
|
||||||
|
$serialized = $this->calendar->jsonSerialize();
|
||||||
|
unset($serialized['createdAt']);
|
||||||
|
|
||||||
|
self::assertEquals(
|
||||||
|
[
|
||||||
|
'id' => 0,
|
||||||
|
'name' => 'Name',
|
||||||
|
'description' => 'Description',
|
||||||
|
],
|
||||||
|
$serialized
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -166,4 +166,35 @@ final class EventTest extends \PHPUnit\Framework\TestCase
|
||||||
self::assertCount(0, $this->event->getTags());
|
self::assertCount(0, $this->event->getTags());
|
||||||
self::assertFalse($this->event->removeTag(0));
|
self::assertFalse($this->event->removeTag(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Modules\Calendar\Models\Event
|
||||||
|
* @group module
|
||||||
|
*/
|
||||||
|
public function testSerialize() : void
|
||||||
|
{
|
||||||
|
$this->event->name = 'Name';
|
||||||
|
$this->event->description = 'Description';
|
||||||
|
$this->event->setType(EventType::TEMPLATE);
|
||||||
|
$this->event->setStatus(EventStatus::INACTIVE);
|
||||||
|
|
||||||
|
$serialized = $this->event->jsonSerialize();
|
||||||
|
unset($serialized['location']);
|
||||||
|
unset($serialized['schedule']);
|
||||||
|
unset($serialized['createdAt']);
|
||||||
|
|
||||||
|
self::assertEquals(
|
||||||
|
[
|
||||||
|
'id' => 0,
|
||||||
|
'name' => 'Name',
|
||||||
|
'description' => 'Description',
|
||||||
|
'type' => EventType::TEMPLATE,
|
||||||
|
'status' => EventStatus::INACTIVE,
|
||||||
|
'calendar' => 0,
|
||||||
|
'people' => [],
|
||||||
|
'tags' => [],
|
||||||
|
],
|
||||||
|
$serialized
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -152,4 +152,35 @@ final class ScheduleTest extends \PHPUnit\Framework\TestCase
|
||||||
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
|
$this->expectException(\phpOMS\Stdlib\Base\Exception\InvalidEnumValue::class);
|
||||||
$this->schedule->setIntervalType(999);
|
$this->schedule->setIntervalType(999);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @covers Modules\Calendar\Models\Schedule
|
||||||
|
* @group module
|
||||||
|
*/
|
||||||
|
public function testSerialize() : void
|
||||||
|
{
|
||||||
|
$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();
|
||||||
|
unset($serialized['start']);
|
||||||
|
unset($serialized['createdAt']);
|
||||||
|
|
||||||
|
self::assertEquals(
|
||||||
|
[
|
||||||
|
'id' => 0,
|
||||||
|
'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