Example #1
0
 public function testIsEqualToReturnFalse()
 {
     $currency1 = new Currency('EUR');
     $currency2 = new Currency('USD');
     $this->assertFalse($currency1->isEqualTo($currency2));
     $this->assertFalse($currency2->isEqualTo($currency1));
 }
Example #2
0
 /**
  * @param Price $price
  *
  * @return bool
  *
  * @throws UnexpectedCurrencyException
  */
 public function isEqualTo(Price $price)
 {
     if (!$this->currency->isEqualTo($price->getCurrency())) {
         throw new UnexpectedCurrencyException("Impossible to compare two prices with different currencies.");
     }
     return $this->amount === $price->getAmount();
 }