mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Refactored code through substituting by PureSource
This commit is contained in:
@@ -11,7 +11,7 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
use App\Entity\Source\Complex\FullPersonNameSource;
|
||||
use App\Domain\SourceManagement\SourceMemberInformation;
|
||||
use App\Domain\SourceManagement\SourceMemberInformationInterface;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Entity\Source\PureSource;
|
||||
|
||||
class SourceMemberInformationTest extends TestCase
|
||||
{
|
||||
@@ -25,12 +25,6 @@ class SourceMemberInformationTest extends TestCase
|
||||
*/
|
||||
private $sourceMemberInformation;
|
||||
|
||||
private function createSourceMock(): SourceInterface
|
||||
{
|
||||
return new class() extends AbstractSource {
|
||||
};
|
||||
}
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->source = new UserSource();
|
||||
@@ -75,7 +69,7 @@ class SourceMemberInformationTest extends TestCase
|
||||
public function testError(): void
|
||||
{
|
||||
$this->expectException(\Error::class);
|
||||
$this->source->getMemberRelation()->getMembers()->add($this->createSourceMock());
|
||||
$this->source->getMemberRelation()->getMembers()->add(new PureSource());
|
||||
$this->sourceMemberInformation->getAllMembers();
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ namespace Tests\Unit\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\Entity\Source\PureSource;
|
||||
|
||||
class SourceMemberManagerTest extends TestCase
|
||||
{
|
||||
@@ -20,21 +20,15 @@ class SourceMemberManagerTest extends TestCase
|
||||
*/
|
||||
private $sourceMemberManager;
|
||||
|
||||
private function createSource(): SourceInterface
|
||||
{
|
||||
return new class() extends AbstractSource {
|
||||
};
|
||||
}
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->source = $this->createSource();
|
||||
$this->source = new PureSource();
|
||||
$this->sourceMemberManager = new SourceMemberManager($this->source);
|
||||
}
|
||||
|
||||
public function testAddAndRemoveMember(): void
|
||||
{
|
||||
$member = $this->createSource();
|
||||
$member = new PureSource();
|
||||
$this->assertNull($this->sourceMemberManager->addMember($member));
|
||||
$this->assertEquals($member, $this->source->getMemberRelation()->getMembers()->get(0)->getSource());
|
||||
$this->assertEquals($this->source, $member->getMemberRelation()->getMemberships()->get(0)->getSource());
|
||||
@@ -45,7 +39,7 @@ class SourceMemberManagerTest extends TestCase
|
||||
|
||||
public function testAddAndRemoveMembership(): void
|
||||
{
|
||||
$membership = $this->createSource();
|
||||
$membership = new PureSource();
|
||||
$this->assertNull($this->sourceMemberManager->addMembership($membership));
|
||||
$this->assertEquals($membership, $this->source->getMemberRelation()->getMemberships()->get(0)->getSource());
|
||||
$this->assertEquals($this->source, $membership->getMemberRelation()->getMembers()->get(0)->getSource());
|
||||
|
@@ -5,7 +5,6 @@ namespace Unit\Domain\SourceManagement;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use App\Entity\Source\SourceInterface;
|
||||
use App\Domain\SourceManagement\SourceRightManagerInterface;
|
||||
use App\Entity\Source\AbstractSource;
|
||||
use App\Domain\SourceManagement\SourceRightManager;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Meta\Right;
|
||||
@@ -13,6 +12,7 @@ use App\Entity\Meta\Law;
|
||||
use App\Exception\AllreadySetException;
|
||||
use App\Exception\NotSetException;
|
||||
use App\Exception\AllreadyDefinedException;
|
||||
use App\Entity\Source\PureSource;
|
||||
|
||||
class SourceRightManagerTest extends TestCase
|
||||
{
|
||||
@@ -31,15 +31,9 @@ class SourceRightManagerTest extends TestCase
|
||||
*/
|
||||
private $right;
|
||||
|
||||
private function createSourceMock()
|
||||
{
|
||||
return new class() extends AbstractSource {
|
||||
};
|
||||
}
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->source = $this->createSourceMock();
|
||||
$this->source = new PureSource();
|
||||
$this->sourceRightManager = new SourceRightManager($this->source);
|
||||
$this->right = new Right();
|
||||
}
|
||||
@@ -53,7 +47,7 @@ class SourceRightManagerTest extends TestCase
|
||||
|
||||
public function testSourceException(): void
|
||||
{
|
||||
$this->right->setSource($this->createSourceMock());
|
||||
$this->right->setSource(new PureSource());
|
||||
$this->expectException(AllreadyDefinedException::class);
|
||||
$this->sourceRightManager->addRight($this->right);
|
||||
}
|
||||
|
Reference in New Issue
Block a user