infinito/application/tests/Unit/Domain/SourceManagement/TreeSourceServiceTest.php

57 lines
1.9 KiB
PHP
Raw Normal View History

<?php
2018-11-18 11:41:24 +01:00
2018-11-18 11:47:26 +01:00
namespace Tests\Unit\Domain\SourceManagement;
use PHPUnit\Framework\TestCase;
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;
2018-11-18 11:41:24 +01:00
public function setUp(): void
{
$tree1 = new TreeCollectionSource();
$tree2 = new TreeCollectionSource();
$tree3 = new TreeCollectionSource();
$tree4 = new TreeCollectionSource();
2018-11-18 11:47:26 +01:00
$tree5 = new TreeCollectionSource(new ArrayCollection([$tree2]));
$leave1 = $this->createMock(SourceInterface::class);
$leave2 = $this->createMock(SourceInterface::class);
2018-11-18 11:13:36 +01:00
$leave3 = $this->createMock(SourceInterface::class);
$leave4 = $this->createMock(SourceInterface::class);
2018-11-18 11:34:38 +01:00
$leave5 = $this->createMock(SourceInterface::class);
2018-11-18 11:41:24 +01:00
$tree2->setCollection(new ArrayCollection([$leave3, $leave4, $tree5, $leave5]));
$collection = new ArrayCollection([$tree2, $tree3, $leave1, $leave2, $tree4, $tree1]);
$tree1->setCollection($collection);
$this->treeService = new TreeSourceService($tree1);
}
2018-11-18 11:41:24 +01:00
public function testGetLeaves(): void
{
$this->assertEquals(2, $this->treeService->getLeaves()->count());
}
2018-11-18 11:41:24 +01:00
public function testGetBranches(): void
{
2018-11-18 11:39:06 +01:00
$this->assertEquals(4, $this->treeService->getBranches()->count());
}
2018-11-18 11:41:24 +01:00
public function testGetAllBranches(): void
{
2018-11-18 11:39:06 +01:00
$this->assertEquals(5, $this->treeService->getAllBranches()->count());
2018-11-18 11:13:36 +01:00
}
2018-11-18 11:41:24 +01:00
public function testGetAllLeaves(): void
{
2018-11-18 11:34:38 +01:00
$this->assertEquals(5, $this->treeService->getAllLeaves()->count());
2018-11-18 11:13:36 +01:00
}
}