mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Continued the integration of person identity
This commit is contained in:
parent
7a6a5e1bcf
commit
c1b073eba8
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
|
use App\Entity\Source\Combination\FullPersonNameSourceInterface;
|
||||||
|
|
||||||
|
trait FullPersonNameSourceAttribut
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var FullPersonNameSourceInterface
|
||||||
|
*/
|
||||||
|
protected $fullPersonNameSource;
|
||||||
|
|
||||||
|
public function getFullPersonNameSource(): FullPersonNameSourceInterface
|
||||||
|
{
|
||||||
|
return $this->fullPersonNameSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFullPersonNameSource(FullPersonNameSourceInterface $fullname): void
|
||||||
|
{
|
||||||
|
$this->fullPersonNameSource = $fullname;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
|
use App\Entity\Source\Combination\FullPersonNameSourceInterface;
|
||||||
|
|
||||||
|
interface FullPersonNameSourceAttributInterface
|
||||||
|
{
|
||||||
|
public function getFullPersonNameSource(): FullPersonNameSourceInterface;
|
||||||
|
|
||||||
|
public function setFullPersonNameSource(FullPersonNameSourceInterface $fullname): void;
|
||||||
|
}
|
23
application/src/Entity/Attribut/PersonIdentityAttribut.php
Normal file
23
application/src/Entity/Attribut/PersonIdentityAttribut.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Entity\Attribut;
|
||||||
|
|
||||||
|
use App\Entity\Source\Data\PersonIdentitySourceInterface;
|
||||||
|
|
||||||
|
trait PersonIdentityAttribut
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var PersonIdentitySourceInterface
|
||||||
|
*/
|
||||||
|
protected $personIdentitySource;
|
||||||
|
|
||||||
|
public function getPersonIdentitySource(): PersonIdentitySourceInterface
|
||||||
|
{
|
||||||
|
return $this->personIdentitySource;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setPersonIdentitySource(PersonIdentitySourceInterface $identity): void
|
||||||
|
{
|
||||||
|
$this->personIdentitySource = $identity;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Attribut;
|
||||||
|
|
||||||
|
use App\Entity\Source\Data\PersonIdentitySourceInterface;
|
||||||
|
|
||||||
|
interface PersonIdentitySourceAttributInterface
|
||||||
|
{
|
||||||
|
public function getPersonIdentitySource(): PersonIdentitySourceInterface;
|
||||||
|
|
||||||
|
public function setPersonIdentitySource(PersonIdentitySourceInterface $identity): void;
|
||||||
|
}
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Combination;
|
namespace App\Entity\Source\Combination;
|
||||||
|
|
||||||
use App\Entity\Source\AbstractSource;
|
use App\Entity\Source\AbstractSource;
|
||||||
|
|
||||||
abstract class AbstractCombinationSource extends AbstractSource implements CombinationSourceInterface
|
abstract class AbstractCombinationSource extends AbstractSource implements CombinationSourceInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Combination;
|
namespace App\Entity\Source\Combination;
|
||||||
|
|
||||||
use App\Entity\Source\Data\DataSourceInterface;
|
use App\Entity\Source\Data\DataSourceInterface;
|
||||||
@ -6,4 +7,3 @@ use App\Entity\Source\Data\DataSourceInterface;
|
|||||||
interface CombinationSourceInterface extends DataSourceInterface
|
interface CombinationSourceInterface extends DataSourceInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Combination;
|
namespace App\Entity\Source\Combination;
|
||||||
|
|
||||||
use App\Entity\Source\Data\Name\FirstNameSourceInterface;
|
use App\Entity\Source\Data\Name\FirstNameSourceInterface;
|
||||||
use App\Entity\Source\Data\Name\SurnameSourceInterface;
|
use App\Entity\Source\Data\Name\SurnameSourceInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Maybe a middle name would be helpfull in the future ;)
|
* @todo Maybe a middle name would be helpfull in the future ;)
|
||||||
* @author kevinfrantz
|
|
||||||
*
|
*
|
||||||
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface FullPersonNameSourceInterface extends CombinationSourceInterface
|
interface FullPersonNameSourceInterface extends CombinationSourceInterface
|
||||||
{
|
{
|
||||||
public function getFirstName():FirstNameSourceInterface;
|
public function getFirstName(): FirstNameSourceInterface;
|
||||||
|
|
||||||
public function setFirstName(FirstNameSourceInterface $name):void;
|
public function setFirstName(FirstNameSourceInterface $name): void;
|
||||||
|
|
||||||
public function getSurname():SurnameSourceInterface;
|
public function getSurname(): SurnameSourceInterface;
|
||||||
|
|
||||||
public function setSurname(SurnameSourceInterface $name):void;
|
public function setSurname(SurnameSourceInterface $name): void;
|
||||||
}
|
}
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
<?php
|
|
||||||
namespace App\Entity\Source\Data;
|
|
||||||
|
|
||||||
class IdentitySource extends AbstractDataSource implements IdentityInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Data;
|
namespace App\Entity\Source\Data;
|
||||||
|
|
||||||
use App\Entity\Attribut\NameAttributInterface;
|
use App\Entity\Attribut\NameAttributInterface;
|
||||||
|
|
||||||
interface IdentityInterface extends DataSourceInterface, NameAttributInterface
|
interface PersonIdentitySourceInterface extends DataSourceInterface, NameAttributInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Entity\Source\Data;
|
||||||
|
|
||||||
|
class PesonIdentitySource extends AbstractDataSource implements PersonIdentitySourceInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @Assert\Type(type="App\Entity\Source\NameSource")
|
||||||
|
* @Assert\Valid()
|
||||||
|
* @ORM\OneToOne(targetEntity="NameSource",cascade={"persist", "remove"})
|
||||||
|
* @ORM\JoinColumn(name="name_id", referencedColumnName="id")
|
||||||
|
*
|
||||||
|
* @var NameSourceInterface
|
||||||
|
*/
|
||||||
|
protected $nameSource;
|
||||||
|
}
|
@ -3,10 +3,9 @@
|
|||||||
namespace App\Entity\Source\Data;
|
namespace App\Entity\Source\Data;
|
||||||
|
|
||||||
use Doctrine\ORM\Mapping as ORM;
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
use App\Entity\Attribut\UserAttribut;
|
use App\Entity\Attribut\UserAttribut;
|
||||||
use App\Entity\Attribut\NameSourceAttribut;
|
|
||||||
use App\Entity\UserInterface;
|
use App\Entity\UserInterface;
|
||||||
|
use Entity\Attribut\PersonIdentityAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
@ -15,7 +14,7 @@ use App\Entity\UserInterface;
|
|||||||
*/
|
*/
|
||||||
class UserSource extends AbstractDataSource implements UserSourceInterface
|
class UserSource extends AbstractDataSource implements UserSourceInterface
|
||||||
{
|
{
|
||||||
use UserAttribut,NameSourceAttribut;
|
use UserAttribut,PersonIdentityAttribut;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\OneToOne(targetEntity="App\Entity\User",cascade={"persist", "remove"})
|
* @ORM\OneToOne(targetEntity="App\Entity\User",cascade={"persist", "remove"})
|
||||||
@ -25,19 +24,8 @@ class UserSource extends AbstractDataSource implements UserSourceInterface
|
|||||||
*/
|
*/
|
||||||
protected $user;
|
protected $user;
|
||||||
|
|
||||||
/**
|
|
||||||
* @Assert\Type(type="App\Entity\Source\NameSource")
|
|
||||||
* @Assert\Valid()
|
|
||||||
* @ORM\OneToOne(targetEntity="NameSource",cascade={"persist", "remove"})
|
|
||||||
* @ORM\JoinColumn(name="name_id", referencedColumnName="id")
|
|
||||||
*
|
|
||||||
* @var NameSourceInterface
|
|
||||||
*/
|
|
||||||
protected $nameSource;
|
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->nameSource = new NameSource();
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,11 @@
|
|||||||
namespace App\Entity\Source\Data;
|
namespace App\Entity\Source\Data;
|
||||||
|
|
||||||
use App\Entity\Attribut\UserAttributInterface;
|
use App\Entity\Attribut\UserAttributInterface;
|
||||||
use App\Entity\Attribut\NameSourceAttributInterface;
|
use App\Entity\Attribut\PersonIdentitySourceAttributInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kevinfrantz
|
* @author kevinfrantz
|
||||||
*/
|
*/
|
||||||
interface UserSourceInterface extends DataSourceInterface, UserAttributInterface, NameSourceAttributInterface
|
interface UserSourceInterface extends DataSourceInterface, UserAttributInterface, PersonIdentitySourceAttributInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Data\Name;
|
namespace App\Entity\Source\Data\Name;
|
||||||
|
|
||||||
use App\Entity\Source\Data\AbstractDataSource;
|
use App\Entity\Source\Data\AbstractDataSource;
|
||||||
@ -6,4 +7,3 @@ use App\Entity\Source\Data\AbstractDataSource;
|
|||||||
class AbstractNameSource extends AbstractDataSource implements NameSourceInterface
|
class AbstractNameSource extends AbstractDataSource implements NameSourceInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Data\Name;
|
namespace App\Entity\Source\Data\Name;
|
||||||
|
|
||||||
interface FirstNameSourceInterface extends NameSourceInterface
|
interface FirstNameSourceInterface extends NameSourceInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Data\Name;
|
namespace App\Entity\Source\Data\Name;
|
||||||
|
|
||||||
use App\Entity\Source\Data\DataSourceInterface;
|
use App\Entity\Source\Data\DataSourceInterface;
|
||||||
@ -6,4 +7,4 @@ use App\Entity\Attribut\NameAttributInterface;
|
|||||||
|
|
||||||
interface NameSourceInterface extends DataSourceInterface, NameAttributInterface
|
interface NameSourceInterface extends DataSourceInterface, NameAttributInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ final class NicknameSource extends AbstractNameSource implements NicknameSourceI
|
|||||||
* @todo Implement an extra assert Layer!
|
* @todo Implement an extra assert Layer!
|
||||||
* @ORM\Column(type="string",length=255)
|
* @ORM\Column(type="string",length=255)
|
||||||
* @Assert\NotBlank()
|
* @Assert\NotBlank()
|
||||||
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $name;
|
protected $name;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\Entity\Source\Data\Name;
|
namespace App\Entity\Source\Data\Name;
|
||||||
|
|
||||||
interface SurnameSourceInterface extends NameSourceInterface
|
interface SurnameSourceInterface extends NameSourceInterface
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit\Entity\Attribut;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use App\Entity\Source\Combination\FullPersonNameSourceInterface;
|
||||||
|
use App\Entity\Attribut\FullPersonNameSourceAttributInterface;
|
||||||
|
use App\Entity\Attribut\FullPersonNameSourceAttribut;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
class FullPersonNameSourceAttributTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var FullPersonNameSourceAttributInterface
|
||||||
|
*/
|
||||||
|
protected $fullname;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$this->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());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Unit\Entity\Attribut;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use App\Entity\Attribut\PersonIdentitySourceAttributInterface;
|
||||||
|
use Entity\Attribut\PersonIdentityAttribut;
|
||||||
|
use App\Entity\Source\Data\PersonIdentitySourceInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @todo Implement abstract test class for entity attributs
|
||||||
|
*
|
||||||
|
* @author kevinfrantz
|
||||||
|
*/
|
||||||
|
class PersonIdentitySourceAttributTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var PersonIdentitySourceAttributInterface
|
||||||
|
*/
|
||||||
|
protected $identity;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$this->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());
|
||||||
|
}
|
||||||
|
}
|
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace tests\unit\Entity\Source\Data;
|
namespace tests\unit\Entity\Source\Combination;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use App\Entity\Source\Data\UserSourceInterface;
|
use App\Entity\Source\Data\UserSourceInterface;
|
||||||
use App\Entity\Source\Data\UserSource;
|
use App\Entity\Source\Data\UserSource;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
use App\Entity\Source\Data\NameSourceInterface;
|
use App\Entity\Source\Data\PersonIdentitySourceInterface;
|
||||||
|
|
||||||
class UserSourceTest extends TestCase
|
class UserSourceTest extends TestCase
|
||||||
{
|
{
|
||||||
@ -23,7 +23,7 @@ class UserSourceTest extends TestCase
|
|||||||
public function testConstructor(): void
|
public function testConstructor(): void
|
||||||
{
|
{
|
||||||
$this->assertInstanceOf(Collection::class, $this->userSource->getMemberships());
|
$this->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->expectException(\TypeError::class);
|
||||||
$this->userSource->getUser();
|
$this->userSource->getUser();
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace tests\unit\Entity\Source\Data;
|
namespace tests\unit\Entity\Source\Data;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
@ -12,19 +13,21 @@ class IdentitySourceTest extends TestCase
|
|||||||
* @var IdentityInterface
|
* @var IdentityInterface
|
||||||
*/
|
*/
|
||||||
protected $identity;
|
protected $identity;
|
||||||
|
|
||||||
public function setUp():void{
|
public function setUp(): void
|
||||||
|
{
|
||||||
$this->identity = new IdentitySource();
|
$this->identity = new IdentitySource();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testConstructor():void{
|
public function testConstructor(): void
|
||||||
|
{
|
||||||
$this->assertInstanceOf(FullPersonNameSourceInterface::class, $this->identity->getName());
|
$this->assertInstanceOf(FullPersonNameSourceInterface::class, $this->identity->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testName():void{
|
public function testName(): void
|
||||||
|
{
|
||||||
$name = $this->createMock(FullPersonNameSourceInterface::class);
|
$name = $this->createMock(FullPersonNameSourceInterface::class);
|
||||||
$this->assertNull($this->identity->setName($name));
|
$this->assertNull($this->identity->setName($name));
|
||||||
$this->assertEquals($name, $this->identity->getName());
|
$this->assertEquals($name, $this->identity->getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user