public function testSetGetAmount() { $money = new MoneyObject(); // Default $this->assertSame(0, $money->getAmount()); $this->assertSame($money, $money->setAmount(33)); $this->assertSame(33, $money->getAmount()); $this->assertInternalType('int', $money->getAmount()); $this->assertSame($money, $money->setAmount(null)); $this->assertSame(0, $money->getAmount()); $this->assertInternalType('int', $money->getAmount()); }
/** * @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()); } } }