Example #1
0
 /**
  * Asserts equality of tax percentages
  *
  * @param PriceTag $priceTag
  *
  * @throws TaxMismatchException
  */
 public function assertTaxPercentage(PriceTag $priceTag)
 {
     if ($this->taxPercentage != $priceTag->getTaxPercentage()) {
         throw new TaxMismatchException(sprintf('Tax percentage %i must match %i when adding or subtracting price tags', $this->taxPercentage, $priceTag->getTaxPercentage()));
     }
 }
Example #2
0
 /**
  * @dataProvider getConvertTo
  */
 public function testConvertTo(PriceTag $priceTag, $factor, $expNet, $expGross, $expCurrency)
 {
     /** @var PriceTag $return */
     $return = $priceTag->convertTo($factor, new ISO4217Currency($expCurrency));
     $this->assertInstanceOf('Nilz\\Money\\PriceTag\\PriceTag', $return);
     $this->assertSame($expNet, $return->getNetPrice()->getAmount());
     $this->assertSame($expGross, $return->getGrossPrice()->getAmount());
     $this->assertSame($expCurrency, $return->getNetPrice()->getCurrency()->getAlpha3());
     $this->assertSame($expCurrency, $return->getGrossPrice()->getCurrency()->getAlpha3());
     $this->assertSame($priceTag->getTaxPercentage(), $return->getTaxPercentage());
 }