SiPrefixTest.php (1206B)
1 <?php 2 3 namespace PartKeepr\SiPrefixBundle\Tests\Model; 4 5 use PartKeepr\SiPrefixBundle\Entity\SiPrefix; 6 7 class SiPrefixTest extends \PHPUnit_Framework_TestCase 8 { 9 public function testPrefix() 10 { 11 $siPrefix = $this->getSiPrefix(); 12 13 $siPrefix->setPrefix('yotta'); 14 $this->assertEquals('yotta', $siPrefix->getPrefix()); 15 } 16 17 public function testSymbol() 18 { 19 $siPrefix = $this->getSiPrefix(); 20 21 $siPrefix->setSymbol('µ'); 22 23 $this->assertEquals('µ', $siPrefix->getSymbol()); 24 } 25 26 public function testBase() 27 { 28 $siPrefix = $this->getSiPrefix(); 29 30 $siPrefix->setBase(10); 31 32 $this->assertEquals(10, $siPrefix->getBase()); 33 } 34 35 public function testExponent() 36 { 37 $siPrefix = $this->getSiPrefix(); 38 39 $siPrefix->setExponent(10); 40 $this->assertEquals(10, $siPrefix->getExponent()); 41 } 42 43 public function testCalculation() 44 { 45 $siPrefix = $this->getSiPrefix(); 46 47 $siPrefix->setBase(10); 48 $siPrefix->setExponent(2); 49 50 $this->assertEquals(310, $siPrefix->calculateProduct(3.1)); 51 } 52 53 private function getSiPrefix() 54 { 55 return new SiPrefix(); 56 } 57 }