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
*
* @throws InvalidChoiceTypeException
*/
public function setActionType(string $actionType): void

View File

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

View File

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

View File

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

View File

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

View File

@ -3,8 +3,8 @@
namespace Infinito\Domain\ActionManagement;
use Infinito\Entity\EntityInterface;
use Infinito\Exception\NotSecureException;
use Infinito\Exception\NotValidByFormException;
use Infinito\Exception\Validation\FormInvalidException;
use Infinito\Exception\Permission\NoPermissionException;
/**
* @author kevinfrantz
@ -50,8 +50,8 @@ abstract class AbstractAction extends AbstractActionConstructor implements Actio
if ($this->isValid()) {
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
*
* @throws InvalidChoiceTypeException
*/
private function throwNoValidActionTypeException(string $actionType): void

View File

@ -5,7 +5,7 @@ namespace Infinito\Domain\FormManagement;
use Symfony\Component\Form\FormBuilderInterface;
use Infinito\Domain\RequestManagement\Action\RequestedActionInterface;
use Symfony\Component\Form\FormFactoryInterface;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Exception\Attribut\UndefinedAttributException;
/**
* @author kevinfrantz
@ -25,12 +25,12 @@ class RequestedActionFormBuilder implements RequestedActionFormBuilderInterface
/**
* @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
{
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\Entity\Source\AbstractSource;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Entity\Meta\Law;
use Infinito\Entity\Meta\Right;
use Infinito\Entity\Meta\Relation\Parent\HeredityRelation;
@ -31,7 +31,7 @@ final class LayerClassMap implements LayerClassMapInterface
/**
* @param string $layer
*
* @throws NotSetException
* @throws NotSetElementException
*
* @return string
*/
@ -40,6 +40,6 @@ final class LayerClassMap implements LayerClassMapInterface
if (array_key_exists($layer, self::LAYER_CLASS_MAP)) {
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\Request;
use Infinito\Exception\Attribut\UndefinedAttributException;
use Infinito\Exception\Collection\NotSetElementException;
/**
* This class exists out of refactoring reasons.
@ -71,6 +71,6 @@ abstract class AbstractGetParameterService implements GetParameterServiceInterfa
if ($this->hasParameter($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 HaydenPierce\ClassFinder\ClassFinder;
use Infinito\Domain\ParameterManagement\Parameter\ParameterInterface;
use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Core\NotImplementedCoreException;
/**
* @author kevinfrantz
@ -67,7 +67,7 @@ final class ParameterFactory implements ParameterFactoryInterface
if ($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\Validator\Validator\ValidatorInterface;
use Infinito\Exception\Validation\GetParameterInvalidException;
/**
* @author kevinfrantz
@ -34,8 +35,6 @@ final class ValidGetParametersService extends AbstractGetParameterService implem
/**
* @param string $key
*
* @throws UnvalidGetParameterException
*/
protected function validateParameter(string $key): void
{
@ -43,7 +42,7 @@ final class ValidGetParametersService extends AbstractGetParameterService implem
$parameter->setValue($this->currentRequest->get($key));
$errors = $this->validator->validate($parameter);
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;
use Doctrine\Common\Collections\Collection;
use Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Exception\AllreadySetException;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Collection\NotSetElementException;
/**
* @author kevinfrantz
@ -26,7 +25,7 @@ class RequestedActionStack implements RequestedActionStackInterface
/**
* {@inheritdoc}
*
* @see \Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface::containesRequestedAction()
* @see \Infinito\Domain\RequestManagement\Action\RequestedActionStackInterface::containesRequestedAction()
*/
public function containesRequestedAction(string $actionType): bool
{
@ -36,13 +35,13 @@ class RequestedActionStack implements RequestedActionStackInterface
/**
* {@inheritdoc}
*
* @see \Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface::addRequestedAction()
* @see \Infinito\Domain\RequestManagement\Action\RequestedActionStackInterface::addRequestedAction()
*/
public function addRequestedAction(RequestedActionInterface $requestedAction): void
{
$key = $requestedAction->getActionType();
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);
}
@ -50,7 +49,7 @@ class RequestedActionStack implements RequestedActionStackInterface
/**
* {@inheritdoc}
*
* @see \Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface::getAllRequestedActions()
* @see \Infinito\Domain\RequestManagement\Action\RequestedActionStackInterface::getAllRequestedActions()
*/
public function getAllRequestedActions(): Collection
{
@ -60,13 +59,13 @@ class RequestedActionStack implements RequestedActionStackInterface
/**
* {@inheritdoc}
*
* @see \Infinito\Domain\ReInfinito\Management\RequestedActionStackInterface::getRequestedAction()
* @see \Infinito\Domain\RequestManagement\Action\RequestedActionStackInterface::getRequestedAction()
*/
public function getRequestedAction(string $actionType): RequestedActionInterface
{
if ($this->requestedActions->containsKey($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
{
if (!($this->hasId() || $this->hasSlug())) {
throw new NoIdentityCoreException('No identity attribut like id or slug was set!');
if ($this->hasId() || $this->hasSlug()) {
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
{
if (!$entity) {
throw new EntityNotFoundException('Entity with {id:"'.$this->id.'",slug:"'.$this->slug.'"} not found');
if ($entity) {
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\Attribut\ActionTypeAttribut;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Exception\NoIdentityCoreException;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException;
use Infinito\Exception\Core\NoIdentityCoreException;
use Infinito\Exception\Collection\ContainsElementException;
/**
* @author kevinfrantz
@ -57,7 +57,7 @@ class RequestedRight implements RequestedRightInterface
if ($this->requestedEntity->hasIdentity()) {
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
{
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);
}

View File

@ -4,9 +4,9 @@ namespace Infinito\Domain\RequestManagement\User;
use Infinito\Entity\Source\SourceInterface;
use Infinito\Domain\UserManagement\UserSourceDirectorInterface;
use Infinito\Exception\SetNotPossibleException;
use Infinito\Domain\RequestManagement\Right\RequestedRightInterface;
use Infinito\Domain\RequestManagement\Right\AbstractRequestedRightFacade;
use Infinito\Exception\Collection\NotPossibleSetElementException;
/**
* @author kevinfrantz
@ -37,7 +37,7 @@ class RequestedUser extends AbstractRequestedRightFacade implements RequestedUse
*/
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\Source\SourceInterface;
use Infinito\Domain\LawManagement\LawPermissionChecker;
use Infinito\Exception\SourceAccessDenied;
use Infinito\Exception\Permission\NoSourcePermissionException;
/**
* @author kevinfrantz
@ -62,7 +62,7 @@ final class SecureSourceChecker implements SecureSourceCheckerInterface
/**
* @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
*/
@ -77,7 +77,7 @@ final class SecureSourceChecker implements SecureSourceCheckerInterface
if ($this->isSource($attributExpectedSource)) {
$methodSecureSourceChecker = new self($attributExpectedSource);
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;
use Infinito\Entity\Meta\RightInterface;
use Infinito\Exception\SourceAccessDenied;
/**
* @author kevinfrantz
@ -11,8 +10,6 @@ use Infinito\Exception\SourceAccessDenied;
interface SecureSourceCheckerInterface
{
/**
* @throws SourceAccessDenied
*
* @param RightInterface $right
*
* @return bool

View File

@ -4,12 +4,12 @@ namespace Infinito\Domain\SourceManagement;
use Infinito\Entity\Meta\RightInterface;
use Infinito\Entity\Source\SourceInterface;
use Infinito\Exception\AllreadySetException;
use Infinito\Entity\Source\AbstractSource;
use Infinito\Entity\Meta\Law;
use Infinito\Exception\AllreadyDefinedException;
use Infinito\Exception\Collection\NotSetException;
use Doctrine\Common\Collections\ArrayCollection;
use Infinito\Exception\Attribut\AllreadyDefinedAttributException;
use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Collection\NotSetElementException;
/**
* @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
{
@ -38,7 +38,7 @@ final class SourceRightManager implements SourceRightManagerInterface
foreach ($attributes as $attribut) {
try {
$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) {
//Expected
}
@ -61,7 +61,7 @@ final class SourceRightManager implements SourceRightManagerInterface
public function addRight(RightInterface $right): void
{
if ($this->getRights()->contains($right)) {
throw new AllreadySetException('The right was allready added.');
throw new ContainsElementException('The right was allready added.');
}
$this->checkRightAttributes($right);
$right->setSource($this->source);
@ -80,7 +80,7 @@ final class SourceRightManager implements SourceRightManagerInterface
});
$right->setLaw(new Law());
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;
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.
@ -16,16 +13,11 @@ interface SourceRightManagerInterface
{
/**
* @param RightInterface $right
*
* @throws AllreadySetException
* @throws AllreadyDefinedException
*/
public function addRight(RightInterface $right): void;
/**
* @param RightInterface $right
*
* @throws NotSetException
*/
public function removeRight(RightInterface $right): void;
}

View File

@ -3,7 +3,7 @@
namespace Infinito\Domain\TwigManagement;
use Infinito\DBAL\Types\ActionType;
use Infinito\Exception\Collection\NotSetException;
use Infinito\Exception\Collection\NotSetElementException;
/**
* @author kevinfrantz
@ -31,6 +31,6 @@ final class ActionIconClassMap implements ActionIconClassMapInterface
if (key_exists($action, self::ACTION_ICON_CLASS_MAP)) {
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;
use Infinito\Exception\Collection\NotSetException;
use Infinito\DBAL\Types\Meta\Right\LayerType;
use Infinito\Exception\Collection\NotSetElementException;
/**
* @author kevinfrantz
@ -32,6 +32,6 @@ final class LayerIconClassMap implements LayerIconClassMapInterface
if (key_exists($layer, self::LAYER_ICON_CLASS_MAP)) {
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 Infinito\Entity\Source\AbstractSource;
use Infinito\Entity\Source\Operation\Attribut\OperandsAttribut;
use Infinito\Exception\NotProcessedException;
use Infinito\Exception\Deprecated\NotProcessedException;
/**
* @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);
$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
{
$is404 = 404 === $response->getStatusCode();
$isEntityNotFoundHttpException = strpos($response->getContent(), 'EntityNotFoundHttpException');
$isEntityNotFoundHttpException = strpos($response->getContent(), 'EntityNotFoundException');
return !$is404 || $isEntityNotFoundHttpException;
}

View File

@ -11,9 +11,9 @@ use Infinito\Entity\EntityInterface;
use Infinito\Logic\Result\ResultInterface;
use Infinito\Domain\FormManagement\RequestedActionFormBuilderServiceInterface;
use Infinito\Exception\Type\InvalidChoiceTypeException;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Validation\ValueInvalidException;
/**
* @author kevinfrantz
@ -55,7 +55,7 @@ class ActionViewsDAOServiceIntegrationTest extends TestCase
public function testNotCorrectInstanceSetException(): void
{
$this->expectException(NotCorrectInstanceCoreException::class);
$this->expectException(ValueInvalidException::class);
$data = new class() {
};
$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\Exception\Validation\GetParameterInvalidException;
use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Core\NotImplementedCoreException;
/**
* @author kevinfrantz
*/
class ValidGetParameterServiceTest extends KernelTestCase
class ValidGetParameterServiceIntegrationTest extends KernelTestCase
{
/**
* @var Request
@ -72,10 +73,17 @@ class ValidGetParameterServiceTest extends KernelTestCase
$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->expectException(GetParameterInvalidException::class);
$this->expectException(NotImplementedCoreException::class);
new ValidGetParametersService($this->requestStack, $this->parameterFactory, $this->validator);
}

View File

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

View File

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

View File

@ -10,8 +10,8 @@ use PHPUnit\Framework\TestCase;
use Infinito\Exception\Collection\ContainsElementException;
use Infinito\Exception\Collection\NotSetElementException;
use Infinito\Exception\Type\InvalidChoiceTypeException;
use Infinito\Exception\Core\NotCorrectInstanceCoreException;
use Infinito\Domain\DataAccessManagement\ActionsResultsDAOServiceInterface;
use Infinito\Exception\Validation\ValueInvalidException;
/**
* @author kevinfrantz
@ -41,7 +41,7 @@ class ActionResultsDAOServiceTest extends TestCase
public function testNotCorrectInstanceSetException(): void
{
$this->expectException(NotCorrectInstanceCoreException::class);
$this->expectException(ValueInvalidException::class);
$data = new class() {
};
$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\ActionDependenciesDAOServiceInterface;
use PHPUnit\Framework\MockObject\MockObject;
use Infinito\Exception\NotValidByFormException;
use Infinito\Exception\Validation\FormInvalidException;
/**
* @author kevinfrantz
@ -51,7 +51,7 @@ class AbstractActionTest extends TestCase
{
$this->action->isSecure = true;
$this->action->validByForm = false;
$this->expectException(NotValidByFormException::class);
$this->expectException(FormInvalidException::class);
$this->action->execute();
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -4,7 +4,6 @@ namespace tests\Unit\Domain\ParameterManagement;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Infinito\Exception\NotDefinedException;
use Infinito\Domain\ParameterManagement\Parameter\VersionParameter;
use Infinito\Domain\ParameterManagement\ParameterFactory;
use Infinito\Domain\ParameterManagement\ValidGetParametersService;
@ -13,6 +12,8 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
use Infinito\Domain\ParameterManagement\ValidGetParameterServiceInterface;
use Infinito\Domain\ParameterManagement\Parameter\ViewParameter;
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.
@ -69,13 +70,17 @@ class ValidGetParameterServiceTest extends KernelTestCase
$this->assertTrue($this->validGetParameterService->hasParameter($key));
$this->assertEquals($value, $this->validGetParameterService->getParameter($key));
}
$this->expectException(NotDefinedException::class);
}
public function testNotImplementedException(): void
{
$this->expectException(NotImplementedCoreException::class);
$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());
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,6 +39,7 @@ class SecureRequestedRightCheckerServiceTest extends TestCase
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('hasId')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($source);
$requestedEntity->method('hasIdentity')->willReturn(true);
$requestedRight->setRequestedEntity($requestedEntity);
$rightTransformerService = new RightTransformerService();
$secureEntityChecker = new SecureRequestedRightCheckerService($rightTransformerService);
@ -67,6 +68,7 @@ class SecureRequestedRightCheckerServiceTest extends TestCase
$requestedEntity = $this->createMock(RequestedEntityInterface::class);
$requestedEntity->method('hasId')->willReturn(true);
$requestedEntity->method('getEntity')->willReturn($source);
$requestedEntity->method('hasIdentity')->willReturn(true);
$requestedRight->setRequestedEntity($requestedEntity);
$rightTransformerService = new 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\Attribut\SourceAttribut;
use Infinito\Attribut\SourceAttributInterface;
use Infinito\Exception\SourceAccessDenied;
use Infinito\Exception\Permission\NoSourcePermissionException;
/**
* @author kevinfrantz
@ -80,7 +80,7 @@ class SecureSourceCheckerTest extends TestCase
$requestedRight = clone $right;
$this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight));
$childRight->setActionType(CRUDType::READ);
$this->expectException(SourceAccessDenied::class);
$this->expectException(NoSourcePermissionException::class);
$this->securerSourceChecker->hasPermission($requestedRight);
}
@ -102,7 +102,7 @@ class SecureSourceCheckerTest extends TestCase
$requestedRight = clone $right;
$this->assertTrue($this->securerSourceChecker->hasPermission($requestedRight));
$childRight->setActionType(CRUDType::READ);
$this->expectException(SourceAccessDenied::class);
$this->expectException(NoSourcePermissionException::class);
$this->securerSourceChecker->hasPermission($requestedRight);
}

View File

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

View File

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

View File

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

View File

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

View File

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