本文整理汇总了PHP中Money::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Money::add方法的具体用法?PHP Money::add怎么用?PHP Money::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Money
的用法示例。
在下文中一共展示了Money::add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAdd
public function testAdd()
{
// Arrange
$a = new Money(600);
// Act
$a->add(66);
// Assert
$this->assertEquals(666, $a->getAmount());
}
示例2: testMoneyCanBeAdded
public function testMoneyCanBeAdded()
{
$usCurrency = new USD();
$amount = 123;
$money = new Money($usCurrency, $amount);
$result = $money->add($money);
$this->assertEquals($usCurrency, $result->getCurrency());
$this->assertEquals($amount + $amount, $result->getValue());
}
示例3: testExceptionIsRaisedWhenMoneyObjectWithDifferentCurrencyIsAdded
/**
* @covers \SebastianBergmann\Money\Money::add
* @covers \SebastianBergmann\Money\Money::assertSameCurrency
* @uses \SebastianBergmann\Money\Money::__construct
* @uses \SebastianBergmann\Money\Money::handleCurrencyArgument
* @uses \SebastianBergmann\Money\Money::getAmount
* @uses \SebastianBergmann\Money\Money::getCurrency
* @uses \SebastianBergmann\Money\Currency
* @expectedException \SebastianBergmann\Money\CurrencyMismatchException
*/
public function testExceptionIsRaisedWhenMoneyObjectWithDifferentCurrencyIsAdded()
{
$a = new Money(1, new Currency('EUR'));
$b = new Money(2, new Currency('USD'));
$a->add($b);
}
示例4: testBagNotEquals
public function testBagNotEquals()
{
$bag1 = MoneyBag::create($this->f12EUR, $this->f7USD);
$bag2 = new Money(12, 'CHF');
$bag2->add($this->f7USD);
$this->assertFalse($bag1->equals($bag2));
}
示例5: addMoney
/**
* addMoney
*
* Adds two instances of Money together, returning a new instance in the
* same currency as the first instance.
*
* @param Money $first
* @param Money $second
* @return type
*/
public function addMoney(Money $first, Money $second)
{
return $first->add($this->normalizeMoneyValue($first, $second));
}