mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-09-13 13:57:10 +02:00
Implemented SourceRESTResponseManager and cleaned up code
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
|
||||
namespace Unit\Domain\ResponseManagement;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use App\Entity\Meta\RightInterface;
|
||||
use App\Entity\Meta\Right;
|
||||
use FOS\RestBundle\View\ViewHandlerInterface;
|
||||
use App\Entity\Source\PureSource;
|
||||
use App\DBAL\Types\SystemSlugType;
|
||||
use App\DBAL\Types\LayerType;
|
||||
use App\DBAL\Types\RightType;
|
||||
use App\Domain\ResponseManagement\SourceRESTResponseManager;
|
||||
use App\Exception\AllreadyDefinedException;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
*
|
||||
* @todo Implement more tests!
|
||||
*/
|
||||
class SourceRESTReponseManagerTest extends KernelTestCase
|
||||
{
|
||||
/**
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
private $entityManager;
|
||||
|
||||
/**
|
||||
* @var RightInterface
|
||||
*/
|
||||
private $requestedRight;
|
||||
|
||||
/**
|
||||
* @var ViewHandlerInterface
|
||||
*/
|
||||
private $viewHandler;
|
||||
|
||||
private function setRequestedRight(): void
|
||||
{
|
||||
$this->requestedRight = new Right();
|
||||
}
|
||||
|
||||
private function setEntityManager(): void
|
||||
{
|
||||
$this->entityManager = self::$container->get('doctrine.orm.default_entity_manager');
|
||||
}
|
||||
|
||||
private function setViewHandler(): void
|
||||
{
|
||||
$this->viewHandler = $this->createMock(ViewHandlerInterface::class);
|
||||
}
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
self::bootKernel();
|
||||
$this->setEntityManager();
|
||||
$this->setRequestedRight();
|
||||
$this->setViewHandler();
|
||||
}
|
||||
|
||||
public function testAllreadyDefinedException(): void
|
||||
{
|
||||
$requestedSource = new PureSource();
|
||||
$requestedSource->setSlug(SystemSlugType::IMPRINT);
|
||||
$requestedRight = new Right();
|
||||
$requestedRight->setSource($requestedSource);
|
||||
$requestedRight->setReciever(new PureSource());
|
||||
$requestedRight->setLayer(LayerType::SOURCE);
|
||||
$requestedRight->setType(RightType::READ);
|
||||
$this->expectException(AllreadyDefinedException::class);
|
||||
$sourceResponseManager = new SourceRESTResponseManager(null, $this->entityManager, $requestedRight, $this->viewHandler);
|
||||
$sourceResponseManager->getResponse();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user