當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Money::add方法代碼示例

本文整理匯總了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());
 }
開發者ID:edele,項目名稱:travis-tryout,代碼行數:9,代碼來源:MoneyTest.php

示例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());
 }
開發者ID:rocketpastsix,項目名稱:OOPExample,代碼行數:9,代碼來源:moneyTest.php

示例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);
 }
開發者ID:erictho,項目名稱:money,代碼行數:16,代碼來源:MoneyTest.php

示例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));
 }
開發者ID:amptools-net,項目名稱:midori-php,代碼行數:7,代碼來源:MoneyTest.php

示例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));
 }
開發者ID:mcordingley,項目名稱:money,代碼行數:14,代碼來源:Broker.php


注:本文中的Money::add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。