From b13ca3795906e5a2c50b63e7f0a8a8032f7624fb Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Tue, 6 Nov 2018 22:42:24 +0100 Subject: [PATCH] Implemented tests for LayerType --- application/src/DBAL/Types/LayerType.php | 4 +- .../Entity/Attribut/LayerAttributTest.php | 41 +++++++++++++++++++ .../tests/Unit/Entity/Meta/RightTest.php | 12 +++++- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 application/tests/Unit/Entity/Attribut/LayerAttributTest.php diff --git a/application/src/DBAL/Types/LayerType.php b/application/src/DBAL/Types/LayerType.php index 0c458dc..4ccc7da 100644 --- a/application/src/DBAL/Types/LayerType.php +++ b/application/src/DBAL/Types/LayerType.php @@ -9,14 +9,14 @@ use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType; */ final class LayerType extends AbstractEnumType { - public const NODE = 'node'; + public const RELATION = 'relation'; public const SOURCE = 'source'; public const LAW = 'law'; protected static $choices = [ - self::NODE => 'node', + self::RELATION => 'relation', self::LAW => 'law', self::SOURCE => 'source', ]; diff --git a/application/tests/Unit/Entity/Attribut/LayerAttributTest.php b/application/tests/Unit/Entity/Attribut/LayerAttributTest.php new file mode 100644 index 0000000..df375c4 --- /dev/null +++ b/application/tests/Unit/Entity/Attribut/LayerAttributTest.php @@ -0,0 +1,41 @@ +layer = new class() implements LayerAttributInterface { + use LayerAttribut; + }; + } + + public function testConstruct(): void + { + $this->expectException(\TypeError::class); + $this->layer->getLayer(); + } + + public function testAccessors(): void + { + foreach ([ + LayerType::LAW, + LayerType::RELATION, + LayerType::SOURCE, + ] as $value) { + $this->assertNull($this->layer->setLayer($value)); + $this->assertEquals($value, $this->layer->getLayer()); + } + } +} diff --git a/application/tests/Unit/Entity/Meta/RightTest.php b/application/tests/Unit/Entity/Meta/RightTest.php index 982e7f3..c2182d6 100644 --- a/application/tests/Unit/Entity/Meta/RightTest.php +++ b/application/tests/Unit/Entity/Meta/RightTest.php @@ -29,11 +29,21 @@ class RightTest extends TestCase { $this->assertEquals($this->right, $this->right->getReciever()->getRight()); $this->assertTrue($this->right->getGrant()); + } + + public function testConstructorLayer(): void + { + $this->expectException(\TypeError::class); + $this->assertNull($this->right->getLayer()); + } + + public function testConstructorLaw(): void + { $this->expectException(\TypeError::class); $this->assertNull($this->right->getLaw()); } - public function testConstructorCondition() + public function testConstructorCondition(): void { $this->expectException(\TypeError::class); $this->right->getCondition();