Implemented some tests for UserSource and deleted unnecessary attributs

This commit is contained in:
Kevin Frantz 2018-11-04 12:24:52 +01:00
parent 03ce3f5cdf
commit 00ae6412e6
6 changed files with 29 additions and 71 deletions

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\Source\NameSourceInterface;
use App\Entity\Source\Data\NameSourceInterface;
/**
* @author kevinfrantz

View File

@ -2,7 +2,7 @@
namespace App\Entity\Attribut;
use App\Entity\Source\NameSourceInterface;
use App\Entity\Source\Data\NameSourceInterface;
/**
* @author kevinfrantz

View File

@ -1,28 +0,0 @@
<?php
namespace Entity\Attribut;
use App\Entity\Source\UserSourceInterface;
/**
* @author kevinfrantz
*/
trait UserSource
{
/**
* @var UserSourceInterface
* @ORM\OneToOne(targetEntity="UserSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="source_user_id", referencedColumnName="id")
*/
protected $userSource;
public function setUserSource(UserSourceInterface $userSource): void
{
$this->user = $userSource;
}
public function getUserSource(): UserSourceInterface
{
return $this->userSource;
}
}

View File

@ -1,15 +0,0 @@
<?php
namespace App\Entity\Attribut;
use App\Entity\Source\UserSourceInterface;
/**
* @author kevinfrantz
*/
interface UserSourceAttributInterface
{
public function setUserSource(UserSourceInterface $user): void;
public function getUserSource(): UserSourceInterface;
}

View File

@ -1,26 +0,0 @@
<?php
namespace App\Entity\Attribut;
/**
* This trait doesn't need an own interface because it's covered by symfony.
*
* @author kevinfrantz
*/
trait UsernameAttribut
{
/**
* @ORM\Column(type="string", length=25, unique=true)
*/
protected $username;
public function getUsername(): ?string
{
return $this->username;
}
public function setUsername(string $username): void
{
$this->username = \trim($username);
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace tests\unit\Entity\Source\Data;
use PHPUnit\Framework\TestCase;
use App\Entity\Source\Data\UserSourceInterface;
use App\Entity\Source\Data\UserSource;
use Doctrine\Common\Collections\Collection;
use App\Entity\Source\Data\NameSourceInterface;
class UserSourceTest extends TestCase
{
/**
*
* @var UserSourceInterface
*/
public $userSource;
public function setUp():void{
$this->userSource = new UserSource();
}
public function testConstructor():void {
$this->assertInstanceOf(Collection::class, $this->userSource->getMemberships());
$this->assertInstanceOf(NameSourceInterface::class, $this->userSource->getNameSource());
}
}