2018-10-31 16:15:39 +01:00
|
|
|
<?php
|
2018-10-31 17:19:10 +01:00
|
|
|
|
2018-10-31 20:47:51 +01:00
|
|
|
namespace App\Tests\Unit\Entity\Meta;
|
2018-10-31 16:15:39 +01:00
|
|
|
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use App\Entity\Meta\Reciever;
|
|
|
|
use App\Entity\Meta\RecieverInterface;
|
2018-10-31 21:07:57 +01:00
|
|
|
use Doctrine\Common\Collections\Collection;
|
2018-11-04 16:12:16 +01:00
|
|
|
use App\Entity\Source\Data\UserSource;
|
|
|
|
use App\Entity\Source\Collection\TreeCollectionSource;
|
|
|
|
use App\Entity\Source\Collection\TreeCollectionSourceInterface;
|
|
|
|
use App\Entity\Source\Data\UserSourceInterface;
|
2018-10-31 16:15:39 +01:00
|
|
|
|
|
|
|
class RecieverTest extends TestCase
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var RecieverInterface
|
|
|
|
*/
|
|
|
|
public $reciever;
|
2018-10-31 17:19:10 +01:00
|
|
|
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
2018-10-31 16:15:39 +01:00
|
|
|
$this->reciever = new Reciever();
|
|
|
|
}
|
2018-10-31 17:19:10 +01:00
|
|
|
|
|
|
|
public function testConstructor(): void
|
|
|
|
{
|
2018-11-04 23:43:34 +01:00
|
|
|
$this->assertInstanceOf(Collection::class, $this->reciever->getCollection());
|
2018-11-04 15:51:16 +01:00
|
|
|
$this->expectException(\TypeError::class);
|
|
|
|
$this->reciever->getRight();
|
2018-10-31 16:15:39 +01:00
|
|
|
}
|
2018-11-04 16:12:16 +01:00
|
|
|
|
2018-11-04 23:43:34 +01:00
|
|
|
public function testDimensions(): void
|
2018-11-04 16:12:16 +01:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface
|
|
|
|
*/
|
2018-11-04 23:43:34 +01:00
|
|
|
$user1 = new UserSource();
|
2018-11-04 16:12:16 +01:00
|
|
|
/**
|
|
|
|
* @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface
|
|
|
|
*/
|
2018-11-04 23:43:34 +01:00
|
|
|
$user2 = new UserSource();
|
2018-11-04 16:12:16 +01:00
|
|
|
/**
|
|
|
|
* @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface
|
|
|
|
*/
|
2018-11-04 23:43:34 +01:00
|
|
|
$user3 = new UserSource();
|
2018-11-04 16:12:16 +01:00
|
|
|
/**
|
|
|
|
* @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface
|
|
|
|
*/
|
2018-11-04 23:43:34 +01:00
|
|
|
$group1 = new TreeCollectionSource();
|
2018-11-04 16:12:16 +01:00
|
|
|
/**
|
|
|
|
* @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface
|
|
|
|
*/
|
2018-11-04 23:43:34 +01:00
|
|
|
$group2 = new TreeCollectionSource();
|
2018-11-04 16:12:16 +01:00
|
|
|
/**
|
|
|
|
* @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface
|
|
|
|
*/
|
2018-11-04 23:43:34 +01:00
|
|
|
$group3 = new TreeCollectionSource();
|
2018-11-04 16:12:16 +01:00
|
|
|
$group1->getCollection()->add($user1);
|
2018-11-04 23:43:34 +01:00
|
|
|
$group1->getCollection()->add($group2);
|
2018-11-04 16:12:16 +01:00
|
|
|
$group2->getCollection()->add($user2);
|
|
|
|
$group2->getCollection()->add($user3);
|
2018-11-04 22:59:15 +01:00
|
|
|
$group2->getCollection()->add($group3);
|
2018-11-04 23:43:34 +01:00
|
|
|
$this->reciever->getCollection()->add($group1);
|
|
|
|
$this->assertEquals($group1, $this->reciever->getCollection()->get(0));
|
|
|
|
$this->assertEquals(6, $this->reciever->getDimensions()->count());
|
2018-11-04 16:12:16 +01:00
|
|
|
}
|
2018-10-31 17:19:10 +01:00
|
|
|
}
|