本文整理匯總了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));
}