From f2868d925960bfd8396fd11a16003ead670fb211 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 4 Nov 2018 12:06:44 +0100 Subject: [PATCH] Optimized unit tests for new data structure --- application/src/Entity/Source/Data/NameSource.php | 1 - .../Entity/Source/{ => Data}/NameSourceTest.php | 13 +++++++++---- application/tests/Unit/Entity/UserTest.php | 2 +- 3 files changed, 10 insertions(+), 6 deletions(-) rename application/tests/Unit/Entity/Source/{ => Data}/NameSourceTest.php (57%) diff --git a/application/src/Entity/Source/Data/NameSource.php b/application/src/Entity/Source/Data/NameSource.php index d29c2e8..2c2381e 100644 --- a/application/src/Entity/Source/Data/NameSource.php +++ b/application/src/Entity/Source/Data/NameSource.php @@ -26,6 +26,5 @@ final class NameSource extends AbstractDataSource implements NameSourceInterface public function __construct() { parent::__construct(); - $this->name = ''; } } diff --git a/application/tests/Unit/Entity/Source/NameSourceTest.php b/application/tests/Unit/Entity/Source/Data/NameSourceTest.php similarity index 57% rename from application/tests/Unit/Entity/Source/NameSourceTest.php rename to application/tests/Unit/Entity/Source/Data/NameSourceTest.php index 9f882c7..e0b7d2c 100644 --- a/application/tests/Unit/Entity/Source/NameSourceTest.php +++ b/application/tests/Unit/Entity/Source/Data/NameSourceTest.php @@ -1,10 +1,10 @@ nameSource = new NameSource(); } + public function testConstructor():void{ + $this->assertInstanceOf(NameSourceInterface::class, $this->nameSource); + $this->expectException(\TypeError::class); + $this->nameSource->getName(); + } + public function testName(): void { - $this->assertEquals('', $this->nameSource->getName()); $name = 'Hello World!'; $this->nameSource->setName($name); $this->assertEquals($name, $this->nameSource->getName()); diff --git a/application/tests/Unit/Entity/UserTest.php b/application/tests/Unit/Entity/UserTest.php index 7086725..ca64f70 100644 --- a/application/tests/Unit/Entity/UserTest.php +++ b/application/tests/Unit/Entity/UserTest.php @@ -4,7 +4,7 @@ namespace tests\unit\Entity; use PHPUnit\Framework\TestCase; use App\Entity\User; -use App\Entity\Source\UserSource; +use App\Entity\Source\Data\UserSource; use App\Entity\UserInterface; /**