Solved bugs to allow unit tests to run

This commit is contained in:
Kevin Frantz 2018-11-15 19:55:03 +01:00
parent 647bc81965
commit de66375ee0
9 changed files with 61 additions and 42 deletions

View File

@ -1,10 +1,10 @@
<?php <?php
namespace Entity\Attribut; namespace App\Entity\Attribut;
use App\Entity\Source\Data\PersonIdentitySourceInterface; use App\Entity\Source\Data\PersonIdentitySourceInterface;
trait PersonIdentityAttribut trait PersonIdentitySourceAttribut
{ {
/** /**
* @var PersonIdentitySourceInterface * @var PersonIdentitySourceInterface

View File

@ -4,9 +4,20 @@ namespace App\Entity\Attribut;
use App\Entity\Source\Data\Name\SurnameSourceInterface; use App\Entity\Source\Data\Name\SurnameSourceInterface;
interface SurnameSourceAttributInterface trait SurnameSourceAttribut
{ {
public function getSurname(): SurnameSourceInterface; /**
* @var SurnameSourceInterface
*/
protected $surnameSource;
public function setSurname(SurnameSourceInterface $name): void; public function getSurname(): SurnameSourceInterface
{
return $this->surnameSource;
}
public function setSurname(SurnameSourceInterface $name): void
{
$this->surnameSource = $name;
}
} }

View File

@ -4,20 +4,9 @@ namespace App\Entity\Attribut;
use App\Entity\Source\Data\Name\SurnameSourceInterface; use App\Entity\Source\Data\Name\SurnameSourceInterface;
trait SurnameSourceAttribut interface SurnameSourceAttributInterface
{ {
/** public function getSurname(): SurnameSourceInterface;
* @var SurnameSourceInterface
*/
protected $surnameSource;
public function getSurname(): SurnameSourceInterface public function setSurname(SurnameSourceInterface $name): void;
{
return $this->surnameSource;
}
public function setSurname(SurnameSourceInterface $name): void
{
$this->surnameSource = $name;
}
} }

View File

@ -5,7 +5,7 @@ namespace App\Entity\Source\Combination;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use App\Entity\Attribut\UserAttribut; use App\Entity\Attribut\UserAttribut;
use App\Entity\UserInterface; use App\Entity\UserInterface;
use Entity\Attribut\PersonIdentityAttribut; use App\Entity\Attribut\PersonIdentitySourceAttribut;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -14,7 +14,7 @@ use Entity\Attribut\PersonIdentityAttribut;
*/ */
class UserSource extends AbstractCombinationSource implements UserSourceInterface class UserSource extends AbstractCombinationSource implements UserSourceInterface
{ {
use UserAttribut,PersonIdentityAttribut; use UserAttribut,PersonIdentitySourceAttribut;
/** /**
* @ORM\OneToOne(targetEntity="App\Entity\User",cascade={"persist", "remove"}) * @ORM\OneToOne(targetEntity="App\Entity\User",cascade={"persist", "remove"})

View File

@ -5,6 +5,7 @@ namespace App\Entity\Source\Data\Name;
use App\Entity\Source\Data\AbstractDataSource; use App\Entity\Source\Data\AbstractDataSource;
use App\Entity\Attribut\NameAttribut; use App\Entity\Attribut\NameAttribut;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -13,9 +14,23 @@ use Doctrine\ORM\Mapping as ORM;
* @ORM\Table(name="source_data_name") * @ORM\Table(name="source_data_name")
* @ORM\InheritanceType("SINGLE_TABLE") * @ORM\InheritanceType("SINGLE_TABLE")
* @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorColumn(name="discr", type="string")
* @ORM\DiscriminatorMap({"nickname" = "NicknameSource","firstname" = "FirstNameSource", "lastname" = "LastNameSource"}) * @ORM\DiscriminatorMap({"nickname" = "NicknameSource","firstname" = "FirstNameSource", "surname" = "SurnameSource"})
*/ */
abstract class AbstractNameSource extends AbstractDataSource implements NameSourceInterface abstract class AbstractNameSource extends AbstractDataSource implements NameSourceInterface
{ {
use NameAttribut; use NameAttribut;
/**
* @todo Implement an extra assert Layer! - maybe ;)
* @ORM\Column(type="string",length=255)
* @Assert\NotBlank()
*
* @var string
*/
protected $name;
public function __construct()
{
parent::__construct();
}
} }

View File

@ -0,0 +1,7 @@
<?php
namespace App\Entity\Source\Data\Name;
final class FirstNameSource extends AbstractNameSource implements FirstNameSourceInterface
{
}

View File

@ -2,30 +2,13 @@
namespace App\Entity\Source\Data\Name; namespace App\Entity\Source\Data\Name;
use App\Entity\Attribut\NameAttribut;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/** /**
* @author kevinfrantz * @author kevinfrantz
* @ORM\Table(name="source_data_nickname") * @ORM\Table(name="source_data_name_nickname")
* @ORM\Entity() * @ORM\Entity()
*/ */
final class NicknameSource extends AbstractNameSource implements NicknameSourceInterface final class NicknameSource extends AbstractNameSource implements NicknameSourceInterface
{ {
use NameAttribut;
/**
* @todo Implement an extra assert Layer!
* @ORM\Column(type="string",length=255)
* @Assert\NotBlank()
*
* @var string
*/
protected $name;
public function __construct()
{
parent::__construct();
}
} }

View File

@ -0,0 +1,14 @@
<?php
namespace App\Entity\Source\Data\Name;
use Doctrine\ORM\Mapping as ORM;
/**
* @author kevinfrantz
* @ORM\Table(name="source_data_name_surname")
* @ORM\Entity()
*/
final class SurnameSource extends AbstractNameSource implements SurnameSourceInterface
{
}

View File

@ -4,7 +4,7 @@ namespace Tests\Unit\Entity\Attribut;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use App\Entity\Attribut\PersonIdentitySourceAttributInterface; use App\Entity\Attribut\PersonIdentitySourceAttributInterface;
use Entity\Attribut\PersonIdentityAttribut; use App\Entity\Attribut\PersonIdentitySourceAttribut;
use App\Entity\Source\Data\PersonIdentitySourceInterface; use App\Entity\Source\Data\PersonIdentitySourceInterface;
/** /**
@ -22,7 +22,7 @@ class PersonIdentitySourceAttributTest extends TestCase
public function setUp(): void public function setUp(): void
{ {
$this->identity = new class() implements PersonIdentitySourceAttributInterface { $this->identity = new class() implements PersonIdentitySourceAttributInterface {
use PersonIdentityAttribut; use PersonIdentitySourceAttribut;
}; };
} }