Injected requestedAction as Service

This commit is contained in:
Kevin Frantz 2019-02-13 15:47:46 +01:00
parent 54b0d98ef3
commit 6563a9fb5a
2 changed files with 11 additions and 9 deletions

View File

@ -3,7 +3,6 @@
namespace App\Domain\ActionManagement;
use App\Domain\RequestManagement\Action\RequestedActionInterface;
use App\Domain\SecureManagement\SecureRequestedRightCheckerInterface;
use App\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
@ -11,6 +10,8 @@ use App\Repository\RepositoryInterface;
use Symfony\Component\Form\FormBuilderInterface;
use Doctrine\ORM\EntityManagerInterface;
use App\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
use App\Domain\RequestManagement\Action\RequestedActionServiceInterface;
use App\Domain\SecureManagement\SecureRequestedRightCheckerInterface;
/**
* @author kevinfrantz
@ -48,11 +49,11 @@ final class ActionService implements ActionServiceInterface
private $entityManager;
/**
* @param RequestedActionInterface $requestedAction
* @param RequestedActionInterface $requestedActionService
*/
public function __construct(RequestedActionInterface $requestedAction, SecureRequestedRightCheckerInterface $secureRequestedRightChecker, RequestStack $requestStack, LayerRepositoryFactoryServiceInterface $layerRepositoryFactoryService, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService, EntityManagerInterface $entityManager)
public function __construct(RequestedActionServiceInterface $requestedActionService, SecureRequestedRightCheckerInterface $secureRequestedRightChecker, RequestStack $requestStack, LayerRepositoryFactoryServiceInterface $layerRepositoryFactoryService, RequestedActionFormBuilderServiceInterface $requestedActionFormBuilderService, EntityManagerInterface $entityManager)
{
$this->requestedAction = $requestedAction;
$this->requestedAction = $requestedActionService;
$this->secureRequestedRightChecker = $secureRequestedRightChecker;
$this->requestStack = $requestStack;
$this->layerRepositoryFactoryService = $layerRepositoryFactoryService;

View File

@ -17,6 +17,7 @@ use PHPUnit\Framework\MockObject\MockObject;
use App\Entity\EntityInterface;
use Symfony\Component\Form\FormBuilderInterface;
use App\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
use App\Domain\RequestManagement\Action\RequestedActionServiceInterface;
/**
* @author kevinfrantz
@ -24,9 +25,9 @@ use App\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
class ActionServiceTest extends TestCase
{
/**
* @var RequestedActionInterface|MockObject
* @var RequestedActionServiceInterface|MockObject
*/
private $requestedAction;
private $requestedActionService;
/**
* @var SecureRequestedRightCheckerInterface|MockObject
@ -75,15 +76,15 @@ class ActionServiceTest extends TestCase
$this->requestedEntity = $this->createMock(RequestedEntityInterface::class);
$this->requestedEntity->method('getEntity')->willReturn($this->entity);
$this->requestedAction = $this->createMock(RequestedActionInterface::class);
$this->requestedAction->method('getRequestedEntity')->willReturn($this->requestedEntity);
$this->requestedActionService = $this->createMock(RequestedActionServiceInterface::class);
$this->requestedActionService->method('getRequestedEntity')->willReturn($this->requestedEntity);
$this->secureRequestedRightChecker = $this->createMock(SecureRequestedRightCheckerInterface::class);
$this->requestedActionFormBuilderService = $this->createMock(RequestedActionFormBuilderServiceInterface::class);
$this->requestStack = $this->createMock(RequestStack::class);
$this->layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$this->entityManager = $this->createMock(EntityManagerInterface::class);
$this->actionService = new ActionService($this->requestedAction, $this->secureRequestedRightChecker, $this->requestStack, $this->layerRepositoryFactoryService, $this->requestedActionFormBuilderService, $this->entityManager);
$this->actionService = new ActionService($this->requestedActionService, $this->secureRequestedRightChecker, $this->requestStack, $this->layerRepositoryFactoryService, $this->requestedActionFormBuilderService, $this->entityManager);
}
public function testIsRequestedActionSecure(): void