From 74c404a9ce256b8c89831b5e38731640af6ea7ce Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Fri, 4 Jan 2019 21:28:21 +0100 Subject: [PATCH] Implemented PureSource --- .../src/Controller/DefaultController.php | 2 +- .../src/Entity/Source/AbstractSource.php | 1 + application/src/Entity/Source/PureSource.php | 21 ++++++++ .../src/Entity/Source/PureSourceInterface.php | 10 ++++ .../Source/PureSourceIntegrationTest.php | 49 +++++++++++++++++++ .../Unit/Entity/Source/PureSourceTest.php | 36 ++++++++++++++ 6 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 application/src/Entity/Source/PureSource.php create mode 100644 application/src/Entity/Source/PureSourceInterface.php create mode 100644 application/tests/Integration/Entity/Source/PureSourceIntegrationTest.php create mode 100644 application/tests/Unit/Entity/Source/PureSourceTest.php diff --git a/application/src/Controller/DefaultController.php b/application/src/Controller/DefaultController.php index 40ccf1e..b157898 100644 --- a/application/src/Controller/DefaultController.php +++ b/application/src/Controller/DefaultController.php @@ -18,7 +18,7 @@ use Doctrine\ORM\EntityManagerInterface; * * @author kevinfrantz */ -class DefaultController extends AbstractEntityController +final class DefaultController extends AbstractEntityController { /** * @todo Optimize function! diff --git a/application/src/Entity/Source/AbstractSource.php b/application/src/Entity/Source/AbstractSource.php index 62419bd..c283319 100644 --- a/application/src/Entity/Source/AbstractSource.php +++ b/application/src/Entity/Source/AbstractSource.php @@ -32,6 +32,7 @@ use App\Entity\Meta\Relation\Member\MemberRelationInterface; * @ORM\InheritanceType("JOINED") * @ORM\DiscriminatorColumn(name="discr", type="string") * @ORM\DiscriminatorMap({ + * "pure" = "PureSource", * "text" = "App\Entity\Source\Primitive\Text\TextSource", * "operation"="App\Entity\Source\Operation\AbstractOperation", * "user" = "App\Entity\Source\Complex\UserSource", diff --git a/application/src/Entity/Source/PureSource.php b/application/src/Entity/Source/PureSource.php new file mode 100644 index 0000000..77ba92e --- /dev/null +++ b/application/src/Entity/Source/PureSource.php @@ -0,0 +1,21 @@ +entityManager = self::$container->get('doctrine.orm.default_entity_manager'); + $this->sourceRepository = $this->entityManager->getRepository(PureSource::class); + $this->pureSource = new PureSource(); + } + + public function testDatabaseProcess(): void + { + $this->entityManager->persist($this->pureSource); + $this->entityManager->flush(); + $this->assertGreaterThan(0, $this->pureSource->getId()); + $this->entityManager->remove($this->pureSource); + $this->entityManager->flush(); + $this->expectException(\TypeError::class); + $this->pureSource->getId(); + } +} diff --git a/application/tests/Unit/Entity/Source/PureSourceTest.php b/application/tests/Unit/Entity/Source/PureSourceTest.php new file mode 100644 index 0000000..3dbfce0 --- /dev/null +++ b/application/tests/Unit/Entity/Source/PureSourceTest.php @@ -0,0 +1,36 @@ +pureSource = new PureSource(); + $this->abstractSource = new class() extends AbstractSource { + }; + } + + public function testMethodSet(): void + { + $pureSourceMethods = get_class_methods($this->pureSource); + $abstractSourceMethods = get_class_methods($this->abstractSource); + $this->assertArraySubset($pureSourceMethods, $abstractSourceMethods); + } +}