infinito/application/symfony/tests/Unit/Attribut/CrudAttributTest.php

44 lines
1.0 KiB
PHP
Raw Normal View History

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-01-20 10:41:58 +01:00
use App\Attribut\CrudAttributInterface;
use App\Attribut\CrudAttribut;
2019-01-16 21:36:05 +01:00
use App\DBAL\Types\Meta\Right\CRUDType;
use App\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
}
}