From 9137c55b178776f302154686eb691d281a2203ce Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 18 Nov 2018 11:39:06 +0100 Subject: [PATCH] Solved infinite recursion bug --- .../src/Domain/SourceManagement/TreeSourceService.php | 2 +- application/tests/Unit/Domain/TreeSourceServiceTest.php | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/application/src/Domain/SourceManagement/TreeSourceService.php b/application/src/Domain/SourceManagement/TreeSourceService.php index 8b2460e..79dd53d 100644 --- a/application/src/Domain/SourceManagement/TreeSourceService.php +++ b/application/src/Domain/SourceManagement/TreeSourceService.php @@ -105,7 +105,7 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc { $leaves = new ArrayCollection($this->getLeaves()->toArray()); foreach ($this->getAllBranches() as $branch) { - foreach ((new self($branch))->getAllLeaves() as $leave) { + foreach ((new self($branch))->getLeaves() as $leave) { if (! $leaves->contains($leave)) { $leaves->add($leave); } diff --git a/application/tests/Unit/Domain/TreeSourceServiceTest.php b/application/tests/Unit/Domain/TreeSourceServiceTest.php index c79f08f..647a4eb 100644 --- a/application/tests/Unit/Domain/TreeSourceServiceTest.php +++ b/application/tests/Unit/Domain/TreeSourceServiceTest.php @@ -29,7 +29,7 @@ class TreeSourceServiceTest extends TestCase $leave4 = $this->createMock(SourceInterface::class); $leave5 = $this->createMock(SourceInterface::class); $tree2->setCollection(new ArrayCollection([$leave3,$leave4,$tree5,$leave5])); - $collection = new ArrayCollection([$tree2,$tree3,$leave1,$leave2,$tree4]); + $collection = new ArrayCollection([$tree2,$tree3,$leave1,$leave2,$tree4,$tree1]); $tree1->setCollection($collection); $this->treeService = new TreeSourceService($tree1); } @@ -39,11 +39,11 @@ class TreeSourceServiceTest extends TestCase } public function testGetBranches():void{ - $this->assertEquals(3, $this->treeService->getBranches()->count()); + $this->assertEquals(4, $this->treeService->getBranches()->count()); } public function testGetAllBranches():void{ - $this->assertEquals(4, $this->treeService->getAllBranches()->count()); + $this->assertEquals(5, $this->treeService->getAllBranches()->count()); } public function testGetAllLeaves():void{