93 lines
2.3 KiB
PHP
Raw Normal View History

2018-10-31 15:19:24 +01:00
<?php
namespace tests\unit\Entity;
2018-10-31 15:19:24 +01:00
use PHPUnit\Framework\TestCase;
use App\DBAL\Types\RightType;
use App\Entity\Meta\RightInterface;
use App\Entity\Meta\Right;
use App\Entity\Meta\Law;
use App\DBAL\Types\LayerType;
use App\Exception\NoValidChoice;
2018-10-31 15:19:24 +01:00
/**
* @todo Implement reciever test
*
* @author kevinfrantz
*/
class RightTest extends TestCase
{
/**
* @var RightInterface
*/
private $right;
2018-10-31 15:19:24 +01:00
public function setUp(): void
{
$this->right = new Right();
}
2018-11-06 20:56:54 +01:00
public function testConstructorGeneral(): void
2018-10-31 15:19:24 +01:00
{
2018-11-06 22:27:06 +01:00
$this->assertTrue($this->right->getGrant());
$this->assertEquals(0, $this->right->getPriority());
2018-11-06 22:42:24 +01:00
}
2018-12-14 10:10:28 +01:00
public function testConstructorReciever(): void
{
$this->expectException(\TypeError::class);
$this->right->getReciever();
}
2018-11-06 22:42:24 +01:00
public function testConstructorLayer(): void
{
$this->expectException(\TypeError::class);
$this->assertNull($this->right->getLayer());
}
public function testConstructorLaw(): void
{
2018-10-31 15:19:24 +01:00
$this->expectException(\TypeError::class);
$this->assertNull($this->right->getLaw());
2018-11-06 20:56:54 +01:00
}
2018-11-06 22:42:24 +01:00
public function testConstructorCondition(): void
2018-11-06 20:56:54 +01:00
{
$this->expectException(\TypeError::class);
$this->right->getCondition();
}
public function testConstructorType(): void
{
2018-11-04 15:51:16 +01:00
$this->expectException(\TypeError::class);
2018-10-31 15:19:24 +01:00
$this->assertNull($this->right->getType());
}
public function testLaw(): void
{
$law = new Law();
$this->assertNull($this->right->setLaw($law));
$this->assertEquals($law, $this->right->getLaw());
}
public function testRight(): void
{
foreach (RightType::getChoices() as $key => $value) {
$this->assertNull($this->right->setType($key));
$this->assertEquals($key, $this->right->getType());
}
$this->expectException(NoValidChoice::class);
$this->right->setType('NoneValidType');
}
public function testLayer(): void
{
foreach (LayerType::getChoices() as $key => $value) {
$this->assertNull($this->right->setLayer($key));
$this->assertEquals($key, $this->right->getLayer());
}
$this->expectException(NoValidChoice::class);
$this->right->setLayer('NoneValidLayer');
2018-10-31 15:19:24 +01:00
}
}