2018-11-18 10:50:18 +01:00
|
|
|
<?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();
|
2018-11-18 10:53:48 +01:00
|
|
|
$tree4 = new TreeCollectionSource();
|
2018-11-18 10:50:18 +01:00
|
|
|
$leave1 = $this->createMock(SourceInterface::class);
|
|
|
|
$leave2 = $this->createMock(SourceInterface::class);
|
2018-11-18 10:53:48 +01:00
|
|
|
$collection = new ArrayCollection([$tree2,$tree3,$leave1,$leave2,$tree4]);
|
2018-11-18 10:50:18 +01:00
|
|
|
$tree1->setCollection($collection);
|
|
|
|
$this->treeService = new TreeSourceService($tree1);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetLeaves():void{
|
|
|
|
$this->assertEquals(2, $this->treeService->getLeaves()->count());
|
|
|
|
}
|
2018-11-18 10:53:48 +01:00
|
|
|
|
|
|
|
public function testGetBranches():void{
|
|
|
|
$this->assertEquals(3, $this->treeService->getBranches()->count());
|
|
|
|
}
|
2018-11-18 10:50:18 +01:00
|
|
|
}
|
|
|
|
|