Added tests for has- functions

This commit is contained in:
Kevin Frantz 2019-01-13 20:18:52 +01:00
parent 84b6b96ae3
commit 67e389d2fb
2 changed files with 11 additions and 0 deletions

View File

@ -6,6 +6,9 @@ use PHPUnit\Framework\TestCase;
use App\Entity\Attribut\IdAttribut; use App\Entity\Attribut\IdAttribut;
use App\Entity\Attribut\IdAttributInterface; use App\Entity\Attribut\IdAttributInterface;
/**
* @author kevinfrantz
*/
class IdAttributTest extends TestCase class IdAttributTest extends TestCase
{ {
/** /**
@ -22,6 +25,7 @@ class IdAttributTest extends TestCase
public function testConstruct(): void public function testConstruct(): void
{ {
$this->assertFalse($this->id->hasId());
$this->expectException(\TypeError::class); $this->expectException(\TypeError::class);
$this->id->getId(); $this->id->getId();
} }
@ -31,5 +35,8 @@ class IdAttributTest extends TestCase
$id = 1234; $id = 1234;
$this->assertNull($this->id->setId($id)); $this->assertNull($this->id->setId($id));
$this->assertEquals($id, $this->id->getId()); $this->assertEquals($id, $this->id->getId());
$this->assertTrue($this->id->hasId());
$this->assertNull($this->id->setId(0));
$this->assertTrue($this->id->hasId());
} }
} }

View File

@ -25,6 +25,7 @@ class SlugAttributTest extends TestCase
public function testConstructor(): void public function testConstructor(): void
{ {
$this->assertFalse($this->slugAttribut->hasSlug());
$this->expectException(\TypeError::class); $this->expectException(\TypeError::class);
$this->slugAttribut->getSlug(); $this->slugAttribut->getSlug();
} }
@ -33,6 +34,9 @@ class SlugAttributTest extends TestCase
{ {
$slug = 'goodslug'; $slug = 'goodslug';
$this->assertNull($this->slugAttribut->setSlug($slug)); $this->assertNull($this->slugAttribut->setSlug($slug));
$this->assertTrue($this->slugAttribut->hasSlug());
$this->assertEquals($slug, $this->slugAttribut->getSlug()); $this->assertEquals($slug, $this->slugAttribut->getSlug());
$this->assertNull($this->slugAttribut->setSlug(''));
$this->assertTrue($this->slugAttribut->hasSlug());
} }
} }