Exemplo n.º 1
0
 function testWidgetPreview()
 {
     $ds = Widgets\allowedSizes();
     $descriptions = array('This is to test preview mode.', str_repeat('words ', 100));
     foreach ($descriptions as $about) {
         $this->get("/widgets/preview?title=Oh+Bother&goal=3&currency=BTC&" . "about=" . urlencode($about) . "&ending=2020-07-25&address=" . $this->btcAddr() . "&" . "width={$ds[0]->width}&height={$ds[0]->height}&color=silver");
         $this->assertContains("//div[contains(., '" . substr($about, 0, 15) . "')]");
         $goalDiv = current($this->xpathQuery("//div[@class='goal']"));
         assertTrue(contains($goalDiv->textContent, '3 BTC') || contains($goalDiv->textContent, '3.0 BTC'));
     }
 }
Exemplo n.º 2
0
 private function renderWidgetArr(array $vars)
 {
     $w = $vars['width'];
     $h = $vars['height'];
     if (!Widgets\validDimensions($w, $h)) {
         $ds = Widgets\allowedSizes();
         $w = $ds[0]->width;
         $h = $ds[0]->height;
         # TODO: Log warning that a request for invalid widget dimensions was made.
     }
     return $this->renderDietTpl("widgets/{$w}x{$h}.diet-php", $vars);
 }
Exemplo n.º 3
0
 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]);
 }