infinito/application/symfony/tests/Unit/Domain/Member/MemberManagerTest.php

51 lines
1.8 KiB
PHP
Raw Normal View History

2018-11-26 21:41:06 +01:00
<?php
namespace Tests\Unit\Domain\Member;
2018-11-26 21:41:06 +01:00
2020-04-02 21:13:35 +02:00
use Infinito\Domain\Member\MemberManager;
use Infinito\Domain\Member\MemberManagerInterface;
use Infinito\Entity\Meta\Relation\Member\MemberRelation;
2020-04-02 21:13:35 +02:00
use Infinito\Entity\Meta\Relation\Member\MemberRelationInterface;
use PHPUnit\Framework\TestCase;
2018-11-26 21:41:06 +01:00
class MemberManagerTest extends TestCase
{
/**
* @var MemberRelationInterface
*/
private $memberRelation;
/**
* @var MemberManagerInterface
*/
private $MemberManager;
public function setUp(): void
{
$this->memberRelation = new MemberRelation();
$this->MemberManager = new MemberManager($this->memberRelation);
}
public function testAddAndRemoveMember(): void
{
$member = new MemberRelation();
$this->assertNull($this->MemberManager->addMember($member));
$this->assertEquals($member, $this->memberRelation->getMembers()->get(0));
$this->assertEquals($this->memberRelation, $member->getMemberships()->get(0));
$this->assertNull($this->MemberManager->removeMember($member));
$this->assertEquals(0, $this->memberRelation->getMembers()->count());
$this->assertEquals(0, $member->getMemberships()->count());
}
public function testAddAndRemoveMembership(): void
{
$membership = new MemberRelation();
$this->assertNull($this->MemberManager->addMembership($membership));
$this->assertEquals($membership, $this->memberRelation->getMemberships()->get(0));
$this->assertEquals($this->memberRelation, $membership->getMembers()->get(0));
$this->assertNull($this->MemberManager->removeMembership($membership));
$this->assertEquals(0, $this->memberRelation->getMemberships()->count());
$this->assertEquals(0, $membership->getMembers()->count());
}
}