Finished refactoring of exceptions

This commit is contained in:
Kevin Frantz 2019-04-15 01:37:17 +02:00
parent 9f179ead73
commit 06f69675ac
49 changed files with 159 additions and 135 deletions

View File

@ -19,6 +19,7 @@ trait ActionTypeAttribut
/** /**
* @param string $actionType * @param string $actionType
*
* @throws InvalidChoiceTypeException * @throws InvalidChoiceTypeException
*/ */
public function setActionType(string $actionType): void public function setActionType(string $actionType): void

View File

@ -1,25 +1,22 @@
<?php <?php
namespace Infinito\Attribut; namespace Infinito\Attribut;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
*
* @see ClassAttributInterface * @see ClassAttributInterface
* *
* @author kevinfrantz * @author kevinfrantz
*/ */
trait ClassAttribut trait ClassAttribut
{ {
/** /**
*
* @var string * @var string
*/ */
private $class; private $class;
/** /**
*
* @param string $class * @param string $class
*/ */
public function setClass(string $class): void public function setClass(string $class): void
@ -29,11 +26,10 @@ trait ClassAttribut
return; return;
} }
throw new NotFoundHttpException('Class ' . $class . ' couldn\'t be found!'); throw new NotFoundHttpException('Class '.$class.' couldn\'t be found!');
} }
/** /**
*
* @return string * @return string
*/ */
public function getClass(): string public function getClass(): string
@ -42,7 +38,6 @@ trait ClassAttribut
} }
/** /**
*
* @return bool * @return bool
*/ */
public function hasClass(): bool public function hasClass(): bool

View File

@ -7,6 +7,7 @@ use Infinito\Exception\Type\InvalidChoiceTypeException;
/** /**
* @author kevinfrantz * @author kevinfrantz
*
* @see CrudAttributInterface * @see CrudAttributInterface
*/ */
trait CrudAttribut trait CrudAttribut

View File

@ -20,8 +20,8 @@ trait LayerAttribut
protected $layer; protected $layer;
/** /**
*
* @param string $layer * @param string $layer
*
* @throws InvalidChoiceTypeException * @throws InvalidChoiceTypeException
*/ */
public function setLayer(string $layer): void public function setLayer(string $layer): void

View File

@ -18,8 +18,9 @@ trait SlugAttribut
/** /**
* @todo Maybe throw an other Exception here? * @todo Maybe throw an other Exception here?
*
* @param string $slug * @param string $slug
* *
* @throws ValueInvalidException * @throws ValueInvalidException
*/ */
public function setSlug(string $slug): void public function setSlug(string $slug): void

View File

@ -3,8 +3,8 @@
namespace Infinito\Domain\ActionManagement; namespace Infinito\Domain\ActionManagement;
use Infinito\Entity\EntityInterface; use Infinito\Entity\EntityInterface;
use Infinito\Exception\NotSecureException; use Infinito\Exception\Validation\FormInvalidException;
use Infinito\Exception\NotValidByFormException; use Infinito\Exception\Permission\NoPermissionException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -50,8 +50,8 @@ abstract class AbstractAction extends AbstractActionConstructor implements Actio
if ($this->isValid()) { if ($this->isValid()) {
return $this->proccess(); return $this->proccess();
} }
throw new NotValidByFormException('The requested Entity is not valid!'); throw new FormInvalidException('The requested Entity is not valid!');
} }
throw new NotSecureException("You don't have the permission to execute this action!"); throw new NoPermissionException("You don't have the permission to execute this action!");
} }
} }

View File

@ -48,6 +48,7 @@ final class ActionsResultsDAOService extends AbstractActionsDAO implements Actio
/** /**
* @param string $actionType * @param string $actionType
*
* @throws InvalidChoiceTypeException * @throws InvalidChoiceTypeException
*/ */
private function throwNoValidActionTypeException(string $actionType): void private function throwNoValidActionTypeException(string $actionType): void

View File

@ -5,7 +5,7 @@ namespace Infinito\Domain\FormManagement;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface; use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
use Infinito\Exception\Collection\NotSetException; use Infinito\Exception\Attribut\UndefinedAttributException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -25,12 +25,12 @@ class RequestedActionFormBuilder implements RequestedActionFormBuilderInterface
/** /**
* @param RequestedActionInterface $requestedAction * @param RequestedActionInterface $requestedAction
* *
* @throws NotSetException If the requested action can't be processed * @throws UndefinedAttributException If the requested action can't be processed
*/ */
private function validateRequestedAction(RequestedActionInterface $requestedAction): void private function validateRequestedAction(RequestedActionInterface $requestedAction): void
{ {
if (!$requestedAction->hasRequestedEntity()) { if (!$requestedAction->hasRequestedEntity()) {
throw new NotSetException('The <<requested entity>> attribut of a <<requested action>> must be set, to be processed by '.__CLASS__.'!'); throw new UndefinedAttributException('The <<requested entity>> attribut of a <<requested action>> must be set, to be processed by '.__CLASS__.'!');
} }
} }

View File

@ -4,7 +4,7 @@ namespace Infinito\Domain\LayerManagement;
use Infinito\DBAL\Types\Meta\Right\LayerType; use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Entity\Source\AbstractSource; use Infinito\Entity\Source\AbstractSource;
use Infinito\Exception\Collection\NotSetException; use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Entity\Meta\Law; use Infinito\Entity\Meta\Law;
use Infinito\Entity\Meta\Right; use Infinito\Entity\Meta\Right;
use Infinito\Entity\Meta\Relation\Parent\HeredityRelation; use Infinito\Entity\Meta\Relation\Parent\HeredityRelation;
@ -31,7 +31,7 @@ final class LayerClassMap implements LayerClassMapInterface
/** /**
* @param string $layer * @param string $layer
* *
* @throws NotSetException * @throws NotSetElementException
* *
* @return string * @return string
*/ */
@ -40,6 +40,6 @@ final class LayerClassMap implements LayerClassMapInterface
if (array_key_exists($layer, self::LAYER_CLASS_MAP)) { if (array_key_exists($layer, self::LAYER_CLASS_MAP)) {
return self::LAYER_CLASS_MAP[$layer]; return self::LAYER_CLASS_MAP[$layer];
} }
throw new NotSetException('The requested layer is not mapped!'); throw new NotSetElementException('The requested layer is not mapped!');
} }
} }

View File

