From d00d70f440dd9fc7580914ae654eac2fe59ac212 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sun, 3 Feb 2019 12:34:29 +0100 Subject: [PATCH] Implemented ClassAttribut --- .../symfony/src/Attribut/ClassAttribut.php | 39 ++++++++++++++++ .../src/Attribut/ClassAttributInterface.php | 19 ++++++++ .../tests/Unit/Attribut/ClassAttributTest.php | 44 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 application/symfony/src/Attribut/ClassAttribut.php create mode 100644 application/symfony/src/Attribut/ClassAttributInterface.php create mode 100644 application/symfony/tests/Unit/Attribut/ClassAttributTest.php diff --git a/application/symfony/src/Attribut/ClassAttribut.php b/application/symfony/src/Attribut/ClassAttribut.php new file mode 100644 index 0000000..c33b9a4 --- /dev/null +++ b/application/symfony/src/Attribut/ClassAttribut.php @@ -0,0 +1,39 @@ +class = $class; + + return; + } + throw new NotFoundHttpException('Class '.$class.' couldn\'t be found!'); + } + + /** + * @return string + */ + public function getClass(): string + { + return $this->class; + } +} diff --git a/application/symfony/src/Attribut/ClassAttributInterface.php b/application/symfony/src/Attribut/ClassAttributInterface.php new file mode 100644 index 0000000..51d7082 --- /dev/null +++ b/application/symfony/src/Attribut/ClassAttributInterface.php @@ -0,0 +1,19 @@ +classAttribut = new class() implements ClassAttributInterface { + use ClassAttribut; + }; + } + + public function testConstructor(): void + { + $this->expectException(\TypeError::class); + $this->classAttribut->getClass(); + } + + public function testAccessors(): void + { + $class = AbstractSource::class; + $this->assertNull($this->classAttribut->setClass($class)); + $this->assertEquals($class, $this->classAttribut->getClass()); + } + + public function testException(): void + { + $class = 'NOTEXISTINGCLASS'; + $this->expectException(NotFoundHttpException::class); + $this->classAttribut->setClass($class); + } +}