mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2024-12-04 23:17:19 +01:00
Solved function tests
This commit is contained in:
parent
74aad46978
commit
9530944d17
@ -33,8 +33,9 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
|
||||
private function isValidActionData(string $actionType, $data): bool
|
||||
{
|
||||
switch ($actionType) {
|
||||
case ActionType::READ:
|
||||
case ActionType::CREATE:
|
||||
return $data instanceof EntityInterface | null === $data;
|
||||
case ActionType::READ:
|
||||
case ActionType::UPDATE:
|
||||
return $data instanceof EntityInterface;
|
||||
case ActionType::DELETE:
|
||||
|
@ -4,6 +4,8 @@ namespace Infinito\Domain\DataAccessManagement;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
|
||||
use Infinito\DBAL\Types\ActionType;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -15,12 +17,18 @@ final class ActionsViewsDAOService extends AbstractActionsDAO implements Actions
|
||||
*/
|
||||
private $actionsResultsDAO;
|
||||
|
||||
/**
|
||||
* @var RequestedActionFormBuilderServiceInterface
|
||||
*/
|
||||
private $requestedActionFormBuilderService;
|
||||
|
||||
/**
|
||||
* @param ActionsResultsDAOServiceInterface $actionsResultsDAO
|
||||
*/
|
||||
public function __construct(ActionsResultsDAOServiceInterface $actionsResultsDAO)
|
||||
public function __construct(ActionsResultsDAOServiceInterface $actionsResultsDAO, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService)
|
||||
{
|
||||
$this->actionsResultsDAO = $actionsResultsDAO;
|
||||
$this->requestedActionFormBuilderService = $requestedActionFormBuilderService;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,6 +58,13 @@ final class ActionsViewsDAOService extends AbstractActionsDAO implements Actions
|
||||
return $storedData;
|
||||
}
|
||||
|
||||
private function getCreateForm()
|
||||
{
|
||||
return $this->requestedActionFormBuilderService->createByService()
|
||||
->getForm()
|
||||
->createView();
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Implement the mapping
|
||||
* {@inheritdoc}
|
||||
@ -58,6 +73,11 @@ final class ActionsViewsDAOService extends AbstractActionsDAO implements Actions
|
||||
*/
|
||||
public function getData(string $actionType)
|
||||
{
|
||||
switch ($actionType) {
|
||||
case ActionType::CREATE:
|
||||
return $this->getCreateForm();
|
||||
}
|
||||
|
||||
return $this->actionsResultsDAO->getData($actionType);
|
||||
}
|
||||
}
|
||||
|
@ -90,11 +90,8 @@ final class ProcessService implements ProcessServiceInterface
|
||||
} else {
|
||||
// @todo move to view
|
||||
// CREATE
|
||||
//$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
|
||||
// $updateForm = $this->requestedActionFormBuilderService->createByService()
|
||||
// ->getForm()
|
||||
// ->createView();
|
||||
//$this->actionsResultsDAOService->setData(ActionType::CREATE, $updateForm);
|
||||
$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
|
||||
$this->actionsResultsDAOService->setData(ActionType::CREATE, null);
|
||||
}
|
||||
|
||||
return $this->actionsResultsDAOService;
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace Infinito\Domain\ViewManagement;
|
||||
|
||||
use FOS\RestBundle\View\View;
|
||||
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionServiceInterface;
|
||||
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
|
||||
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
|
||||
@ -33,7 +32,7 @@ final class ViewBuilder implements ViewBuilderInterface
|
||||
private $view;
|
||||
|
||||
/**
|
||||
* @var RequestedActionInterface
|
||||
* @var ActionServiceInterface
|
||||
*/
|
||||
private $actionService;
|
||||
|
||||
@ -91,8 +90,10 @@ final class ViewBuilder implements ViewBuilderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ActionServiceInterface $actionService
|
||||
* @param ActionFactoryServiceInterface $actionFactoryService
|
||||
* @param ActionServiceInterface $actionService
|
||||
* @param ActionFactoryServiceInterface $actionFactoryService
|
||||
* @param TemplateNameServiceInterface $templateNameService
|
||||
* @param ValidGetParameterServiceInterface $validGetParameterService
|
||||
*/
|
||||
public function __construct(ActionServiceInterface $actionService, ActionFactoryServiceInterface $actionFactoryService, TemplateNameServiceInterface $templateNameService, ValidGetParameterServiceInterface $validGetParameterService)
|
||||
{
|
||||
@ -108,6 +109,7 @@ final class ViewBuilder implements ViewBuilderInterface
|
||||
public function getView(): View
|
||||
{
|
||||
$template = $this->getTemplate();
|
||||
|
||||
$this->view->setTemplate($template);
|
||||
|
||||
return $this->view;
|
||||
|
@ -13,6 +13,7 @@ use Infinito\Domain\DataAccessManagement\ActionsResultsDAOService;
|
||||
use Infinito\Domain\DataAccessManagement\ActionsViewsDAOService;
|
||||
use Infinito\Entity\EntityInterface;
|
||||
use Infinito\Logic\Result\ResultInterface;
|
||||
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -29,6 +30,11 @@ class ActionViewsDAOServiceIntegrationTest extends TestCase
|
||||
*/
|
||||
private $actionsResultsDAO;
|
||||
|
||||
/**
|
||||
* @var RequestedActionFormBuilderServiceInterface
|
||||
*/
|
||||
private $requestedActionFormBuilderService;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
@ -36,8 +42,9 @@ class ActionViewsDAOServiceIntegrationTest extends TestCase
|
||||
*/
|
||||
public function setUp(): void
|
||||
{
|
||||
$this->requestedActionFormBuilderService = $this->createMock(RequestedActionFormBuilderServiceInterface::class);
|
||||
$this->actionsResultsDAO = new ActionsResultsDAOService();
|
||||
$this->actionsViewsDAO = new ActionsViewsDAOService($this->actionsResultsDAO);
|
||||
$this->actionsViewsDAO = new ActionsViewsDAOService($this->actionsResultsDAO, $this->requestedActionFormBuilderService);
|
||||
}
|
||||
|
||||
public function testNotValidChoiceSetException(): void
|
||||
|
Loading…
Reference in New Issue
Block a user