mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 06:01:35 +01:00
Solved Unit tests
This commit is contained in:
parent
00c6ba1f9d
commit
0d0fa68094
@ -103,15 +103,14 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
|
||||
|
||||
public function getAllLeaves(): Collection
|
||||
{
|
||||
$leaves = new ArrayCollection();
|
||||
foreach ($this->getAllBranches()->toArray() as $branch) {
|
||||
foreach ((new self($branch))->getLeaves() as $leave) {
|
||||
$leaves = new ArrayCollection($this->getLeaves()->toArray());
|
||||
foreach ($this->getAllBranches() as $branch) {
|
||||
foreach ((new self($branch))->getAllLeaves() as $leave) {
|
||||
if (! $leaves->contains($leave)) {
|
||||
$leaves->add($leave);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $leaves;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,8 @@ class TreeSourceServiceTest extends TestCase
|
||||
$leave2 = $this->createMock(SourceInterface::class);
|
||||
$leave3 = $this->createMock(SourceInterface::class);
|
||||
$leave4 = $this->createMock(SourceInterface::class);
|
||||
$tree2->setCollection(new ArrayCollection([$leave3,$leave4,$tree5]));
|
||||
$leave5 = $this->createMock(SourceInterface::class);
|
||||
$tree2->setCollection(new ArrayCollection([$leave3,$leave4,$tree5,$leave5]));
|
||||
$collection = new ArrayCollection([$tree2,$tree3,$leave1,$leave2,$tree4]);
|
||||
$tree1->setCollection($collection);
|
||||
$this->treeService = new TreeSourceService($tree1);
|
||||
@ -46,7 +47,7 @@ class TreeSourceServiceTest extends TestCase
|
||||
}
|
||||
|
||||
public function testGetAllLeaves():void{
|
||||
$this->assertEquals(4, $this->treeService->getAllLeaves()->count());
|
||||
$this->assertEquals(5, $this->treeService->getAllLeaves()->count());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user