@ -4,7 +4,7 @@ namespace Infinito\Domain\ParameterManagement;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Infinito\Exception\Attribut\UndefinedAttributException; use Infinito\Exception\Collection\NotSetElementException;
/** /**
* This class exists out of refactoring reasons. * This class exists out of refactoring reasons.
@ -71,6 +71,6 @@ abstract class AbstractGetParameterService implements GetParameterServiceInterfa
if ($this->hasParameter($key)) { if ($this->hasParameter($key)) {
return $this->currentRequest->get($key); return $this->currentRequest->get($key);
} }
throw new UndefinedAttributException("The parameter <<$key>> is not defined!"); throw new NotSetElementException("The parameter <<$key>> is not defined!");
} }
} }

View File

@ -6,7 +6,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use HaydenPierce\ClassFinder\ClassFinder; use HaydenPierce\ClassFinder\ClassFinder;
use Infinito\Domain\ParameterManagement\Parameter\ParameterInterface; use Infinito\Domain\ParameterManagement\Parameter\ParameterInterface;
use Infinito\Exception\Collection\NotSetElementException; use Infinito\Exception\Core\NotImplementedCoreException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -67,7 +67,7 @@ final class ParameterFactory implements ParameterFactoryInterface
if ($parameter) { if ($parameter) {
return $parameter; return $parameter;
} }
throw new NotSetElementException("The parameter for key <<$key>> doesn't exist! Generate a parameter class in the parameter folder!"); throw new NotImplementedCoreException("The parameter for key <<$key>> doesn't exist! Generate a parameter class in the parameter folder!");
} }
/** /**

View File

@ -4,6 +4,7 @@ namespace Infinito\Domain\ParameterManagement;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\Validator\Validator\ValidatorInterface;
use Infinito\Exception\Validation\GetParameterInvalidException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -34,8 +35,6 @@ final class ValidGetParametersService extends AbstractGetParameterService implem
/** /**
* @param string $key * @param string $key
*
* @throws UnvalidGetParameterException
*/ */
protected function validateParameter(string $key): void protected function validateParameter(string $key): void
{ {
@ -43,7 +42,7 @@ final class ValidGetParametersService extends AbstractGetParameterService implem
$parameter->setValue($this->currentRequest->get($key)); $parameter->setValue($this->currentRequest->get($key));
$errors = $this->validator->validate($parameter); $errors = $this->validator->validate($parameter);
foreach ($errors as $error) { foreach ($errors as $error) {
throw new UnvalidGetParameterException("Parameter <<$key>> didn't pass the validation; Message: <<".$error->getMessage().'>> ,Value: <<'.$parameter->getValue().'>> .'); throw new GetParameterInvalidException("Parameter <<$key>> didn't pass the validation; Message: <<".$error->getMessage().'>> ,Value: <<'.$parameter->getValue().'>> .');
} }
} }
} }

View File

@ -3,10 +3,9 @@
namespace Infinito\Domain\RequestManagement\Action; namespace Infinito\Domain\RequestManagement\Action;
use Doctrine\Common\Collections\Collection; use Doctrine\Common\Collections\Collection;
use Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Exception\AllreadySetException; use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Collection\NotSetException; use Infinito\Exception\Collection\NotSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -26,7 +25,7 @@ class RequestedActionStack implements RequestedActionStackInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface::containesRequestedAction() * @see \Infinito\Domain\RequestManagement\Action\RequestedActionStackInterface::containesRequestedAction()
*/ */
public function containesRequestedAction(string $actionType): bool public function containesRequestedAction(string $actionType): bool
{ {
@ -36,13 +35,13 @@ class RequestedActionStack implements RequestedActionStackInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface::addRequestedAction() * @see \Infinito\Domain\RequestManagement\Action\RequestedActionStackInterface::addRequestedAction()
*/ */
public function addRequestedAction(RequestedActionInterface $requestedAction): void public function addRequestedAction(RequestedActionInterface $requestedAction): void
{ {
$key = $requestedAction->getActionType(); $key = $requestedAction->getActionType();
if ($this->containesRequestedAction($key)) { if ($this->containesRequestedAction($key)) {
throw new AllreadySetException("The key is allready set <<$key>>!"); throw new ContainsElementException("The key is allready set <<$key>>!");
} }
$this->requestedActions->set($key, $requestedAction); $this->requestedActions->set($key, $requestedAction);
} }
@ -50,7 +49,7 @@ class RequestedActionStack implements RequestedActionStackInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface::getAllRequestedActions() * @see \Infinito\Domain\RequestManagement\Action\RequestedActionStackInterface::getAllRequestedActions()
*/ */
public function getAllRequestedActions(): Collection public function getAllRequestedActions(): Collection
{ {
@ -60,13 +59,13 @@ class RequestedActionStack implements RequestedActionStackInterface
/** /**
* {@inheritdoc} * {@inheritdoc}
* *
* @see \Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface::getRequestedAction() * @see \Infinito\Domain\RequestManagement\Action\RequestedActionStackInterface::getRequestedAction()
*/ */
public function getRequestedAction(string $actionType): RequestedActionInterface public function getRequestedAction(string $actionType): RequestedActionInterface
{ {
if ($this->requestedActions->containsKey($actionType)) { if ($this->requestedActions->containsKey($actionType)) {
return $this->requestedActions->get($actionType); return $this->requestedActions->get($actionType);
} }
throw new NotSetException(RequestedActionInterface::class." object for action type <<$actionType>> was not set!"); throw new NotSetElementException(RequestedActionInterface::class." object for action type <<$actionType>> was not set!");
} }
} }

View File

@ -44,9 +44,10 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
*/ */
private function validateHasIdentity(): void private function validateHasIdentity(): void
{ {
if (!($this->hasId() || $this->hasSlug())) { if ($this->hasId() || $this->hasSlug()) {
throw new NoIdentityCoreException('No identity attribut like id or slug was set!'); return;
} }
throw new NoIdentityCoreException('No identity attribut like id or slug was set!');
} }
/** /**
@ -56,9 +57,10 @@ class RequestedEntity extends AbstractEntity implements RequestedEntityInterface
*/ */
private function validateLoadedEntity(?EntityInterface $entity): void private function validateLoadedEntity(?EntityInterface $entity): void
{ {
if (!$entity) { if ($entity) {
throw new EntityNotFoundException('Entity with {id:"'.$this->id.'",slug:"'.$this->slug.'"} not found'); return;
} }
throw new EntityNotFoundException('Entity with {id:"'.$this->id.'",slug:"'.$this->slug.'"} not found');
} }
/** /**

View File

@ -11,8 +11,8 @@ use Infinito\Entity\Meta\MetaInterface;
use Infinito\Domain\RequestManagement\Entity\RequestedEntity; use Infinito\Domain\RequestManagement\Entity\RequestedEntity;
use Infinito\Attribut\ActionTypeAttribut; use Infinito\Attribut\ActionTypeAttribut;
use Infinito\Exception\Core\NotCorrectInstanceCoreException; use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Exception\NoIdentityCoreException; use Infinito\Exception\Core\NoIdentityCoreException;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException; use Infinito\Exception\Collection\ContainsElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -57,7 +57,7 @@ class RequestedRight implements RequestedRightInterface
if ($this->requestedEntity->hasIdentity()) { if ($this->requestedEntity->hasIdentity()) {
return; return;
} }
throw new NoIdentityCoreException(get_class($this->requestedEntity).' needs to have a defined attribut id or slug!'); throw new NoIdentityCoreException(get_class($this->requestedEntity).' needs to have a defined id or slug attribut!');
} }
/** /**
@ -79,7 +79,7 @@ class RequestedRight implements RequestedRightInterface
public function setActionType(string $actionType): void public function setActionType(string $actionType): void
{ {
if (isset($this->actionType)) { if (isset($this->actionType)) {
throw new AllreadyDefinedAttributException("The action type is allready set! Origine: $this->actionType New: $actionType"); throw new ContainsElementException("The action type is allready set! Origine: $this->actionType New: $actionType");
} }
$this->setActionTypeTrait($actionType); $this->setActionTypeTrait($actionType);
} }

View File

@ -4,9 +4,9 @@ namespace Infinito\Domain\RequestManagement\User;
use Infinito\Entity\Source\SourceInterface; use Infinito\Entity\Source\SourceInterface;
use Infinito\Domain\UserManagement\UserSourceDirectorInterface; use Infinito\Domain\UserManagement\UserSourceDirectorInterface;
use Infinito\Exception\SetNotPossibleException;
use Infinito\Domain\RequestManagement\Right\RequestedRightInterface; use Infinito\Domain\RequestManagement\Right\RequestedRightInterface;
use Infinito\Domain\RequestManagement\Right\AbstractRequestedRightFacade; use Infinito\Domain\RequestManagement\Right\AbstractRequestedRightFacade;
use Infinito\Exception\Collection\NotPossibleSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -37,7 +37,7 @@ class RequestedUser extends AbstractRequestedRightFacade implements RequestedUse
*/ */
public function setReciever(?SourceInterface $reciever): void public function setReciever(?SourceInterface $reciever): void
{ {
throw new SetNotPossibleException('It\'s not possible to set the reciever! Set it via '.UserSourceDirectorInterface::class.'!'); throw new NotPossibleSetElementException('It\'s not possible to set the reciever! Set it via '.UserSourceDirectorInterface::class.'!');
} }
/** /**

View File

@ -5,7 +5,7 @@ namespace Infinito\Domain\SecureManagement;
use Infinito\Entity\Meta\RightInterface; use Infinito\Entity\Meta\RightInterface;
use Infinito\Entity\Source\SourceInterface; use Infinito\Entity\Source\SourceInterface;
use Infinito\Domain\LawManagement\LawPermissionChecker; use Infinito\Domain\LawManagement\LawPermissionChecker;
use Infinito\Exception\SourceAccessDenied; use Infinito\Exception\Permission\NoSourcePermissionException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -62,7 +62,7 @@ final class SecureSourceChecker implements SecureSourceCheckerInterface
/** /**
* @param RightInterface $requestedRight * @param RightInterface $requestedRight
* *
* @throws SourceAccessDenied It's important to fire this exception to reduce complexity in debuging * @throws NoSourcePermissionException It's important to fire this exception to reduce complexity in debuging
* *
* @return bool * @return bool
*/ */
@ -77,7 +77,7 @@ final class SecureSourceChecker implements SecureSourceCheckerInterface
if ($this->isSource($attributExpectedSource)) { if ($this->isSource($attributExpectedSource)) {
$methodSecureSourceChecker = new self($attributExpectedSource); $methodSecureSourceChecker = new self($attributExpectedSource);
if (!$methodSecureSourceChecker->hasPermission($requestedSubSourceRight)) { if (!$methodSecureSourceChecker->hasPermission($requestedSubSourceRight)) {
throw new SourceAccessDenied('Access denied for subsource!'); throw new NoSourcePermissionException('Access denied for subsource!');
} }
} }
} }

