From b6cecd00103ec9f8b29cf85111060719935da0cb Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 18 Nov 2018 10:50:18 +0100 Subject: [PATCH] Implemented first test for tree-source service --- .../SourceManagement/TreeSourceService.php | 1 + .../Unit/Domain/TreeSourceServiceTest.php | 35 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 application/tests/Unit/Domain/TreeSourceServiceTest.php diff --git a/application/src/Domain/SourceManagement/TreeSourceService.php b/application/src/Domain/SourceManagement/TreeSourceService.php index 77b0e7a..c207170 100644 --- a/application/src/Domain/SourceManagement/TreeSourceService.php +++ b/application/src/Domain/SourceManagement/TreeSourceService.php @@ -41,6 +41,7 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc $this->source = $source; $this->branches = new ArrayCollection(); $this->leaves = new ArrayCollection(); + $this->basicSort(); } private function sortMember(SourceInterface $member): bool diff --git a/application/tests/Unit/Domain/TreeSourceServiceTest.php b/application/tests/Unit/Domain/TreeSourceServiceTest.php new file mode 100644 index 0000000..1638f33 --- /dev/null +++ b/application/tests/Unit/Domain/TreeSourceServiceTest.php @@ -0,0 +1,35 @@ +createMock(SourceInterface::class); + $leave2 = $this->createMock(SourceInterface::class); + $collection = new ArrayCollection([$tree2,$tree3,$leave1,$leave2]); + $tree1->setCollection($collection); + $this->treeService = new TreeSourceService($tree1); + } + + public function testGetLeaves():void{ + $this->assertEquals(2, $this->treeService->getLeaves()->count()); + } +} +