mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-10 06:27:24 +01:00
Implemented test for exception
This commit is contained in:
parent
c7c4e1c16e
commit
3ab9cb0e99
@ -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);
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
class NotCorrectInstanceException extends \TypeError
|
||||
{
|
||||
}
|
@ -10,6 +10,8 @@ use App\Domain\SourceManagement\SourceMetaInformation;
|
||||
use App\Domain\SourceManagement\SourceMetaInformationInterface;
|
||||
use App\Domain\TemplateManagement\TemplatePathFormAndViewInterface;
|
||||
use App\Domain\FormManagement\FormMetaInformationInterface;
|
||||
use App\Entity\EntityInterface;
|
||||
use App\Exception\NotCorrectInstanceException;
|
||||
|
||||
class SourceMetaInformationTest extends TestCase
|
||||
{
|
||||
@ -79,4 +81,10 @@ class SourceMetaInformationTest extends TestCase
|
||||
{
|
||||
$this->assertInstanceOf(FormMetaInformationInterface::class, $this->sourceMetaInformation->getFormMetaInformation());
|
||||
}
|
||||
|
||||
public function testTypeError(): void
|
||||
{
|
||||
$this->expectException(NotCorrectInstanceException::class);
|
||||
new SourceMetaInformation($this->createMock(EntityInterface::class));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user