View File

@ -3,7 +3,6 @@
namespace Infinito\Domain\SecureManagement; namespace Infinito\Domain\SecureManagement;
use Infinito\Entity\Meta\RightInterface; use Infinito\Entity\Meta\RightInterface;
use Infinito\Exception\SourceAccessDenied;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -11,8 +10,6 @@ use Infinito\Exception\SourceAccessDenied;
interface SecureSourceCheckerInterface interface SecureSourceCheckerInterface
{ {
/** /**
* @throws SourceAccessDenied
*
* @param RightInterface $right * @param RightInterface $right
* *
* @return bool * @return bool

View File

@ -4,12 +4,12 @@ namespace Infinito\Domain\SourceManagement;
use Infinito\Entity\Meta\RightInterface; use Infinito\Entity\Meta\RightInterface;
use Infinito\Entity\Source\SourceInterface; use Infinito\Entity\Source\SourceInterface;
use Infinito\Exception\AllreadySetException;
use Infinito\Entity\Source\AbstractSource; use Infinito\Entity\Source\AbstractSource;
use Infinito\Entity\Meta\Law; use Infinito\Entity\Meta\Law;
use Infinito\Exception\AllreadyDefinedException;
use Infinito\Exception\Collection\NotSetException;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException;
use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Collection\NotSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -30,7 +30,7 @@ final class SourceRightManager implements SourceRightManagerInterface
} }
/** /**
* @throws AllreadyDefinedException If the attribut is allready defined * @throws AllreadyDefinedAttributException If the attribut is allready defined
*/ */
private function checkRightAttributes(RightInterface $right): void private function checkRightAttributes(RightInterface $right): void
{ {
@ -38,7 +38,7 @@ final class SourceRightManager implements SourceRightManagerInterface
foreach ($attributes as $attribut) { foreach ($attributes as $attribut) {
try { try {
$right->{'get'.ucfirst($attribut)}(); $right->{'get'.ucfirst($attribut)}();
throw new AllreadyDefinedException("The attribut \"$attribut\" is allready defined!"); throw new AllreadyDefinedAttributException("The attribut \"$attribut\" is allready defined!");
} catch (\Error $error) { } catch (\Error $error) {
//Expected //Expected
} }
@ -61,7 +61,7 @@ final class SourceRightManager implements SourceRightManagerInterface
public function addRight(RightInterface $right): void public function addRight(RightInterface $right): void
{ {
if ($this->getRights()->contains($right)) { if ($this->getRights()->contains($right)) {
throw new AllreadySetException('The right was allready added.'); throw new ContainsElementException('The right was allready added.');
} }
$this->checkRightAttributes($right); $this->checkRightAttributes($right);
$right->setSource($this->source); $right->setSource($this->source);
@ -80,7 +80,7 @@ final class SourceRightManager implements SourceRightManagerInterface
}); });
$right->setLaw(new Law()); $right->setLaw(new Law());
if (!$this->getRights()->removeElement($right)) { if (!$this->getRights()->removeElement($right)) {
throw new NotSetException('The right to remove is not set.'); throw new NotSetElementException('The right to remove is not set.');
} }
} }
} }

View File

@ -3,9 +3,6 @@
namespace Infinito\Domain\SourceManagement; namespace Infinito\Domain\SourceManagement;
use Infinito\Entity\Meta\RightInterface; use Infinito\Entity\Meta\RightInterface;
use Infinito\Exception\AllreadySetException;
use Infinito\Exception\AllreadyDefinedException;
use Infinito\Exception\Collection\NotSetException;
/** /**
* Allows to add and remove rights of a source. * Allows to add and remove rights of a source.
@ -16,16 +13,11 @@ interface SourceRightManagerInterface
{ {
/** /**
* @param RightInterface $right * @param RightInterface $right
*
* @throws AllreadySetException
* @throws AllreadyDefinedException
*/ */
public function addRight(RightInterface $right): void; public function addRight(RightInterface $right): void;
/** /**
* @param RightInterface $right * @param RightInterface $right
*
* @throws NotSetException
*/ */
public function removeRight(RightInterface $right): void; public function removeRight(RightInterface $right): void;
} }

View File

@ -3,7 +3,7 @@
namespace Infinito\Domain\TwigManagement; namespace Infinito\Domain\TwigManagement;
use Infinito\DBAL\Types\ActionType; use Infinito\DBAL\Types\ActionType;
use Infinito\Exception\Collection\NotSetException; use Infinito\Exception\Collection\NotSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -31,6 +31,6 @@ final class ActionIconClassMap implements ActionIconClassMapInterface
if (key_exists($action, self::ACTION_ICON_CLASS_MAP)) { if (key_exists($action, self::ACTION_ICON_CLASS_MAP)) {
return self::ACTION_ICON_CLASS_MAP[$action]; return self::ACTION_ICON_CLASS_MAP[$action];
} }
throw new NotSetException("The key <<$action>> is not defined in the map!"); throw new NotSetElementException("The key <<$action>> is not defined in the map!");
} }
} }

View File

