From 523d8f68ecf97fb6de57eff364b7cdebeeb61df4 Mon Sep 17 00:00:00 2001 From: Kevin Frantz Date: Sat, 14 Jul 2018 11:41:40 +0200 Subject: [PATCH] Implemented Euros and test --- src/entity/currency/Euro.php | 42 +++++++++++++++++++++++++++++++ src/entity/currency/EuroTest.php | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 src/entity/currency/Euro.php create mode 100644 src/entity/currency/EuroTest.php diff --git a/src/entity/currency/Euro.php b/src/entity/currency/Euro.php new file mode 100644 index 0000000..8b684c8 --- /dev/null +++ b/src/entity/currency/Euro.php @@ -0,0 +1,42 @@ +cents; + } + + public function setCents(int $cents): void + { + $this->cents = $cents; + } + + public function getFloat(): float + { + return ($this->cents/100); + } + + public function getSymbol(): string + { + return '€'; + } +} + diff --git a/src/entity/currency/EuroTest.php b/src/entity/currency/EuroTest.php new file mode 100644 index 0000000..4c253c8 --- /dev/null +++ b/src/entity/currency/EuroTest.php @@ -0,0 +1,43 @@ +euro = new Euro(); + $this->euro->setCents(self::CENTS); + } + + public function testName():void{ + $this->assertEquals('Euro', $this->euro->getName()); + } + + public function testSymbol():void{ + $this->assertEquals('€', $this->euro->getSymbol()); + } + + public function testCent():void{ + $this->assertEquals(self::CENTS, $this->euro->getCents()); + } + + public function testFloat():void{ + $this->assertEquals(self::FLOAT, $this->euro->getFloat()); + } +} +