mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 22:17:26 +01:00
Implemented first test for tree-source service
This commit is contained in:
parent
56c0196326
commit
b6cecd0010
@ -41,6 +41,7 @@ final class TreeSourceService extends AbstractSourceService implements TreeSourc
|
|||||||
$this->source = $source;
|
$this->source = $source;
|
||||||
$this->branches = new ArrayCollection();
|
$this->branches = new ArrayCollection();
|
||||||
$this->leaves = new ArrayCollection();
|
$this->leaves = new ArrayCollection();
|
||||||
|
$this->basicSort();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function sortMember(SourceInterface $member): bool
|
private function sortMember(SourceInterface $member): bool
|
||||||
|
35
application/tests/Unit/Domain/TreeSourceServiceTest.php
Normal file
35
application/tests/Unit/Domain/TreeSourceServiceTest.php
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
namespace Tests\Unit\Domain;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use App\Entity\Source\Collection\TreeCollectionSourceInterface;
|
||||||
|
use App\Entity\Source\Collection\TreeCollectionSource;
|
||||||
|
use App\Entity\Source\SourceInterface;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use App\Domain\SourceManagement\TreeSourceServiceInterface;
|
||||||
|
use App\Domain\SourceManagement\TreeSourceService;
|
||||||
|
|
||||||
|
class TreeSourceServiceTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var TreeSourceServiceInterface
|
||||||
|
*/
|
||||||
|
protected $treeService;
|
||||||
|
|
||||||
|
public function setUp():void {
|
||||||
|
$tree1 = new TreeCollectionSource();
|
||||||
|
$tree2 = new TreeCollectionSource();
|
||||||
|
$tree3 = new TreeCollectionSource();
|
||||||
|
$leave1 = $this->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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user