@ -2,8 +2,8 @@
namespace Infinito\Domain\TwigManagement; namespace Infinito\Domain\TwigManagement;
use Infinito\Exception\Collection\NotSetException;
use Infinito\DBAL\Types\Meta\Right\LayerType; use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Exception\Collection\NotSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -32,6 +32,6 @@ final class LayerIconClassMap implements LayerIconClassMapInterface
if (key_exists($layer, self::LAYER_ICON_CLASS_MAP)) { if (key_exists($layer, self::LAYER_ICON_CLASS_MAP)) {
return self::LAYER_ICON_CLASS_MAP[$layer]; return self::LAYER_ICON_CLASS_MAP[$layer];
} }
throw new NotSetException("The key <<$layer>> is not defined in the map!"); throw new NotSetElementException("The key <<$layer>> is not defined in the map!");
} }
} }

View File

@ -8,7 +8,7 @@ use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM; use Doctrine\ORM\Mapping as ORM;
use Infinito\Entity\Source\AbstractSource; use Infinito\Entity\Source\AbstractSource;
use Infinito\Entity\Source\Operation\Attribut\OperandsAttribut; use Infinito\Entity\Source\Operation\Attribut\OperandsAttribut;
use Infinito\Exception\NotProcessedException; use Infinito\Exception\Deprecated\NotProcessedException;
/** /**
* @author kevinfrantz * @author kevinfrantz

View File

@ -0,0 +1,10 @@
<?php
namespace Infinito\Exception\Core;
/**
* @author kevinfrantz
*/
final class NotImplementedCoreException extends \Exception
{
}

View File

