Пример #1
0
 function testDisplayingAltCurrency()
 {
     $w = getWidget();
     foreach (array(array(Currencies\USD(), Currencies\BTC()), array(Currencies\BTC(), Currencies\USD())) as $pair) {
         $w->currency = $pair[0];
         $w->save();
         $altCurrency = $pair[1];
         $this->browseToWidget($w);
         foreach ($this->xpathQuery("//div[@class='alt-amount']") as $div) {
             assertTrue(contains($div->textContent, $altCurrency), "Alt-currency should be listed with unit {$altCurrency}");
         }
     }
 }
Пример #2
0
function testProgressProperlyCalculated()
{
    $w = getWidget();
    $addr = getBitcoinAddr($btcBalance = 2);
    # Case where widget uses BTC as base currency.
    $w->bitcoinAddress = $addr;
    $w->setGoal(4, Currencies\BTC());
    $w->save();
    $reloaded = Widget::getByID($w->id);
    assertTrue($reloaded->progressPercent > 49 && $reloaded->progressPercent < 51);
    # Case where widget uses fiat as base currency.
    setPriceForBTC(Currencies\USD(), 100);
    $w->bitcoinAddress = $addr;
    $w->setGoal(600, Currencies\USD());
    $w->save();
    $reloaded = Widget::getByID($w->id);
    $expected = 200 / 600 * 100;
    assertTrue($reloaded->progressPercent > floor($expected) && $reloaded->progressPercent < ceil($expected));
}