Beispiel #1
0
 public function testNegate()
 {
     $money = new MoneyObject();
     $money->setCurrency('EUR');
     $testValue = 100;
     $money->setAmount($testValue);
     $this->assertSame($money, $money->setAmount($testValue)->negate());
     $this->assertSame(-$testValue, $money->getAmount());
     $testValue = -10;
     $money->setAmount($testValue);
     $this->assertSame($money, $money->setAmount($testValue)->negate());
     $this->assertSame(-$testValue, $money->getAmount());
 }
Beispiel #2
0
 /**
  * @dataProvider collectionDataProvider
  * @param MoneyCollectionInterface $moneyCollection
  * @param array $rawData
  */
 public function testMultiply(MoneyCollectionInterface $moneyCollection, array $rawData)
 {
     $factors = [0, 1, -1, 2.5, new DecimalNumberObject(2, 2), new DecimalNumberObject(-2, 3)];
     foreach ($factors as $factor) {
         $testCollection = clone $moneyCollection;
         $this->assertSame($testCollection, $testCollection->multiply($factor));
         /* @var $money MoneyInterface */
         foreach ($testCollection as $k => $money) {
             $moneyObjectAsset = new MoneyObject($rawData[$k]['amount'], $rawData[$k]['currency']);
             $moneyObjectAsset->multiply($factor);
             $this->assertEquals($moneyObjectAsset->getAmount(), $money->getAmount());
             $this->assertEquals($rawData[$k]['currency'], $money->getCurrency());
         }
     }
 }