@ -71,7 +71,7 @@ class RestRoutesReachableIntegrationTest extends KernelTestCase
]); ]);
$request->setMethod($method); $request->setMethod($method);
$response = static::$kernel->handle($request); $response = static::$kernel->handle($request);
$this->assertTrue($this->isResponseValid($response), "Route $url with Method $method sends an 404 response and doesn't throw an EntityNotFoundHttpException!"); $this->assertTrue($this->isResponseValid($response), "Route $url with Method $method sends an 404 response and doesn't throw an EntityNotFoundException!");
} }
/** /**
@ -82,7 +82,7 @@ class RestRoutesReachableIntegrationTest extends KernelTestCase
private function isResponseValid(Response $response): bool private function isResponseValid(Response $response): bool
{ {
$is404 = 404 === $response->getStatusCode(); $is404 = 404 === $response->getStatusCode();
$isEntityNotFoundHttpException = strpos($response->getContent(), 'EntityNotFoundHttpException'); $isEntityNotFoundHttpException = strpos($response->getContent(), 'EntityNotFoundException');
return !$is404 || $isEntityNotFoundHttpException; return !$is404 || $isEntityNotFoundHttpException;
} }

View File

@ -11,9 +11,9 @@ use Infinito\Entity\EntityInterface;
use Infinito\Logic\Result\ResultInterface; use Infinito\Logic\Result\ResultInterface;
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface; use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
use Infinito\Exception\Type\InvalidChoiceTypeException; use Infinito\Exception\Type\InvalidChoiceTypeException;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Exception\Collection\NotSetElementException; use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Collection\ContainsElementException; use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Validation\ValueInvalidException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -55,7 +55,7 @@ class ActionViewsDAOServiceIntegrationTest extends TestCase
public function testNotCorrectInstanceSetException(): void public function testNotCorrectInstanceSetException(): void
{ {
$this->expectException(NotCorrectInstanceCoreException::class); $this->expectException(ValueInvalidException::class);
$data = new class() { $data = new class() {
}; };
$this->actionsResultsDAO->setData(ActionType::READ, $data); $this->actionsResultsDAO->setData(ActionType::READ, $data);

View File

@ -13,11 +13,12 @@ use Infinito\Domain\ParameterManagement\Parameter\VersionParameter;
use Infinito\Domain\ParameterManagement\ParameterFactoryInterface; use Infinito\Domain\ParameterManagement\ParameterFactoryInterface;
use Infinito\Exception\Validation\GetParameterInvalidException; use Infinito\Exception\Validation\GetParameterInvalidException;
use Infinito\Exception\Collection\NotSetElementException; use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Core\NotImplementedCoreException;
/** /**
* @author kevinfrantz * @author kevinfrantz
*/ */
class ValidGetParameterServiceTest extends KernelTestCase class ValidGetParameterServiceIntegrationTest extends KernelTestCase
{ {
/** /**
* @var Request * @var Request
@ -72,10 +73,17 @@ class ValidGetParameterServiceTest extends KernelTestCase
$this->validGetParameterService->getParameter($versionKey); $this->validGetParameterService->getParameter($versionKey);
} }
public function testConstructor(): void public function testConstructorInvalid(): void
{
$this->currentRequest->query->set(VersionParameter::getKey(), 'adasa');
$this->expectException(GetParameterInvalidException::class);
new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator);
}
public function testConstructorNotImplemented(): void
{ {
$this->currentRequest->query->set('asdwgwe', 'adasa'); $this->currentRequest->query->set('asdwgwe', 'adasa');
$this->expectException(GetParameterInvalidException::class); $this->expectException(NotImplementedCoreException::class);
new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator); new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator);
} }

View File

@ -46,7 +46,7 @@ class SecureRequestedRightCheckerServiceIntegrationTest extends KernelTestCase
$requestedRight->setLayer($layer); $requestedRight->setLayer($layer);
$requestedRight->setReciever($reciever); $requestedRight->setReciever($reciever);
$requestedEntity = $this->createMock(RequestedEntityInterface::class); $requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('hasId')->willReturn(true); $requestedEntity->method('hasIdentity')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($source); $requestedEntity->method('getEntity')->willReturn($source);
$requestedRight->setRequestedEntity($requestedEntity); $requestedRight->setRequestedEntity($requestedEntity);
$result = $this->secureRequestedRightCheckerService->check($requestedRight); $result = $this->secureRequestedRightCheckerService->check($requestedRight);
@ -72,7 +72,7 @@ class SecureRequestedRightCheckerServiceIntegrationTest extends KernelTestCase
$requestedRight->setLayer($layer); $requestedRight->setLayer($layer);
$requestedRight->setReciever($reciever); $requestedRight->setReciever($reciever);
$requestedEntity = $this->createMock(RequestedEntityInterface::class); $requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('hasId')->willReturn(true); $requestedEntity->method('hasIdentity')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($source); $requestedEntity->method('getEntity')->willReturn($source);
$requestedRight->setRequestedEntity($requestedEntity); $requestedRight->setRequestedEntity($requestedEntity);
$result = $this->secureRequestedRightCheckerService->check($requestedRight); $result = $this->secureRequestedRightCheckerService->check($requestedRight);

View File

@ -5,7 +5,7 @@ namespace Tests\Attribut;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Attribut\SlugAttributInterface; use Infinito\Attribut\SlugAttributInterface;
use Infinito\Attribut\SlugAttribut; use Infinito\Attribut\SlugAttribut;
use Infinito\Exception\UnvalidValueException; use Infinito\Exception\Validation\ValueInvalidException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -42,7 +42,7 @@ class SlugAttributTest extends TestCase
public function testNumericSetException(): void public function testNumericSetException(): void
{ {
$this->expectException(UnvalidValueException::class); $this->expectException(ValueInvalidException::class);
$this->slugAttribut->setSlug('1234'); $this->slugAttribut->setSlug('1234');
} }
} }

View File

@ -10,8 +10,8 @@ use PHPUnit\Framework\TestCase;
use Infinito\Exception\Collection\ContainsElementException; use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Collection\NotSetElementException; use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Type\InvalidChoiceTypeException; use Infinito\Exception\Type\InvalidChoiceTypeException;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Domain\DataAccessManagement\ActionsResultsDAOServiceInterface; use Infinito\Domain\DataAccessManagement\ActionsResultsDAOServiceInterface;
use Infinito\Exception\Validation\ValueInvalidException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -41,7 +41,7 @@ class ActionResultsDAOServiceTest extends TestCase
public function testNotCorrectInstanceSetException(): void public function testNotCorrectInstanceSetException(): void
{ {
$this->expectException(NotCorrectInstanceCoreException::class); $this->expectException(ValueInvalidException::class);
$data = new class() { $data = new class() {
}; };
$this->actionsResultsDAO->setData(ActionType::READ, $data); $this->actionsResultsDAO->setData(ActionType::READ, $data);

View File

@ -7,7 +7,7 @@ use Infinito\Domain\ActionManagement\ActionInterface;
use Infinito\Domain\ActionManagement\AbstractAction; use Infinito\Domain\ActionManagement\AbstractAction;
use Infinito\Domain\ActionManagement\ActionDependenciesDAOServiceInterface; use Infinito\Domain\ActionManagement\ActionDependenciesDAOServiceInterface;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Infinito\Exception\NotValidByFormException; use Infinito\Exception\Validation\FormInvalidException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -51,7 +51,7 @@ class AbstractActionTest extends TestCase
{ {
$this->action->isSecure = true; $this->action->isSecure = true;
$this->action->validByForm = false; $this->action->validByForm = false;
$this->expectException(NotValidByFormException::class); $this->expectException(FormInvalidException::class);
$this->action->execute(); $this->action->execute();
} }
} }

View File

@ -7,10 +7,10 @@ use PHPUnit\Framework\TestCase;
use Infinito\Domain\ActionManagement\Read\ReadAction; use Infinito\Domain\ActionManagement\Read\ReadAction;
use Infinito\Domain\ActionManagement\ActionDependenciesDAOServiceInterface; use Infinito\Domain\ActionManagement\ActionDependenciesDAOServiceInterface;
use Infinito\Domain\ActionManagement\Read\ReadActionInterface; use Infinito\Domain\ActionManagement\Read\ReadActionInterface;
use Infinito\Exception\NotSecureException;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface; use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface; use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
use Infinito\Entity\Source\SourceInterface; use Infinito\Entity\Source\SourceInterface;
use Infinito\Exception\Permission\NoPermissionException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -59,7 +59,7 @@ class ReadSourceActionTest extends TestCase
public function testNotSecureException(): void public function testNotSecureException(): void
{ {
$this->actionService->method('isRequestedActionSecure')->willReturn(false); $this->actionService->method('isRequestedActionSecure')->willReturn(false);
$this->expectException(NotSecureException::class); $this->expectException(NoPermissionException::class);
$this->sourceReadAction->execute(); $this->sourceReadAction->execute();
} }

View File

@ -20,10 +20,10 @@ use Infinito\Attribut\RightsAttributInterface;
use Infinito\Entity\EntityInterface; use Infinito\Entity\EntityInterface;
use Infinito\Attribut\VersionAttribut; use Infinito\Attribut\VersionAttribut;
use Infinito\Attribut\IdAttribut; use Infinito\Attribut\IdAttribut;
use Infinito\Exception\NotCorrectInstanceException;
use Infinito\Entity\Source\Complex\UserSource; use Infinito\Entity\Source\Complex\UserSource;
use Infinito\Entity\User; use Infinito\Entity\User;
use Infinito\Attribut\UserAttributInterface; use Infinito\Attribut\UserAttributInterface;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -65,7 +65,7 @@ class EntityDomServiceTest extends TestCase
$entity->setTest(new class() { $entity->setTest(new class() {
}); });
$this->requestedEntityService->method('getEntity')->willReturn($entity); $this->requestedEntityService->method('getEntity')->willReturn($entity);
$this->expectException(NotCorrectInstanceException::class); $this->expectException(NotCorrectInstanceCoreException::class);
$this->entityDomService->getDomDocument(); $this->entityDomService->getDomDocument();
} }

View File

@ -3,11 +3,11 @@
namespace tests\Unit\Domain\FormManagement; namespace tests\Unit\Domain\FormManagement;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface; use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Infinito\Domain\FormManagement\RequestedActionFormBuilder; use Infinito\Domain\FormManagement\RequestedActionFormBuilder;
use Infinito\Domain\FormManagement\FormClassNameServiceInterface; use Infinito\Domain\FormManagement\FormClassNameServiceInterface;
use Symfony\Component\Form\FormFactoryInterface; use Symfony\Component\Form\FormFactoryInterface;
use Infinito\Exception\Attribut\UndefinedAttributException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -21,7 +21,7 @@ class RequestedActionFormBuilderTest extends TestCase
$formFactory = $this->createMock(FormFactoryInterface::class); $formFactory = $this->createMock(FormFactoryInterface::class);
$formClassNameService = $this->createMock(FormClassNameServiceInterface::class); $formClassNameService = $this->createMock(FormClassNameServiceInterface::class);
$requestedActionFormBuilder = new RequestedActionFormBuilder($formFactory, $formClassNameService); $requestedActionFormBuilder = new RequestedActionFormBuilder($formFactory, $formClassNameService);
$this->expectException(NotSetException::class); $this->expectException(UndefinedAttributException::class);
$requestedActionFormBuilder->create($requestedAction); $requestedActionFormBuilder->create($requestedAction);
} }
} }

View File

@ -5,7 +5,7 @@ namespace tests\Unit\Domain\ParameterManagement;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Domain\ParameterManagement\ParameterFactory; use Infinito\Domain\ParameterManagement\ParameterFactory;
use Infinito\Domain\ParameterManagement\Parameter\VersionParameter; use Infinito\Domain\ParameterManagement\Parameter\VersionParameter;
use Infinito\Exception\Collection\NotSetElementException; use Infinito\Exception\Core\NotImplementedCoreException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -27,7 +27,7 @@ class ParameterFactoryTest extends TestCase
$versionParameter = $parameterFactory->getParameter('version'); $versionParameter = $parameterFactory->getParameter('version');
$this->assertInstanceOf(VersionParameter::class, $versionParameter); $this->assertInstanceOf(VersionParameter::class, $versionParameter);
$this->assertEquals($versionParameter, $parameterFactory->getParameter('version')); $this->assertEquals($versionParameter, $parameterFactory->getParameter('version'));
$this->expectException(NotSetElementException::class); $this->expectException(NotImplementedCoreException::class);
$versionParameter = $parameterFactory->getParameter('blabalbal'); $versionParameter = $parameterFactory->getParameter('blabalbal');
} }
} }

View File

@ -4,7 +4,6 @@ namespace tests\Unit\Domain\ParameterManagement;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\RequestStack;
use Infinito\Exception\NotDefinedException;
use Infinito\Domain\ParameterManagement\Parameter\VersionParameter; use Infinito\Domain\ParameterManagement\Parameter\VersionParameter;
use Infinito\Domain\ParameterManagement\ParameterFactory; use Infinito\Domain\ParameterManagement\ParameterFactory;
use Infinito\Domain\ParameterManagement\ValidGetParametersService; use Infinito\Domain\ParameterManagement\ValidGetParametersService;
@ -13,6 +12,8 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
use Infinito\Domain\ParameterManagement\ValidGetParameterServiceInterface; use Infinito\Domain\ParameterManagement\ValidGetParameterServiceInterface;
use Infinito\Domain\ParameterManagement\Parameter\ViewParameter; use Infinito\Domain\ParameterManagement\Parameter\ViewParameter;
use Infinito\DBAL\Types\ActionType; use Infinito\DBAL\Types\ActionType;
use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Core\NotImplementedCoreException;
/** /**
* This class is a bit messed up because it is an recycled class of an other unit. * This class is a bit messed up because it is an recycled class of an other unit.
@ -69,13 +70,17 @@ class ValidGetParameterServiceTest extends KernelTestCase
$this->assertTrue($this->validGetParameterService->hasParameter($key)); $this->assertTrue($this->validGetParameterService->hasParameter($key));
$this->assertEquals($value, $this->validGetParameterService->getParameter($key)); $this->assertEquals($value, $this->validGetParameterService->getParameter($key));
} }
$this->expectException(NotDefinedException::class); }
public function testNotImplementedException(): void
{
$this->expectException(NotImplementedCoreException::class);
$this->validGetParameterService->getParameter('12312312asdas'); $this->validGetParameterService->getParameter('12312312asdas');
} }
public function testSetParameterException(): void public function testNotSetParameterException(): void
{ {
$this->expectException(NotDefinedException::class); $this->expectException(NotSetElementException::class);
$this->validGetParameterService->getParameter(VersionParameter::getKey()); $this->validGetParameterService->getParameter(VersionParameter::getKey());
} }
} }

View File

@ -6,8 +6,8 @@ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface; use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryService; use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryService;
use Infinito\Repository\RepositoryInterface; use Infinito\Repository\RepositoryInterface;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Domain\LayerManagement\LayerClassMap; use Infinito\Domain\LayerManagement\LayerClassMap;
use Infinito\Exception\Collection\NotSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -32,7 +32,7 @@ class LayerRepositoryFactoryServiceTest extends KernelTestCase
$repositoy = $this->layerRepositoryFactoryService->getRepository($layer); $repositoy = $this->layerRepositoryFactoryService->getRepository($layer);
$this->assertInstanceOf(RepositoryInterface::class, $repositoy); $this->assertInstanceOf(RepositoryInterface::class, $repositoy);
} }
$this->expectException(NotSetException::class); $this->expectException(NotSetElementException::class);
$repositoy = $this->layerRepositoryFactoryService->getRepository('UnknownLayer'); $repositoy = $this->layerRepositoryFactoryService->getRepository('UnknownLayer');
} }
} }

View File

@ -11,8 +11,9 @@ use Infinito\Repository\RepositoryInterface;
use Infinito\Entity\EntityInterface; use Infinito\Entity\EntityInterface;
use Infinito\Entity\Source\AbstractSource; use Infinito\Entity\Source\AbstractSource;
use Infinito\Exception\Attribut\UndefinedAttributException; use Infinito\Exception\Attribut\UndefinedAttributException;
use Infinito\Exception\NoIdentityCoreException; use Infinito\Exception\Core\NoIdentityCoreException;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException; use Infinito\Exception\Attribut\AllreadyDefinedAttributException;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -37,7 +38,7 @@ class RequestedEntityTest extends TestCase
{ {
$layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class); $layerRepositoryFactoryService = $this->createMock(LayerRepositoryFactoryServiceInterface::class);
$requestedEntity = new RequestedEntity($layerRepositoryFactoryService); $requestedEntity = new RequestedEntity($layerRepositoryFactoryService);
$this->expectException(UndefinedAttributException::class); $this->expectException(NoIdentityCoreException::class);
$requestedEntity->getEntity(); $requestedEntity->getEntity();
} }
@ -50,7 +51,7 @@ class RequestedEntityTest extends TestCase
$requestedEntity = new RequestedEntity($layerRepositoryFactoryService); $requestedEntity = new RequestedEntity($layerRepositoryFactoryService);
$requestedEntity->setSlug('abcd'); $requestedEntity->setSlug('abcd');
$requestedEntity->setRequestedRight($requestedRight); $requestedEntity->setRequestedRight($requestedRight);
$this->expectException(NoIdentityCoreException::class); $this->expectException(NotCorrectInstanceCoreException::class);
$requestedEntity->getEntity(); $requestedEntity->getEntity();
} }

View File

@ -12,10 +12,10 @@ use Infinito\Domain\UserManagement\UserSourceDirectorInterface;
use Infinito\Domain\RequestManagement\Right\RequestedRightInterface; use Infinito\Domain\RequestManagement\Right\RequestedRightInterface;
use Infinito\Domain\RequestManagement\Right\RequestedRight; use Infinito\Domain\RequestManagement\Right\RequestedRight;
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface; use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
use Infinito\Exception\SetNotPossibleException;
use Infinito\Entity\Source\SourceInterface; use Infinito\Entity\Source\SourceInterface;
use Infinito\Domain\RequestManagement\Right\AbstractRequestedRightFacade; use Infinito\Domain\RequestManagement\Right\AbstractRequestedRightFacade;
use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource; use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
use Infinito\Exception\Collection\NotPossibleSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -88,7 +88,7 @@ class AbstractRequestedRightFacadeTest extends TestCase
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class); $userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$requestedRight = $this->createMock(RequestedRightInterface::class); $requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight); $requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->expectException(SetNotPossibleException::class); $this->expectException(NotPossibleSetElementException::class);
$requestedUserRightFacade->setReciever($reciever); $requestedUserRightFacade->setReciever($reciever);
} }
} }

View File

@ -8,7 +8,6 @@ use Infinito\Domain\RequestManagement\Right\RequestedRight;
use Infinito\DBAL\Types\Meta\Right\LayerType; use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Domain\RequestManagement\Entity\RequestedEntity; use Infinito\Domain\RequestManagement\Entity\RequestedEntity;
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface; use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
use Infinito\Exception\PreconditionFailedException;
use Infinito\Entity\Source\PureSource; use Infinito\Entity\Source\PureSource;
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface; use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryServiceInterface;
use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryService; use Infinito\Domain\RepositoryManagement\LayerRepositoryFactoryService;
@ -16,8 +15,9 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Infinito\Entity\Meta\Law; use Infinito\Entity\Meta\Law;
use Infinito\Entity\Source\SourceInterface; use Infinito\Entity\Source\SourceInterface;
use Infinito\DBAL\Types\ActionType; use Infinito\DBAL\Types\ActionType;
use Infinito\Exception\AllreadySetException;
use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource; use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
use Infinito\Exception\Core\NoIdentityCoreException;
use Infinito\Exception\Collection\ContainsElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -59,7 +59,7 @@ class RequestedRightTest extends KernelTestCase
{ {
$requestedSource = $this->createMock(RequestedEntity::class); $requestedSource = $this->createMock(RequestedEntity::class);
$this->requestedRight->setRequestedEntity($requestedSource); $this->requestedRight->setRequestedEntity($requestedSource);
$this->expectException(PreconditionFailedException::class); $this->expectException(NoIdentityCoreException::class);
$this->requestedRight->getSource(); $this->requestedRight->getSource();
} }
@ -83,6 +83,7 @@ class RequestedRightTest extends KernelTestCase
$requestedEntity = $this->createMock(RequestedEntityInterface::class); $requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('getSlug')->willReturn($slug); $requestedEntity->method('getSlug')->willReturn($slug);
$requestedEntity->method('hasSlug')->willReturn(true); $requestedEntity->method('hasSlug')->willReturn(true);
$requestedEntity->method('hasIdentity')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($requestedEntityEntity); $requestedEntity->method('getEntity')->willReturn($requestedEntityEntity);
$this->assertEquals($slug, $requestedEntity->getSlug()); $this->assertEquals($slug, $requestedEntity->getSlug());
$this->requestedRight->setRequestedEntity($requestedEntity); $this->requestedRight->setRequestedEntity($requestedEntity);
@ -101,6 +102,7 @@ class RequestedRightTest extends KernelTestCase
$requestedEntity->method('getSlug')->willReturn($slug); $requestedEntity->method('getSlug')->willReturn($slug);
$requestedEntity->method('hasSlug')->willReturn(true); $requestedEntity->method('hasSlug')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($entity); $requestedEntity->method('getEntity')->willReturn($entity);
$requestedEntity->method('hasIdentity')->willReturn(true);
$this->assertEquals($slug, $requestedEntity->getSlug()); $this->assertEquals($slug, $requestedEntity->getSlug());
$this->requestedRight->setRequestedEntity($requestedEntity); $this->requestedRight->setRequestedEntity($requestedEntity);
$this->requestedRight->setLayer(LayerType::LAW); $this->requestedRight->setLayer(LayerType::LAW);
@ -113,7 +115,7 @@ class RequestedRightTest extends KernelTestCase
$attributType = ActionType::CREATE; $attributType = ActionType::CREATE;
$this->requestedRight->setActionType($attributType); $this->requestedRight->setActionType($attributType);
$this->assertEquals($attributType, $this->requestedRight->getActionType()); $this->assertEquals($attributType, $this->requestedRight->getActionType());
$this->expectException(AllreadySetException::class); $this->expectException(ContainsElementException::class);
$this->requestedRight->setActionType($attributType); $this->requestedRight->setActionType($attributType);
} }
} }

View File

@ -14,9 +14,9 @@ use Infinito\Domain\RequestManagement\Right\RequestedRight;
use Infinito\Domain\UserManagement\UserSourceDirector; use Infinito\Domain\UserManagement\UserSourceDirector;
use Infinito\Repository\Source\SourceRepositoryInterface; use Infinito\Repository\Source\SourceRepositoryInterface;
use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface; use Infinito\Domain\RequestManagement\Entity\RequestedEntityInterface;
use Infinito\Exception\SetNotPossibleException;
use Infinito\Exception\NotCorrectInstanceException;
use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource; use Infinito\Domain\FixtureManagement\FixtureSource\ImpressumFixtureSource;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Exception\Collection\NotPossibleSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -57,9 +57,10 @@ class RequestedUserTest extends TestCase
{ {
$layer = LayerType::SOURCE; $layer = LayerType::SOURCE;
$type = CRUDType::READ; $type = CRUDType::READ;
$requestedSource = $this->createMock(RequestedEntityInterface::class); $requestedEntitySource = $this->createMock(RequestedEntityInterface::class);
$requestedSource->method('getSlug')->willReturn(ImpressumFixtureSource::getSlug()); $requestedEntitySource->method('getSlug')->willReturn(ImpressumFixtureSource::getSlug());
$requestedSource->method('hasSlug')->willReturn(true); $requestedEntitySource->method('hasSlug')->willReturn(true);
$requestedEntitySource->method('hasIdentity')->willReturn(true);
$sourceRepository = $this->createMock(SourceRepositoryInterface::class); $sourceRepository = $this->createMock(SourceRepositoryInterface::class);
$requestedRight = new RequestedRight(); $requestedRight = new RequestedRight();
$user = $this->createMock(User::class); $user = $this->createMock(User::class);
@ -67,10 +68,10 @@ class RequestedUserTest extends TestCase
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight); $requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->assertNull($requestedUserRightFacade->setLayer($layer)); $this->assertNull($requestedUserRightFacade->setLayer($layer));
$this->assertNull($requestedUserRightFacade->setActionType($type)); $this->assertNull($requestedUserRightFacade->setActionType($type));
$this->assertNull($requestedUserRightFacade->setRequestedEntity($requestedSource)); $this->assertNull($requestedUserRightFacade->setRequestedEntity($requestedEntitySource));
$this->assertEquals($layer, $requestedRight->getLayer()); $this->assertEquals($layer, $requestedRight->getLayer());
$this->assertEquals($type, $requestedRight->getActionType()); $this->assertEquals($type, $requestedRight->getActionType());
$this->expectException(NotCorrectInstanceException::class); $this->expectException(NotCorrectInstanceCoreException::class);
$this->assertNotInstanceOf(RequestedEntityInterface::class, $requestedRight->getSource()); $this->assertNotInstanceOf(RequestedEntityInterface::class, $requestedRight->getSource());
} }
@ -80,7 +81,7 @@ class RequestedUserTest extends TestCase
$userSourceDirector = $this->createMock(UserSourceDirectorInterface::class); $userSourceDirector = $this->createMock(UserSourceDirectorInterface::class);
$requestedRight = $this->createMock(RequestedRightInterface::class); $requestedRight = $this->createMock(RequestedRightInterface::class);
$requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight); $requestedUserRightFacade = new RequestedUser($userSourceDirector, $requestedRight);
$this->expectException(SetNotPossibleException::class); $this->expectException(NotPossibleSetElementException::class);
$requestedUserRightFacade->setReciever($reciever); $requestedUserRightFacade->setReciever($reciever);
} }

View File

@ -24,6 +24,7 @@ class RightTransformerServiceTest extends TestCase
$requestedEntity = $this->createMock(RequestedEntityInterface::class); $requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('hasId')->willReturn(123); $requestedEntity->method('hasId')->willReturn(123);
$requestedEntity->method('getEntity')->willReturn($source); $requestedEntity->method('getEntity')->willReturn($source);
$requestedEntity->method('hasIdentity')->willReturn(true);
$requestedEntity->method('hasRequestedRight')->willReturn(true); $requestedEntity->method('hasRequestedRight')->willReturn(true);
$requestedRight = new RequestedRight(); $requestedRight = new RequestedRight();
$requestedRight->setActionType($crud); $requestedRight->setActionType($crud);

View File

@ -39,6 +39,7 @@ class SecureRequestedRightCheckerServiceTest extends TestCase
$requestedEntity = $this->createMock(RequestedEntityInterface::class); $requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('hasId')->willReturn(true); $requestedEntity->method('hasId')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($source); $requestedEntity->method('getEntity')->willReturn($source);
$requestedEntity->method('hasIdentity')->willReturn(true);
$requestedRight->setRequestedEntity($requestedEntity); $requestedRight->setRequestedEntity($requestedEntity);
$rightTransformerService = new RightTransformerService(); $rightTransformerService = new RightTransformerService();
$secureEntityChecker = new SecureRequestedRightCheckerService($rightTransformerService); $secureEntityChecker = new SecureRequestedRightCheckerService($rightTransformerService);
@ -67,6 +68,7 @@ class SecureRequestedRightCheckerServiceTest extends TestCase
$requestedEntity = $this->createMock(RequestedEntityInterface::class); $requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('hasId')->willReturn(true); $requestedEntity->method('hasId')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($source); $requestedEntity->method('getEntity')->willReturn($source);
$requestedEntity->method('hasIdentity')->willReturn(true);
$requestedRight->setRequestedEntity($requestedEntity); $requestedRight->setRequestedEntity($requestedEntity);
$rightTransformerService = new RightTransformerService(); $rightTransformerService = new RightTransformerService();
$secureEntityChecker = new SecureRequestedRightCheckerService($rightTransformerService); $secureEntityChecker = new SecureRequestedRightCheckerService($rightTransformerService);

View File

@ -12,7 +12,7 @@ use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\DBAL\Types\Meta\Right\CRUDType; use Infinito\DBAL\Types\Meta\Right\CRUDType;
use Infinito\Attribut\SourceAttribut; use Infinito\Attribut\SourceAttribut;
use Infinito\Attribut\SourceAttributInterface; use Infinito\Attribut\SourceAttributInterface;
use Infinito\Exception\SourceAccessDenied; use Infinito\Exception\Permission\NoSourcePermissionException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -80,7 +80,7 @@ class SecureSourceCheckerTest extends TestCase
$requestedRight = clone $right; $requestedRight = clone $right;
$this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight)); $this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight));
$childRight->setActionType(CRUDType::READ); $childRight->setActionType(CRUDType::READ);
$this->expectException(SourceAccessDenied::class); $this->expectException(NoSourcePermissionException::class);
$this->securerSourceChecker->hasPermission($requestedRight); $this->securerSourceChecker->hasPermission($requestedRight);
} }
@ -102,7 +102,7 @@ class SecureSourceCheckerTest extends TestCase
$requestedRight = clone $right; $requestedRight = clone $right;
$this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight)); $this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight));
$childRight->setActionType(CRUDType::READ); $childRight->setActionType(CRUDType::READ);
$this->expectException(SourceAccessDenied::class); $this->expectException(NoSourcePermissionException::class);
$this->securerSourceChecker->hasPermission($requestedRight); $this->securerSourceChecker->hasPermission($requestedRight);
} }

View File

@ -9,11 +9,14 @@ use Infinito\Domain\SourceManagement\SourceRightManager;
use Infinito\Entity\Meta\RightInterface; use Infinito\Entity\Meta\RightInterface;
use Infinito\Entity\Meta\Right; use Infinito\Entity\Meta\Right;
use Infinito\Entity\Meta\Law; use Infinito\Entity\Meta\Law;
use Infinito\Exception\AllreadySetException;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Exception\AllreadyDefinedException;
use Infinito\Entity\Source\PureSource; use Infinito\Entity\Source\PureSource;
use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException;
use Infinito\Exception\Collection\NotSetElementException;
/**
* @author kevinfrantz
*/
class SourceRightManagerTest extends TestCase class SourceRightManagerTest extends TestCase
{ {
/** /**
@ -41,27 +44,27 @@ class SourceRightManagerTest extends TestCase
public function testLawException(): void public function testLawException(): void
{ {
$this->right->setLaw(new Law()); $this->right->setLaw(new Law());
$this->expectException(AllreadyDefinedException::class); $this->expectException(AllreadyDefinedAttributException::class);
$this->sourceRightManager->addRight($this->right); $this->sourceRightManager->addRight($this->right);
} }
public function testSourceException(): void public function testSourceException(): void
{ {
$this->right->setSource(new PureSource()); $this->right->setSource(new PureSource());
$this->expectException(AllreadyDefinedException::class); $this->expectException(AllreadyDefinedAttributException::class);
$this->sourceRightManager->addRight($this->right); $this->sourceRightManager->addRight($this->right);
} }
public function testNotSetException(): void public function testNotSetElementException(): void
{ {
$this->expectException(NotSetException::class); $this->expectException(NotSetElementException::class);
$this->sourceRightManager->removeRight($this->right); $this->sourceRightManager->removeRight($this->right);
} }
public function testAllreadSetException(): void public function testAllreadSetException(): void
{ {
$this->sourceRightManager->addRight($this->right); $this->sourceRightManager->addRight($this->right);
$this->expectException(AllreadySetException::class); $this->expectException(ContainsElementException::class);
$this->sourceRightManager->addRight($this->right); $this->sourceRightManager->addRight($this->right);
} }

View File

@ -5,8 +5,8 @@ namespace tests\Unit\Domain\TwigManagement;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Domain\TwigManagement\ActionIconClassMapInterface; use Infinito\Domain\TwigManagement\ActionIconClassMapInterface;
use Infinito\Domain\TwigManagement\ActionIconClassMap; use Infinito\Domain\TwigManagement\ActionIconClassMap;
use Infinito\Exception\Collection\NotSetException;
use Infinito\DBAL\Types\ActionType; use Infinito\DBAL\Types\ActionType;
use Infinito\Exception\Collection\NotSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -30,7 +30,7 @@ class ActionIconClassMapTest extends TestCase
public function testException(): void public function testException(): void
{ {
$this->expectException(NotSetException::class); $this->expectException(NotSetElementException::class);
$this->actionIconClassMap->getIconClass('wejfhwhke12'); $this->actionIconClassMap->getIconClass('wejfhwhke12');
} }

View File

@ -3,9 +3,9 @@
namespace tests\Unit\Domain\TwigManagement; namespace tests\Unit\Domain\TwigManagement;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Domain\TwigManagement\LayerIconClassMap; use Infinito\Domain\TwigManagement\LayerIconClassMap;
use Infinito\DBAL\Types\Meta\Right\LayerType; use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Exception\Collection\NotSetElementException;
/** /**
* @author kevinfrantz * @author kevinfrantz
@ -14,7 +14,7 @@ class LayerIconClassMapTest extends TestCase
{ {
public function testException(): void public function testException(): void
{ {
$this->expectException(NotSetException::class); $this->expectException(NotSetElementException::class);
$this->assertIsString(LayerIconClassMap::getIconClass('123123V')); $this->assertIsString(LayerIconClassMap::getIconClass('123123V'));
} }

View File

@ -10,8 +10,11 @@ use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Logic\Operation\OperandInterface; use Infinito\Logic\Operation\OperandInterface;
use Infinito\Logic\Result\ResultInterface; use Infinito\Logic\Result\ResultInterface;
use Infinito\Logic\Result\Result; use Infinito\Logic\Result\Result;
use Infinito\Exception\NotProcessedException; use Infinito\Exception\Deprecated\NotProcessedException;
/**
* @author kevinfrantz
*/
class AbstractOperationTest extends TestCase class AbstractOperationTest extends TestCase
{ {
/** /**

View File

@ -3,13 +3,13 @@
namespace tests\unit\Entity\Source\Operation; namespace tests\unit\Entity\Source\Operation;
use PHPUnit\Framework\TestCase; use PHPUnit\Framework\TestCase;
use Infinito\Exception\NotDefinedException;
use Infinito\Logic\Result\Result; use Infinito\Logic\Result\Result;
use Infinito\Logic\Operation\OperandInterface; use Infinito\Logic\Operation\OperandInterface;
use Infinito\Logic\Result\ResultInterface; use Infinito\Logic\Result\ResultInterface;
use Doctrine\Common\Collections\ArrayCollection; use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Entity\Source\Operation\OperationInterface; use Infinito\Entity\Source\Operation\OperationInterface;
use Infinito\Entity\Source\Operation\AndOperation; use Infinito\Entity\Source\Operation\AndOperation;
use Infinito\Exception\Attribut\UndefinedAttributException;
class AndOperationTest extends TestCase class AndOperationTest extends TestCase
{ {
@ -25,7 +25,7 @@ class AndOperationTest extends TestCase
public function testConstructor(): void public function testConstructor(): void
{ {
$this->expectException(NotDefinedException::class); $this->expectException(UndefinedAttributException::class);
$this->operation->process(); $this->operation->process();
} }