diff --git a/application/symfony/src/Domain/SourceManagement/SourceMetaInformation.php b/application/symfony/src/Domain/SourceManagement/SourceMetaInformation.php index cb98b89..8ef76c6 100644 --- a/application/symfony/src/Domain/SourceManagement/SourceMetaInformation.php +++ b/application/symfony/src/Domain/SourceManagement/SourceMetaInformation.php @@ -4,6 +4,7 @@ namespace App\Domain\SourceManagement; use App\Domain\EntityManagement\EntityMetaInformation; use App\Entity\Source\AbstractSource; +use App\Exception\NotCorrectInstanceException; /** * @author kevinfrantz @@ -22,7 +23,7 @@ final class SourceMetaInformation extends EntityMetaInformation implements Sourc public function __construct(\App\Entity\EntityInterface $entity) { if (!$entity instanceof AbstractSource) { - throw new \TypeError('Entity has to be an instance of '.AbstractSource::class); + throw new NotCorrectInstanceException('Entity has to be an instance of '.AbstractSource::class); } parent::__construct($entity); } diff --git a/application/symfony/src/Exception/NotCorrectInstanceException.php b/application/symfony/src/Exception/NotCorrectInstanceException.php new file mode 100644 index 0000000..1546858 --- /dev/null +++ b/application/symfony/src/Exception/NotCorrectInstanceException.php @@ -0,0 +1,7 @@ +assertInstanceOf(FormMetaInformationInterface::class, $this->sourceMetaInformation->getFormMetaInformation()); } + + public function testTypeError(): void + { + $this->expectException(NotCorrectInstanceException::class); + new SourceMetaInformation($this->createMock(EntityInterface::class)); + } }