infinito/application/tests/Unit/Entity/Meta/RecieverTest.php

69 lines
2.2 KiB
PHP
Raw Normal View History

<?php
2018-10-31 20:47:51 +01:00
namespace App\Tests\Unit\Entity\Meta;
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;
class RecieverTest extends TestCase
{
/**
* @var RecieverInterface
*/
public $reciever;
public function setUp(): void
{
$this->reciever = new Reciever();
}
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-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
}
}