Solved function tests

This commit is contained in:
Kevin Frantz 2019-04-13 21:22:16 +02:00
parent 74aad46978
commit 9530944d17
5 changed files with 39 additions and 12 deletions

View File

@ -33,8 +33,9 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
private function isValidActionData(string $actionType, $data): bool private function isValidActionData(string $actionType, $data): bool
{ {
switch ($actionType) { switch ($actionType) {
case ActionType::READ:
case ActionType::CREATE: case ActionType::CREATE:
return $data instanceof EntityInterface | null === $data;
case ActionType::READ:
case ActionType::UPDATE: case ActionType::UPDATE:
return $data instanceof EntityInterface; return $data instanceof EntityInterface;
case ActionType::DELETE: case ActionType::DELETE:

View File

@ -4,6 +4,8 @@ namespace Infinito\Domain\DataAccessManagement;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
use Infinito\DBAL\Types\ActionType;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -15,12 +17,18 @@ final class ActionsViewsDAOService extends AbstractActionsDAO implements Actions
*/ */
private $actionsResultsDAO; private $actionsResultsDAO;
/**
* @var RequestedActionFormBuilderServiceInterface
*/
private $requestedActionFormBuilderService;
/** /**
* @param ActionsResultsDAOServiceInterface $actionsResultsDAO * @param ActionsResultsDAOServiceInterface $actionsResultsDAO
*/ */
public function __construct(ActionsResultsDAOServiceInterface $actionsResultsDAO) public function __construct(ActionsResultsDAOServiceInterface $actionsResultsDAO, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService)
{ {
$this->actionsResultsDAO = $actionsResultsDAO; $this->actionsResultsDAO = $actionsResultsDAO;
$this->requestedActionFormBuilderService = $requestedActionFormBuilderService;
} }
/** /**
@ -50,6 +58,13 @@ final class ActionsViewsDAOService extends AbstractActionsDAO implements Actions
return $storedData; return $storedData;
} }
private function getCreateForm()
{
return $this->requestedActionFormBuilderService->createByService()
->getForm()
->createView();
}
/** /**
* @todo Implement the mapping * @todo Implement the mapping
* {@inheritdoc} * {@inheritdoc}
@ -58,6 +73,11 @@ final class ActionsViewsDAOService extends AbstractActionsDAO implements Actions
*/ */
public function getData(string $actionType) public function getData(string $actionType)
{ {
switch ($actionType) {
case ActionType::CREATE:
return $this->getCreateForm();
}
return $this->actionsResultsDAO->getData($actionType); return $this->actionsResultsDAO->getData($actionType);
} }
} }

View File

@ -90,11 +90,8 @@ final class ProcessService implements ProcessServiceInterface
} else { } else {
// @todo move to view // @todo move to view
// CREATE // CREATE
//$this->requestedActionService->getRequestedEntity()->setClass(TextSource::class); $this->requestedActionService->getRequestedEntity()->setClass(TextSource::class);
// $updateForm = $this->requestedActionFormBuilderService->createByService() $this->actionsResultsDAOService->setData(ActionType::CREATE, null);
// ->getForm()
// ->createView();
//$this->actionsResultsDAOService->setData(ActionType::CREATE, $updateForm);
} }
return $this->actionsResultsDAOService; return $this->actionsResultsDAOService;

View File

@ -3,7 +3,6 @@
namespace Infinito\Domain\ViewManagement; namespace Infinito\Domain\ViewManagement;
use FOS\RestBundle\View\View; use FOS\RestBundle\View\View;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Infinito\Domain\ActionManagement\ActionServiceInterface; use Infinito\Domain\ActionManagement\ActionServiceInterface;
use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface; use Infinito\Domain\ActionManagement\ActionFactoryServiceInterface;
use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface; use Infinito\Domain\TemplateManagement\TemplateNameServiceInterface;
@ -33,7 +32,7 @@ final class ViewBuilder implements ViewBuilderInterface
private $view; private $view;
/** /**
* @var RequestedActionInterface * @var ActionServiceInterface
*/ */
private $actionService; private $actionService;
@ -91,8 +90,10 @@ final class ViewBuilder implements ViewBuilderInterface
} }
/** /**
* @param ActionServiceInterface $actionService * @param ActionServiceInterface $actionService
* @param ActionFactoryServiceInterface $actionFactoryService * @param ActionFactoryServiceInterface $actionFactoryService
* @param TemplateNameServiceInterface $templateNameService
* @param ValidGetParameterServiceInterface $validGetParameterService
*/ */
public function __construct(ActionServiceInterface $actionService, ActionFactoryServiceInterface $actionFactoryService, TemplateNameServiceInterface $templateNameService, 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 public function getView(): View
{ {
$template = $this->getTemplate(); $template = $this->getTemplate();
$this->view->setTemplate($template); $this->view->setTemplate($template);
return $this->view; return $this->view;

View File

@ -13,6 +13,7 @@ use Infinito\Domain\DataAccessManagement\ActionsResultsDAOService;
use Infinito\Domain\DataAccessManagement\ActionsViewsDAOService; use Infinito\Domain\DataAccessManagement\ActionsViewsDAOService;
use Infinito\Entity\EntityInterface; use Infinito\Entity\EntityInterface;
use Infinito\Logic\Result\ResultInterface; use Infinito\Logic\Result\ResultInterface;
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -29,6 +30,11 @@ class ActionViewsDAOServiceIntegrationTest extends TestCase
*/ */
private $actionsResultsDAO; private $actionsResultsDAO;
/**
* @var RequestedActionFormBuilderServiceInterface
*/
private $requestedActionFormBuilderService;
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
@ -36,8 +42,9 @@ class ActionViewsDAOServiceIntegrationTest extends TestCase
*/ */
public function setUp(): void public function setUp(): void
{ {
$this->requestedActionFormBuilderService = $this->createMock(RequestedActionFormBuilderServiceInterface::class);
$this->actionsResultsDAO = new ActionsResultsDAOService(); $this->actionsResultsDAO = new ActionsResultsDAOService();
$this->actionsViewsDAO = new ActionsViewsDAOService($this->actionsResultsDAO); $this->actionsViewsDAO = new ActionsViewsDAOService($this->actionsResultsDAO, $this->requestedActionFormBuilderService);
} }
public function testNotValidChoiceSetException(): void public function testNotValidChoiceSetException(): void