Implemented Euros and test

This commit is contained in:
Kevin Frantz 2018-07-14 11:41:40 +02:00
parent 9785ebf5a2
commit 523d8f68ec
2 changed files with 85 additions and 0 deletions

View File

@ -0,0 +1,42 @@
<?php
namespace entity\currency;
/**
*
* @author kevinfrantz
*
*/
final class Euro implements CurrencyInterface
{
/**
*
* @var int
*/
private $cents;
public function getName(): string
{
return 'Euro';
}
public function getCents(): int
{
return $this->cents;
}
public function setCents(int $cents): void
{
$this->cents = $cents;
}
public function getFloat(): float
{
return ($this->cents/100);
}
public function getSymbol(): string
{
return '€';
}
}

View File

@ -0,0 +1,43 @@
<?php
namespace entity\currency;
use PHPUnit\Framework\TestCase;
/**
*
* @author kevinfrantz
*
*/
class EuroTest extends TestCase
{
const CENTS = 13301;
const FLOAT = 133.01;
/**
*
* @var Euro
*/
protected $euro;
protected function setUp():void{
$this->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());
}
}