Implemented test draft for reciever

This commit is contained in:
Kevin Frantz 2018-11-04 16:12:16 +01:00
parent 9e4b00e2ae
commit 2f316ae55d
4 changed files with 41 additions and 3 deletions

View File

@ -13,7 +13,7 @@ use App\Entity\Method\CollectionDimensionHelperMethod;
* @ORM\Table(name="source_group")
* @ORM\Entity
*/
final class TreeCollectionSource extends AbstractCollectionSource implements TreeCollectionSourceInterface
class TreeCollectionSource extends AbstractCollectionSource implements TreeCollectionSourceInterface
{
use MembersAttribut;
use CollectionDimensionHelperMethod;

View File

@ -13,7 +13,7 @@ use App\Entity\UserInterface;
* @ORM\Table(name="source_data_user")
* @ORM\Entity(repositoryClass="App\Repository\UserSourceRepository")
*/
final class UserSource extends AbstractDataSource implements UserSourceInterface
class UserSource extends AbstractDataSource implements UserSourceInterface
{
use UserAttribut,NameSourceAttribut;

View File

@ -6,6 +6,10 @@ use PHPUnit\Framework\TestCase;
use App\Entity\Meta\Reciever;
use App\Entity\Meta\RecieverInterface;
use Doctrine\Common\Collections\Collection;
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
{
@ -25,4 +29,38 @@ class RecieverTest extends TestCase
$this->expectException(\TypeError::class);
$this->reciever->getRight();
}
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());
}
}

View File

@ -27,7 +27,7 @@ class RightTest extends TestCase
public function testConstructor(): void
{
$this->assertEquals($this->right,$this->right->getReciever()->getRight());
$this->assertEquals($this->right, $this->right->getReciever()->getRight());
$this->expectException(\TypeError::class);
$this->assertNull($this->right->getLaw());
$this->expectException(\TypeError::class);