Esempio n. 1
0
function getWidget(User $u = null)
{
    require_once 'chipin/widgets.php';
    if ($u == null) {
        $u = getUser();
    }
    $w = new Widget();
    $w->ownerID = $u->id;
    $w->title = "Test Widget";
    $w->ending = new DateTime('2020-06-30');
    $w->setGoal(100, 'USD');
    $w->setDimensions(350, 310);
    $colors = Widgets\allowedColors();
    $w->color = $colors[0];
    $w->bitcoinAddress = getBitcoinAddr();
    $w->countryCode = 'CA';
    $w->about = "This is a test widget!";
    $w->save();
    return $w;
}
 function testThatFieldsArePrePopulatedWhenEditingWidget()
 {
     $u = $this->loginAsNormalUser();
     $w = new Widget();
     $w->ownerID = $u->id;
     $w->title = 'Party Party';
     $w->about = 'Vamos a festejar.';
     $w->setGoal(50, 'CAD');
     $w->ending = '2015-12-31';
     $w->bitcoinAddress = $this->btcAddr();
     $sizes = Widgets\allowedSizes();
     $w->width = $sizes[0]->width;
     $w->height = $sizes[0]->height;
     $colors = Widgets\allowedColors();
     $w->color = $colors[0];
     $w->save();
     $this->get('/widget-wiz/step-one?w=' . $w->id);
     $titleInput = current($this->xpathQuery("//input[@name='title']"));
     assertEqual('Party Party', $titleInput->getAttribute('value'));
     $endDateInput = current($this->xpathQuery("//input[@name='ending']"));
     $this->assertDatesAreEqual($w->ending, $endDateInput->getAttribute('value'));
     $this->expectSpecificOption($fieldName = 'currency', $expectedValue = 'CAD');
     $this->submitForm($this->getForm(), array());
     $this->expectSpecificOption($fieldName = 'size', $expectedValue = $sizes[0]);
     $this->expectSpecificOption($fieldName = 'color', $expectedValue = $colors[0]);
 }