From c1b073eba8b535b8587745a1b4484304e59dd075 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sat, 10 Nov 2018 12:30:59 +0100 Subject: [PATCH] Continued the integration of person identity --- .../Attribut/FullPersonNameSourceAttribut.php | 23 +++++++++++ .../FullPersonNameSourceAttributInterface.php | 12 ++++++ .../Attribut/PersonIdentityAttribut.php | 23 +++++++++++ .../PersonIdentitySourceAttributInterface.php | 12 ++++++ .../Combination/AbstractCombinationSource.php | 5 ++- .../CombinationSourceInterface.php | 2 +- .../FullPersonNameSourceInterface.php | 21 +++++----- .../Source/Combination/IdentitySource.php | 8 ---- ....php => PersonIdentitySourceInterface.php} | 3 +- .../Combination/PesonIdentitySource.php | 16 ++++++++ .../Entity/Source/Combination/UserSource.php | 16 +------- .../Combination/UserSourceInterface.php | 4 +- .../Source/Data/Name/AbstractNameSource.php | 2 +- .../Data/Name/FirstNameSourceInterface.php | 2 +- .../Source/Data/Name/NameSourceInterface.php | 3 +- .../Source/Data/Name/NicknameSource.php | 1 + .../Data/Name/SurnameSourceInterface.php | 2 +- .../FullPersonNameSourceAttributTest.php | 39 ++++++++++++++++++ .../PersonIdentitySourceAttributTest.php | 41 +++++++++++++++++++ .../{Data => Combination}/UserSourceTest.php | 6 +-- .../Entity/Source/Data/IdentitySourceTest.php | 17 ++++---- 21 files changed, 206 insertions(+), 52 deletions(-) create mode 100644 application/src/Entity/Attribut/FullPersonNameSourceAttribut.php create mode 100644 application/src/Entity/Attribut/FullPersonNameSourceAttributInterface.php create mode 100644 application/src/Entity/Attribut/PersonIdentityAttribut.php create mode 100644 application/src/Entity/Attribut/PersonIdentitySourceAttributInterface.php delete mode 100644 application/src/Entity/Source/Combination/IdentitySource.php rename application/src/Entity/Source/Combination/{IdentityInterface.php => PersonIdentitySourceInterface.php} (50%) create mode 100644 application/src/Entity/Source/Combination/PesonIdentitySource.php create mode 100644 application/tests/Unit/Entity/Attribut/FullPersonNameSourceAttributTest.php create mode 100644 application/tests/Unit/Entity/Attribut/PersonIdentitySourceAttributTest.php rename application/tests/Unit/Entity/Source/{Data => Combination}/UserSourceTest.php (73%) diff --git a/application/src/Entity/Attribut/FullPersonNameSourceAttribut.php b/application/src/Entity/Attribut/FullPersonNameSourceAttribut.php new file mode 100644 index 0000000..5a8aff6 --- /dev/null +++ b/application/src/Entity/Attribut/FullPersonNameSourceAttribut.php @@ -0,0 +1,23 @@ +fullPersonNameSource; + } + + public function setFullPersonNameSource(FullPersonNameSourceInterface $fullname): void + { + $this->fullPersonNameSource = $fullname; + } +} diff --git a/application/src/Entity/Attribut/FullPersonNameSourceAttributInterface.php b/application/src/Entity/Attribut/FullPersonNameSourceAttributInterface.php new file mode 100644 index 0000000..74f9675 --- /dev/null +++ b/application/src/Entity/Attribut/FullPersonNameSourceAttributInterface.php @@ -0,0 +1,12 @@ +personIdentitySource; + } + + public function setPersonIdentitySource(PersonIdentitySourceInterface $identity): void + { + $this->personIdentitySource = $identity; + } +} diff --git a/application/src/Entity/Attribut/PersonIdentitySourceAttributInterface.php b/application/src/Entity/Attribut/PersonIdentitySourceAttributInterface.php new file mode 100644 index 0000000..2039a6f --- /dev/null +++ b/application/src/Entity/Attribut/PersonIdentitySourceAttributInterface.php @@ -0,0 +1,12 @@ +nameSource = new NameSource(); parent::__construct(); } } diff --git a/application/src/Entity/Source/Combination/UserSourceInterface.php b/application/src/Entity/Source/Combination/UserSourceInterface.php index 6d3e157..22808c6 100644 --- a/application/src/Entity/Source/Combination/UserSourceInterface.php +++ b/application/src/Entity/Source/Combination/UserSourceInterface.php @@ -3,11 +3,11 @@ namespace App\Entity\Source\Data; use App\Entity\Attribut\UserAttributInterface; -use App\Entity\Attribut\NameSourceAttributInterface; +use App\Entity\Attribut\PersonIdentitySourceAttributInterface; /** * @author kevinfrantz */ -interface UserSourceInterface extends DataSourceInterface, UserAttributInterface, NameSourceAttributInterface +interface UserSourceInterface extends DataSourceInterface, UserAttributInterface, PersonIdentitySourceAttributInterface { } diff --git a/application/src/Entity/Source/Data/Name/AbstractNameSource.php b/application/src/Entity/Source/Data/Name/AbstractNameSource.php index 864bfc2..c851230 100644 --- a/application/src/Entity/Source/Data/Name/AbstractNameSource.php +++ b/application/src/Entity/Source/Data/Name/AbstractNameSource.php @@ -1,4 +1,5 @@ fullname = new class() implements FullPersonNameSourceAttributInterface { + use FullPersonNameSourceAttribut; + }; + } + + public function testConstructor(): void + { + $this->expectException(\TypeError::class); + $this->fullname->getFullPersonNameSource(); + } + + public function testAccessors(): void + { + $fullname = $this->createMock(FullPersonNameSourceInterface::class); + $this->assertNull($this->fullname->setFullPersonNameSource($fullname)); + $this->assertEquals($collection, $this->fullname->getFullPersonNameSource()); + } +} diff --git a/application/tests/Unit/Entity/Attribut/PersonIdentitySourceAttributTest.php b/application/tests/Unit/Entity/Attribut/PersonIdentitySourceAttributTest.php new file mode 100644 index 0000000..5a7a003 --- /dev/null +++ b/application/tests/Unit/Entity/Attribut/PersonIdentitySourceAttributTest.php @@ -0,0 +1,41 @@ +identity = new class() implements PersonIdentitySourceAttributInterface { + use PersonIdentityAttribut; + }; + } + + public function testConstructor(): void + { + $this->expectException(\TypeError::class); + $this->identity->getIdentitySource(); + } + + public function testAccessors(): void + { + $identity = $this->createMock(PersonIdentitySourceInterface::class); + $this->assertNull($this->identity->setIdentitySource($identity)); + $this->assertEquals($collection, $this->identity->getIdentitySource()); + } +} diff --git a/application/tests/Unit/Entity/Source/Data/UserSourceTest.php b/application/tests/Unit/Entity/Source/Combination/UserSourceTest.php similarity index 73% rename from application/tests/Unit/Entity/Source/Data/UserSourceTest.php rename to application/tests/Unit/Entity/Source/Combination/UserSourceTest.php index 4acd747..9c87583 100644 --- a/application/tests/Unit/Entity/Source/Data/UserSourceTest.php +++ b/application/tests/Unit/Entity/Source/Combination/UserSourceTest.php @@ -1,12 +1,12 @@ assertInstanceOf(Collection::class, $this->userSource->getMemberships()); - $this->assertInstanceOf(NameSourceInterface::class, $this->userSource->getNameSource()); + $this->assertInstanceOf(PersonIdentitySourceInterface::class, $this->userSource->getIdentitySource()); $this->expectException(\TypeError::class); $this->userSource->getUser(); } diff --git a/application/tests/Unit/Entity/Source/Data/IdentitySourceTest.php b/application/tests/Unit/Entity/Source/Data/IdentitySourceTest.php index 04dd4f3..3b7a460 100644 --- a/application/tests/Unit/Entity/Source/Data/IdentitySourceTest.php +++ b/application/tests/Unit/Entity/Source/Data/IdentitySourceTest.php @@ -1,4 +1,5 @@ identity = new IdentitySource(); } - - public function testConstructor():void{ + + public function testConstructor(): void + { $this->assertInstanceOf(FullPersonNameSourceInterface::class, $this->identity->getName()); } - - public function testName():void{ + + public function testName(): void + { $name = $this->createMock(FullPersonNameSourceInterface::class); $this->assertNull($this->identity->setName($name)); $this->assertEquals($name, $this->identity->getName()); } } -