2018-11-02 20:28:42 +01:00
|
|
|
<?php
|
|
|
|
|
2019-01-20 10:41:58 +01:00
|
|
|
namespace Tests\Unit\Attribut;
|
2018-11-02 20:28:42 +01:00
|
|
|
|
|
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
2020-04-02 21:13:35 +02:00
|
|
|
use Infinito\Attribut\CollectionAttribut;
|
|
|
|
use Infinito\Attribut\CollectionAttributInterface;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
2018-11-02 20:28:42 +01:00
|
|
|
|
|
|
|
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());
|
|
|
|
}
|
2018-11-06 20:08:28 +01:00
|
|
|
|
|
|
|
public function testAdd(): void
|
|
|
|
{
|
|
|
|
$mock = new class() {
|
|
|
|
};
|
2018-11-04 23:34:38 +01:00
|
|
|
$this->collection->setCollection(new ArrayCollection());
|
|
|
|
$this->assertTrue($this->collection->getCollection()->add($mock));
|
|
|
|
$this->assertEquals($mock, $this->collection->getCollection()->get(0));
|
|
|
|
}
|
2018-11-02 20:28:42 +01:00
|
|
|
}
|