mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Implemented Collection Attribut
This commit is contained in:
parent
9bcc54cc64
commit
cbb8bc702c
29
application/src/Entity/Attribut/CollectionAttribut.php
Normal file
29
application/src/Entity/Attribut/CollectionAttribut.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
trait CollectionAttribut
|
||||
{
|
||||
/**
|
||||
* @var Collection
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
/**
|
||||
* @return Collection
|
||||
*/
|
||||
public function getCollection(): Collection
|
||||
{
|
||||
return $this->collection;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Collection $collection
|
||||
*/
|
||||
public function setCollection(Collection $collection): void
|
||||
{
|
||||
$this->collection = $collection;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
interface CollectionAttributInterface
|
||||
{
|
||||
public function getCollection(): Collection;
|
||||
|
||||
public function setCollection(Collection $collection): void;
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Entity\Attribut;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Attribut\CollectionAttributInterface;
|
||||
use App\Entity\Attribut\CollectionAttribut;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
class CollectionAttributTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @var CollectionAttributInterface
|
||||
*/
|
||||
protected $collection;
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->collection = new class() implements CollectionAttributInterface {
|
||||
use CollectionAttribut;
|
||||
};
|
||||
}
|
||||
|
||||
public function testConstructor(): void
|
||||
{
|
||||
$this->expectException(\TypeError::class);
|
||||
$this->collection->getCollection();
|
||||
}
|
||||
|
||||
public function testAccessors(): void
|
||||
{
|
||||
$collection = new ArrayCollection();
|
||||
$this->assertNull($this->collection->setCollection($collection));
|
||||
$this->assertEquals($collection, $this->collection->getCollection());
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user