本文整理汇总了PHP中Money\Money::USD方法的典型用法代码示例。如果您正苦于以下问题:PHP Money::USD方法的具体用法?PHP Money::USD怎么用?PHP Money::USD使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Money\Money
的用法示例。
在下文中一共展示了Money::USD方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testOverrideCurrency
public function testOverrideCurrency()
{
\Locale::setDefault("fr_FR");
$form = $this->factory->create($this->simpleMoneyTypeClass, null, ["currency" => "USD"]);
$form->submit(array("tbbc_amount" => '1 252,5'));
$this->assertEquals(Money::USD(125250), $form->getData());
}
示例2: widthdrawl
public function widthdrawl($amount)
{
$originalfunds = Money::USD((int) $this->fundsavailable);
$addedFunds = Money::USD((int) $amount);
$fundsavailable = $originalfunds->subtract($addedFunds);
$this->fundsavailable = $fundsavailable->getAmount();
$this->save();
}
示例3: ConvertsEurToUsdWithModes
/** @test */
public function ConvertsEurToUsdWithModes()
{
$eur = Money::Euro(10);
$pair = new CurrencyPair(CurrencyProxy::determine('EUR'), CurrencyProxy::determine('USD'), 1.25);
$usd = $pair->convert($eur);
$this->assertEquals(Money::USD(13), $usd);
$pair = new CurrencyPair(CurrencyProxy::determine('EUR'), CurrencyProxy::determine('USD'), 1.25);
$usd = $pair->convert($eur, new RoundingMode(RoundingMode::ROUND_HALF_DOWN));
$this->assertEquals(Money::USD(12), $usd);
}
示例4: ConvertsEurToUsdAndBack
/** @test */
public function ConvertsEurToUsdAndBack()
{
$eur = Money::EUR(100);
$pair = new CurrencyPair(new Currency('EUR'), new Currency('USD'), 1.25);
$usd = $pair->convert($eur);
$this->assertEquals(Money::USD(125), $usd);
$pair = new CurrencyPair(new Currency('USD'), new Currency('EUR'), 0.8);
$eur = $pair->convert($usd);
$this->assertEquals(Money::EUR(100), $eur);
}
示例5: testMoneyTwigExtension
public function testMoneyTwigExtension()
{
\Locale::setDefault('en');
/** @var PairManagerInterface $pairManager */
$pairManager = $this->client->getContainer()->get("tbbc_money.pair_manager");
$pairManager->saveRatio("USD", 1.25);
/** @var MoneyExtension $moneyExtension */
$moneyExtension = $this->client->getContainer()->get("tbbc_money.twig.money");
$eur = Money::EUR(100);
$usd = $moneyExtension->convert($eur, "USD");
$this->assertEquals(Money::USD(125), $usd);
}
示例6: testRatio
public function testRatio()
{
$eur = Money::EUR(100);
$sameEur = $this->manager->convert($eur, "EUR");
$this->assertEquals(Money::EUR(100), $sameEur);
try {
$this->manager->convert($eur, "USD");
$this->assertTrue(false);
} catch (MoneyException $e) {
$this->assertTrue(true);
}
$this->manager->saveRatio("USD", 1.25);
$usd = $this->manager->convert($eur, "USD");
$this->assertEquals(Money::USD(125), $usd);
$this->manager->saveRatio("CAD", 1.5);
$cad = $this->manager->convert($usd, "CAD");
$this->assertEquals(Money::CAD(150), $cad);
}
示例7: setUp
public function setUp()
{
$this->money_usd = Money::USD(1234);
$this->money_euro = Money::Euro(1234);
$this->money_czech = Money::Koruna(1234);
}
示例8: testDifferentCurrenciesCannotBeCompared
/**
* @expectedException Money\InvalidArgumentException
*/
public function testDifferentCurrenciesCannotBeCompared()
{
Money::EUR(1)->compare(Money::USD(1));
}
示例9: testConstructorWithMoney
public function testConstructorWithMoney()
{
$price = new Price([Money::EUR(5), Money::USD(10), Money::GBP(10), 'TRY' => 120], [CurrencyPair::createFromIso('USD/CHF 1.5'), CurrencyPair::createFromIso('USD/AWG 1.0')]);
$this->assertInstanceOf('Leaphly\\Price\\Price', $price);
$this->assertEquals(15, $price->getAmount('CHF'));
}
示例10: testCents
public function testCents()
{
$this->assertEquals(Money::USD(1234)->getCents(), Money::USD(1234)->getUnits());
}
示例11: chargeFee
public function chargeFee($amount, $percentage = 0.029, $flat = 30)
{
$amount = Money::USD($amount);
$flatfee = Money::USD($flat);
$fee = $amount->multiply($percentage);
$newAmount = $amount->subtract($fee);
$newAmount = $newAmount->subtract($flatfee);
return $newAmount->getAmount();
}
示例12: itSetsMoney
/**
* @test
*/
public function itSetsMoney()
{
$expense = new Expense();
$expense->setMoney($money = Money::USD(1000));
$this->assertEquals($money, $expense->getMoney());
}