mirror of
				https://github.com/kevinveenbirkenbach/infinito.git
				synced 2025-10-31 09:19:08 +00:00 
			
		
		
		
	Implemented ActionManagement
This commit is contained in:
		| @@ -0,0 +1,51 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\ActionManagement; | ||||
|  | ||||
| use App\Domain\RequestManagement\Action\RequestedActionInterface; | ||||
| use App\Domain\SecureManagement\SecureRequestedRightCheckerInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| final class ActionService implements ActionServiceInterface | ||||
| { | ||||
|     /** | ||||
|      * @var RequestedActionInterface | ||||
|      */ | ||||
|     private $requestedAction; | ||||
|  | ||||
|     /** | ||||
|      * @var SecureRequestedRightCheckerInterface | ||||
|      */ | ||||
|     private $secureRequestedRightChecker; | ||||
|  | ||||
|     /** | ||||
|      * @param RequestedActionInterface $requestedAction | ||||
|      */ | ||||
|     public function __construct(RequestedActionInterface $requestedAction, SecureRequestedRightCheckerInterface $secureRequestedRightChecker) | ||||
|     { | ||||
|         $this->requestedAction = $requestedAction; | ||||
|         $this->secureRequestedRightChecker = $secureRequestedRightChecker; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \App\Domain\ActionManagement\ActionServiceInterface::getRequestedAction() | ||||
|      */ | ||||
|     public function getRequestedAction(): RequestedActionInterface | ||||
|     { | ||||
|         return $this->requestedAction; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * {@inheritdoc} | ||||
|      * | ||||
|      * @see \App\Domain\ActionManagement\ActionServiceInterface::isRequestedActionSecure() | ||||
|      */ | ||||
|     public function isRequestedActionSecure(): bool | ||||
|     { | ||||
|         return $this->secureRequestedRightChecker->check($this->requestedAction); | ||||
|     } | ||||
| } | ||||
| @@ -0,0 +1,23 @@ | ||||
| <?php | ||||
|  | ||||
| namespace App\Domain\ActionManagement; | ||||
|  | ||||
| use App\Domain\RequestManagement\Action\RequestedActionInterface; | ||||
|  | ||||
| /** | ||||
|  * This interface offers all classes for managing an Action. | ||||
|  * | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| interface ActionServiceInterface | ||||
| { | ||||
|     /** | ||||
|      * @return RequestedActionInterface Returns the requested action | ||||
|      */ | ||||
|     public function getRequestedAction(): RequestedActionInterface; | ||||
|  | ||||
|     /** | ||||
|      * @return bool true if the action permissions are right | ||||
|      */ | ||||
|     public function isRequestedActionSecure(): bool; | ||||
| } | ||||
| @@ -0,0 +1,31 @@ | ||||
| <?php | ||||
|  | ||||
| namespace tests\Unit\Domain\ActionManagement; | ||||
|  | ||||
| use PHPUnit\Framework\TestCase; | ||||
| use App\Domain\ActionManagement\ActionService; | ||||
| use App\Domain\RequestManagement\Action\RequestedActionInterface; | ||||
| use App\Domain\SecureManagement\SecureRequestedRightCheckerInterface; | ||||
|  | ||||
| /** | ||||
|  * @author kevinfrantz | ||||
|  */ | ||||
| class ActionServiceTest extends TestCase | ||||
| { | ||||
|     public function testIsRequestedActionSecure() | ||||
|     { | ||||
|         $requestedAction = $this->createMock(RequestedActionInterface::class); | ||||
|         $secureRequestedRightChecker = $this->createMock(SecureRequestedRightCheckerInterface::class); | ||||
|         $secureRequestedRightChecker->method('check')->willReturn(true); | ||||
|         $actionService = new ActionService($requestedAction, $secureRequestedRightChecker); | ||||
|         $this->assertTrue($actionService->isRequestedActionSecure()); | ||||
|     } | ||||
|  | ||||
|     public function testRequestedActionGetter() | ||||
|     { | ||||
|         $requestedAction = $this->createMock(RequestedActionInterface::class); | ||||
|         $secureRequestedRightChecker = $this->createMock(SecureRequestedRightCheckerInterface::class); | ||||
|         $actionService = new ActionService($requestedAction, $secureRequestedRightChecker); | ||||
|         $this->assertInstanceOf(RequestedActionInterface::class, $actionService->getRequestedAction()); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user