2018-12-29 23:23:06 +01:00
|
|
|
<?php
|
|
|
|
|
2019-01-20 10:41:58 +01:00
|
|
|
namespace Tests\Unit\Attribut;
|
2018-12-29 23:23:06 +01:00
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2019-02-17 14:33:19 +01:00
|
|
|
use Infinito\Attribut\CrudAttributInterface;
|
|
|
|
use Infinito\Attribut\CrudAttribut;
|
|
|
|
use Infinito\DBAL\Types\Meta\Right\CRUDType;
|
|
|
|
use Infinito\Exception\NoValidChoiceException;
|
2018-12-29 23:23:06 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @author kevinfrantz
|
|
|
|
*/
|
2019-01-16 21:22:18 +01:00
|
|
|
class CrudAttributTest extends TestCase
|
2018-12-29 23:23:06 +01:00
|
|
|
{
|
|
|
|
/**
|
2019-01-16 21:22:18 +01:00
|
|
|
* @var CrudAttributInterface
|
2018-12-29 23:23:06 +01:00
|
|
|
*/
|
2019-01-16 21:36:05 +01:00
|
|
|
protected $crudAttribut;
|
2018-12-29 23:23:06 +01:00
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
2019-01-16 21:36:05 +01:00
|
|
|
$this->crudAttribut = new class() implements CrudAttributInterface {
|
2019-01-16 21:22:18 +01:00
|
|
|
use CrudAttribut;
|
2018-12-29 23:23:06 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testConstructor(): void
|
|
|
|
{
|
|
|
|
$this->expectException(\TypeError::class);
|
2019-01-16 21:36:05 +01:00
|
|
|
$this->crudAttribut->getCrud();
|
2018-12-29 23:23:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testAccessors(): void
|
|
|
|
{
|
2019-01-16 21:36:05 +01:00
|
|
|
foreach (CRUDType::getChoices() as $enum) {
|
|
|
|
$this->assertNull($this->crudAttribut->setCrud($enum));
|
|
|
|
$this->assertEquals($enum, $this->crudAttribut->getCrud());
|
|
|
|
}
|
|
|
|
$this->expectException(NoValidChoiceException::class);
|
|
|
|
$this->crudAttribut->setCrud('NoneValidType');
|
2018-12-29 23:23:06 +01:00
|
|
|
}
|
|
|
|
}
|