infinito/application/tests/Unit/Entity/Source/AbstractSourceTest.php

51 lines
1.5 KiB
PHP
Raw Normal View History

<?php
2018-10-29 19:01:00 +01:00
namespace tests\unit\Entity\Source;
use PHPUnit\Framework\TestCase;
use App\Entity\Source\SourceInterface;
use App\Entity\Meta\LawInterface;
use Doctrine\Common\Collections\Collection;
2018-10-28 22:43:35 +01:00
use App\Entity\Source\AbstractSource;
use App\Entity\EntityInterface;
2018-11-25 23:47:42 +01:00
use App\Entity\Meta\Relation\Parent\CreatorRelationInterface;
/**
* @author kevinfrantz
*/
class AbstractSourceTest extends TestCase
{
/**
* @var SourceInterface
*/
protected $source;
2018-10-29 19:01:00 +01:00
2018-11-24 21:21:59 +01:00
private function getSourceDummy(): SourceInterface
2018-10-29 19:01:00 +01:00
{
2018-11-24 21:21:59 +01:00
return new class() extends AbstractSource {
2018-10-29 19:01:00 +01:00
};
}
2018-10-29 19:01:00 +01:00
2018-11-24 21:21:59 +01:00
public function setUp()
{
$this->source = $this->getSourceDummy();
}
public function testConstructor(): void
{
$this->assertInstanceOf(EntityInterface::class, $this->source);
2018-11-25 23:12:42 +01:00
$this->assertInstanceOf(CreatorRelationInterface::class, $this->source->getCreatorRelation());
$this->assertEquals($this->source, $this->source->getCreatorRelation()->getSource());
2018-11-26 22:36:08 +01:00
$this->assertInstanceOf(Collection::class, $this->source->getMemberRelation()->getMemberships());
2018-10-29 19:01:00 +01:00
$this->assertInstanceOf(LawInterface::class, $this->source->getLaw());
2018-11-25 23:12:42 +01:00
$this->assertEquals($this->source, $this->source->getLaw()->getSource());
2018-11-26 22:36:08 +01:00
$this->assertInstanceOf(Collection::class, $this->source->getMemberRelation()->getMembers());
}
2018-11-23 18:17:00 +01:00
public function testSlugInit(): void
{
$this->expectException(\TypeError::class);
$this->source->getSlug();
}
2018-11-01 22:34:26 +01:00
}