Refactored tests

This commit is contained in:
Kevin Frantz 2018-12-30 16:21:43 +01:00
parent 3a6ed4d54d
commit beb6cb3e90
2 changed files with 45 additions and 14 deletions

View File

@ -0,0 +1,45 @@
<?php
namespace Tests\Integration\Domain\SourceManagement;
use PHPUnit\Framework\TestCase;
use App\Entity\Source\SourceInterface;
use App\Domain\SourceManagement\SourceMemberManagerInterface;
use App\Entity\Source\AbstractSource;
use App\Domain\SourceManagement\SourceMemberManager;
use App\Domain\SourceManagement\SourceMemberInformation;
class SourceMemberManagerIntegrationTest extends TestCase
{
/**
* @var SourceInterface
*/
private $source;
/**
* @var SourceMemberManagerInterface
*/
private $sourceMemberManager;
private function createSource(): SourceInterface
{
return new class() extends AbstractSource {
};
}
public function setUp(): void
{
$this->source = $this->createSource();
$this->sourceMemberManager = new SourceMemberManager($this->source);
}
public function testSourceMemberInformationIntegration(): void
{
$childSource = $this->createSource();
$sourceMemberInformation = new SourceMemberInformation($this->source);
$this->sourceMemberManager->addMember($childSource);
$this->assertEquals($childSource, $sourceMemberInformation->getAllMembers()->get(0));
$this->sourceMemberManager->removeMember($childSource);
$this->assertEquals(0, $sourceMemberInformation->getAllMembers()->count());
}
}

View File

@ -7,7 +7,6 @@ use App\Entity\Source\SourceInterface;
use App\Domain\SourceManagement\SourceMemberManagerInterface; use App\Domain\SourceManagement\SourceMemberManagerInterface;
use App\Entity\Source\AbstractSource; use App\Entity\Source\AbstractSource;
use App\Domain\SourceManagement\SourceMemberManager; use App\Domain\SourceManagement\SourceMemberManager;
use App\Domain\SourceManagement\SourceMemberInformation;
class SourceMemberManagerTest extends TestCase class SourceMemberManagerTest extends TestCase
{ {
@ -54,17 +53,4 @@ class SourceMemberManagerTest extends TestCase
$this->assertEquals(0, $this->source->getMemberRelation()->getMemberships()->count()); $this->assertEquals(0, $this->source->getMemberRelation()->getMemberships()->count());
$this->assertEquals(0, $membership->getMemberRelation()->getMembers()->count()); $this->assertEquals(0, $membership->getMemberRelation()->getMembers()->count());
} }
/**
* @todo Move this function to an own integration test class
*/
public function testSourceMemberInformationIntegration(): void
{
$childSource = $this->createSource();
$sourceMemberInformation = new SourceMemberInformation($this->source);
$this->sourceMemberManager->addMember($childSource);
$this->assertEquals($childSource, $sourceMemberInformation->getAllMembers()->get(0));
$this->sourceMemberManager->removeMember($childSource);
$this->assertEquals(0, $sourceMemberInformation->getAllMembers()->count());
}
} }