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

67 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-10-31 21:07:57 +01:00
$this->assertInstanceOf(Collection::class, $this->reciever->getMembers());
2018-11-04 15:51:16 +01:00
$this->expectException(\TypeError::class);
$this->reciever->getRight();
}
2018-11-04 16:12:16 +01:00
public function testMembersIncludingChildren(): void
{
/**
* @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface
*/
$user1 = $this->createMock(UserSource::class);
/**
* @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface
*/
$user2 = $this->createMock(UserSource::class);
/**
* @var \PHPUnit\Framework\MockObject\MockObject|UserSourceInterface
*/
$user3 = $this->createMock(UserSource::class);
/**
* @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface
*/
$group1 = $this->createMock(TreeCollectionSource::class);
/**
* @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface
*/
$group2 = $this->createMock(TreeCollectionSource::class);
/**
* @var \PHPUnit\Framework\MockObject\MockObject|TreeCollectionSourceInterface
*/
$group3 = $this->createMock(TreeCollectionSource::class);
$group1->getCollection()->add($user1);
$group2->getCollection()->add($group1);
$group2->getCollection()->add($user2);
$group2->getCollection()->add($user3);
$group3->getCollection()->add($group2);
$this->assertEquals(6, $this->reciever->getMembersIncludingChildren()->count());
}
}