mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 05:47:11 +02:00
Optimized CrudAttribut logic
This commit is contained in:
@@ -5,6 +5,8 @@ namespace Tests\Unit\Entity\Attribut;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\CrudAttributInterface;
|
||||
use App\Entity\Attribut\CrudAttribut;
|
||||
use App\DBAL\Types\Meta\Right\CRUDType;
|
||||
use App\Exception\NoValidChoiceException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@@ -14,11 +16,11 @@ class CrudAttributTest extends TestCase
|
||||
/**
|
||||
* @var CrudAttributInterface
|
||||
*/
|
||||
protected $typeAttribut;
|
||||
protected $crudAttribut;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->typeAttribut = new class() implements CrudAttributInterface {
|
||||
$this->crudAttribut = new class() implements CrudAttributInterface {
|
||||
use CrudAttribut;
|
||||
};
|
||||
}
|
||||
@@ -26,13 +28,16 @@ class CrudAttributTest extends TestCase
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->typeAttribut->getCrud();
|
||||
$this->crudAttribut->getCrud();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$type = 'Hello World!';
|
||||
$this->assertNull($this->typeAttribut->setCrud($type));
|
||||
$this->assertEquals($type, $this->typeAttribut->getCrud());
|
||||
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');
|
||||
}
|
||||
}
|
@@ -73,9 +73,9 @@ class RightTest extends TestCase
|
||||
|
||||
public function testRight(): void
|
||||
{
|
||||
foreach (CRUDType::getChoices() as $key => $value) {
|
||||
$this->assertNull($this->right->setCrud($key));
|
||||
$this->assertEquals($key, $this->right->getCrud());
|
||||
foreach (CRUDType::getChoices() as $enum) {
|
||||
$this->assertNull($this->right->setCrud($enum));
|
||||
$this->assertEquals($enum, $this->right->getCrud());
|
||||
}
|
||||
$this->expectException(NoValidChoiceException::class);
|
||||
$this->right->setCrud('NoneValidType');
|
||||
|
Reference in New Issue
Block a user