mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Refactored method name
This commit is contained in:
parent
e7b41dab22
commit
48697c8b12
@ -31,7 +31,7 @@ trait MembersAttribut
|
|||||||
*
|
*
|
||||||
* @return Collection|MembersAttributInterface[] Returns all members till the defined dimension
|
* @return Collection|MembersAttributInterface[] Returns all members till the defined dimension
|
||||||
*/
|
*/
|
||||||
public function getMembersInclusiveChildren(?int $dimension = null, Collection $members = null): Collection
|
public function getMembersIncludingChildren(?int $dimension = null, Collection $members = null): Collection
|
||||||
{
|
{
|
||||||
$dimension = is_int($dimension) ? $dimension - 1 : null;
|
$dimension = is_int($dimension) ? $dimension - 1 : null;
|
||||||
$members = $members ?? new ArrayCollection();
|
$members = $members ?? new ArrayCollection();
|
||||||
@ -39,7 +39,7 @@ trait MembersAttribut
|
|||||||
if (!$members->contains($member)) {
|
if (!$members->contains($member)) {
|
||||||
$members->add($member);
|
$members->add($member);
|
||||||
if ($this->continueIncludeMembersLoop($dimension) && $member instanceof MembersAttributInterface) {
|
if ($this->continueIncludeMembersLoop($dimension) && $member instanceof MembersAttributInterface) {
|
||||||
$member->getMembersInclusiveChildren($dimension, $members);
|
$member->getMembersIncludingChildren($dimension, $members);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,5 +24,5 @@ interface MembersAttributInterface
|
|||||||
/**
|
/**
|
||||||
* @return Collection
|
* @return Collection
|
||||||
*/
|
*/
|
||||||
public function getMembersInclusiveChildren(int $dimension = null): Collection;
|
public function getMembersIncludingChildren(int $dimension = null): Collection;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ class MembersAttributTest extends AbstractTestCase
|
|||||||
{
|
{
|
||||||
$this->expectException(\TypeError::class);
|
$this->expectException(\TypeError::class);
|
||||||
$this->membersAttribut->getMembers();
|
$this->membersAttribut->getMembers();
|
||||||
$this->membersAttribut->getMembersInclusiveChildren();
|
$this->membersAttribut->getMembersIncludingChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getContinueIncludeMemberLoopResult($dimension): bool
|
private function getContinueIncludeMemberLoopResult($dimension): bool
|
||||||
@ -69,7 +69,7 @@ class MembersAttributTest extends AbstractTestCase
|
|||||||
$source3->setMembers(new ArrayCollection([$source4]));
|
$source3->setMembers(new ArrayCollection([$source4]));
|
||||||
$members = new ArrayCollection([$source1, $source2, $source3]);
|
$members = new ArrayCollection([$source1, $source2, $source3]);
|
||||||
$this->assertNull($this->membersAttribut->setMembers($members));
|
$this->assertNull($this->membersAttribut->setMembers($members));
|
||||||
$this->assertEquals(3, $this->membersAttribut->getMembersInclusiveChildren(1)->count());
|
$this->assertEquals(3, $this->membersAttribut->getMembersIncludingChildren(1)->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test3DimensionsMembersInclusiveChildren(): void
|
public function test3DimensionsMembersInclusiveChildren(): void
|
||||||
@ -87,7 +87,7 @@ class MembersAttributTest extends AbstractTestCase
|
|||||||
$this->assertEquals(1, $source2->getMembers()->count());
|
$this->assertEquals(1, $source2->getMembers()->count());
|
||||||
$this->assertEquals(1, $source3->getMembers()->count());
|
$this->assertEquals(1, $source3->getMembers()->count());
|
||||||
$this->assertEquals(0, $source4->getMembers()->count());
|
$this->assertEquals(0, $source4->getMembers()->count());
|
||||||
$this->assertEquals(3, $this->membersAttribut->getMembersInclusiveChildren(3)->count());
|
$this->assertEquals(3, $this->membersAttribut->getMembersIncludingChildren(3)->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMembersIncludingChildrenInfinite(): void
|
public function testMembersIncludingChildrenInfinite(): void
|
||||||
@ -105,7 +105,7 @@ class MembersAttributTest extends AbstractTestCase
|
|||||||
$source5->setMembers(new ArrayCollection([$source6]));
|
$source5->setMembers(new ArrayCollection([$source6]));
|
||||||
|
|
||||||
$this->membersAttribut->setMembers(new ArrayCollection([$source1]));
|
$this->membersAttribut->setMembers(new ArrayCollection([$source1]));
|
||||||
$this->assertEquals(6, $this->membersAttribut->getMembersInclusiveChildren()->count());
|
$this->assertEquals(6, $this->membersAttribut->getMembersIncludingChildren()->count());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testMemberWithoutMembers(): void
|
public function testMemberWithoutMembers(): void
|
||||||
@ -113,6 +113,6 @@ class MembersAttributTest extends AbstractTestCase
|
|||||||
$source1 = new class() extends AbstractSource {
|
$source1 = new class() extends AbstractSource {
|
||||||
};
|
};
|
||||||
$this->membersAttribut->setMembers(new ArrayCollection([$source1]));
|
$this->membersAttribut->setMembers(new ArrayCollection([$source1]));
|
||||||
$this->assertEquals(1, $this->membersAttribut->getMembersInclusiveChildren()->count());
|
$this->assertEquals(1, $this->membersAttribut->getMembersIncludingChildren()->count());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace App\tests\unit\Entity\Meta;
|
namespace App\Tests\Unit\Entity\Meta;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use Doctrine\Common\Collections\Collection;
|
use Doctrine\Common\Collections\Collection;
|
||||||
|
Loading…
Reference in New Issue
Block a user