From 342a07ee28a0acff67cacec30aaef71b31d8b410 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Wed, 31 Oct 2018 14:10:20 +0100 Subject: [PATCH] Implemented test for Entity --- application/src/Entity/AbstractEntity.php | 1 - application/src/Entity/Meta/Relation.php | 1 - .../tests/unit/Entity/AbstractEntityTest.php | 40 +++++++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 application/tests/unit/Entity/AbstractEntityTest.php diff --git a/application/src/Entity/AbstractEntity.php b/application/src/Entity/AbstractEntity.php index 7a5f7fd..9590092 100644 --- a/application/src/Entity/AbstractEntity.php +++ b/application/src/Entity/AbstractEntity.php @@ -31,6 +31,5 @@ abstract class AbstractEntity implements EntityInterface public function __construct() { - // $this->id = 0; } } diff --git a/application/src/Entity/Meta/Relation.php b/application/src/Entity/Meta/Relation.php index 6177050..1d4e626 100644 --- a/application/src/Entity/Meta/Relation.php +++ b/application/src/Entity/Meta/Relation.php @@ -81,6 +81,5 @@ final class Relation extends AbstractMeta implements RelationInterface $this->law = new Law(); $this->parents = new ArrayCollection(); $this->childs = new ArrayCollection(); - //$this->law->setNode($this); } } diff --git a/application/tests/unit/Entity/AbstractEntityTest.php b/application/tests/unit/Entity/AbstractEntityTest.php new file mode 100644 index 0000000..41b0fe0 --- /dev/null +++ b/application/tests/unit/Entity/AbstractEntityTest.php @@ -0,0 +1,40 @@ +entity = new class() extends AbstractEntity { + }; + } + + public function testConstructor(): void + { + $this->expectException(\TypeError::class); + $this->entity->getId(); + $this->entity->getVersion(); + } + + public function testVersion(): void + { + $version = 123; + $this->assertNull($this->entity->setVersion($version)); + $this->assertEquals($version, $this->entity->getVersion()); + } + + public function testId(): void + { + $id = 123; + $this->assertNull($this->entity->setId($id)); + $this->assertEquals($id, $this->entity->getId()); + } +}