From 67e389d2fbbff37a3779b8d14a426f589376c0d8 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 13 Jan 2019 20:18:52 +0100 Subject: [PATCH] Added tests for has- functions --- .../symfony/tests/Unit/Entity/Attribut/IdAttributTest.php | 7 +++++++ .../tests/Unit/Entity/Attribut/SlugAttributTest.php | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/application/symfony/tests/Unit/Entity/Attribut/IdAttributTest.php b/application/symfony/tests/Unit/Entity/Attribut/IdAttributTest.php index 69709aa..2cd7a0b 100644 --- a/application/symfony/tests/Unit/Entity/Attribut/IdAttributTest.php +++ b/application/symfony/tests/Unit/Entity/Attribut/IdAttributTest.php @@ -6,6 +6,9 @@ use PHPUnit\Framework\TestCase; use App\Entity\Attribut\IdAttribut; use App\Entity\Attribut\IdAttributInterface; +/** + * @author kevinfrantz + */ class IdAttributTest extends TestCase { /** @@ -22,6 +25,7 @@ class IdAttributTest extends TestCase public function testConstruct(): void { + $this->assertFalse($this->id->hasId()); $this->expectException(\TypeError::class); $this->id->getId(); } @@ -31,5 +35,8 @@ class IdAttributTest extends TestCase $id = 1234; $this->assertNull($this->id->setId($id)); $this->assertEquals($id, $this->id->getId()); + $this->assertTrue($this->id->hasId()); + $this->assertNull($this->id->setId(0)); + $this->assertTrue($this->id->hasId()); } } diff --git a/application/symfony/tests/Unit/Entity/Attribut/SlugAttributTest.php b/application/symfony/tests/Unit/Entity/Attribut/SlugAttributTest.php index 072fbc1..b96d690 100644 --- a/application/symfony/tests/Unit/Entity/Attribut/SlugAttributTest.php +++ b/application/symfony/tests/Unit/Entity/Attribut/SlugAttributTest.php @@ -25,6 +25,7 @@ class SlugAttributTest extends TestCase public function testConstructor(): void { + $this->assertFalse($this->slugAttribut->hasSlug()); $this->expectException(\TypeError::class); $this->slugAttribut->getSlug(); } @@ -33,6 +34,9 @@ class SlugAttributTest extends TestCase { $slug = 'goodslug'; $this->assertNull($this->slugAttribut->setSlug($slug)); + $this->assertTrue($this->slugAttribut->hasSlug()); $this->assertEquals($slug, $this->slugAttribut->getSlug()); + $this->assertNull($this->slugAttribut->setSlug('')); + $this->assertTrue($this->slugAttribut->hasSlug()); } }