2022-07-05 14:08:14 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
2023-11-09 10:27:43 +01:00
|
|
|
namespace WerkraumMedia\Events\Tests\Unit\Domain\Model;
|
2022-07-05 14:08:14 +02:00
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
2023-11-09 10:27:43 +01:00
|
|
|
use WerkraumMedia\Events\Domain\Model\Category;
|
|
|
|
use WerkraumMedia\Events\Domain\Model\Event;
|
2022-07-05 14:08:14 +02:00
|
|
|
|
|
|
|
/**
|
2023-11-09 10:27:43 +01:00
|
|
|
* @covers \WerkraumMedia\Events\Domain\Model\Event
|
2022-07-05 14:08:14 +02:00
|
|
|
*/
|
|
|
|
class EventTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function canBeCreated(): void
|
|
|
|
{
|
|
|
|
$subject = new Event();
|
|
|
|
|
|
|
|
self::assertInstanceOf(
|
|
|
|
Event::class,
|
|
|
|
$subject
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsSortedFeatures(): void
|
|
|
|
{
|
2023-08-14 12:09:28 +02:00
|
|
|
$feature1 = $this->createStub(Category::class);
|
|
|
|
$feature1->method('getSorting')->willReturn(10);
|
|
|
|
$feature2 = $this->createStub(Category::class);
|
|
|
|
$feature2->method('getSorting')->willReturn(5);
|
2022-07-05 14:08:14 +02:00
|
|
|
|
|
|
|
$storage = new ObjectStorage();
|
|
|
|
$storage->attach($feature1);
|
|
|
|
$storage->attach($feature2);
|
|
|
|
|
|
|
|
$subject = new Event();
|
2023-11-06 08:44:03 +01:00
|
|
|
$subject->_setProperty('features', $storage);
|
2022-07-05 14:08:14 +02:00
|
|
|
|
|
|
|
self::assertSame([
|
|
|
|
$feature2,
|
|
|
|
$feature1,
|
|
|
|
], $subject->getFeatures());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
*/
|
|
|
|
public function returnsEmptyFeaturesStorage(): void
|
|
|
|
{
|
|
|
|
$subject = new Event();
|
2023-11-06 08:44:03 +01:00
|
|
|
$subject->_setProperty('features', new ObjectStorage());
|
2022-07-05 14:08:14 +02:00
|
|
|
|
|
|
|
self::assertSame([], $subject->getFeatures());
|
|
|
|
}
|
|
|
|
}
|