mirror of
https://github.com/werkraum-media/events.git
synced 2024-11-23 01:16:10 +01:00
Daniel Siepmann
3d0d5d8645
A new PSR-14 event is added that allows to modify the event right before it is persisted within Destination Data One import. This for example allows to alter dates, prices, etc. Improve handling of missing end time in dates.
139 lines
3 KiB
PHP
139 lines
3 KiB
PHP
<?php
|
|
|
|
namespace Wrm\Events\Tests\Unit\Domain\Model;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Wrm\Events\Domain\Model\Date;
|
|
|
|
/**
|
|
* @covers \Wrm\Events\Domain\Model\Date
|
|
*/
|
|
class DateTest extends TestCase
|
|
{
|
|
/**
|
|
* @test
|
|
*/
|
|
public function canBeCreated(): void
|
|
{
|
|
$subject = new Date();
|
|
|
|
self::assertInstanceOf(
|
|
Date::class,
|
|
$subject
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsThatItHasUsefulStartTime(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setStart(new \DateTime('2022-07-11T13:48:00'));
|
|
|
|
self::assertTrue($subject->getHasUsefulStartTime());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsThatItDoesNotHaveUsefulStartTime(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setStart(new \DateTime('2022-07-11T00:00:00'));
|
|
|
|
self::assertFalse($subject->getHasUsefulStartTime());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsThatItHasUsefulEndTime(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setEnd(new \DateTime('2022-07-11T00:00:00'));
|
|
|
|
self::assertTrue($subject->getHasUsefulEndTime());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsThatItDoesNotHaveUsefulEndTimeWithTime(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setEnd(new \DateTime('2022-07-11T23:59:00'));
|
|
|
|
self::assertFalse($subject->getHasUsefulEndTime());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsThatItDoesNotHaveUsefulEndTimeWithNull(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setEnd(null);
|
|
|
|
self::assertFalse($subject->getHasUsefulEndTime());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsThatItEndsOnSameDay(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setStart(new \DateTime('2022-07-11T14:00:00'));
|
|
$subject->setEnd(new \DateTime('2022-07-11T22:00:00'));
|
|
|
|
self::assertTrue($subject->getEndsOnSameDay());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsThatItDoesNotEndOnSameDayWithDifferentDates(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setStart(new \DateTime('2022-07-11T14:00:00'));
|
|
$subject->setEnd(new \DateTime('2022-07-13T22:00:00'));
|
|
|
|
self::assertFalse($subject->getEndsOnSameDay());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsThatItDoesNotEndOnSameDayWithMissingEnd(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setStart(new \DateTime('2022-07-11T14:00:00'));
|
|
$subject->setEnd(null);
|
|
|
|
self::assertFalse($subject->getEndsOnSameDay());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsNullAsEnd(): void
|
|
{
|
|
$subject = new Date();
|
|
$subject->setEnd(null);
|
|
|
|
self::assertNull($subject->getEnd());
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
*/
|
|
public function returnsEnd(): void
|
|
{
|
|
$end = new \DateTime('2022-07-13T22:00:00');
|
|
$subject = new Date();
|
|
$subject->setEnd($end);
|
|
|
|
self::assertSame($end, $subject->getEnd());
|
|
}
|
|
}
|