public function testNormalWebContentShouldHaveNoExtensionElements()
 {
     $this->webContent->url = "http://nowhere.invalid/";
     $this->webContent->height = "100";
     $this->webContent->width = "200";
     $this->assertEquals($this->webContent->url, "http://nowhere.invalid/");
     $this->assertEquals($this->webContent->height, "100");
     $this->assertEquals($this->webContent->width, "200");
     $this->assertEquals(count($this->webContent->extensionElements), 0);
     $newWebContent = new Zend_Gdata_Calendar_Extension_WebContent();
     $newWebContent->transferFromXML($this->webContent->saveXML());
     $this->assertEquals(count($newWebContent->extensionElements), 0);
     $newWebContent->extensionElements = array(new Zend_Gdata_App_Extension_Element('foo', 'atom', null, 'bar'));
     $this->assertEquals(count($newWebContent->extensionElements), 1);
     $this->assertEquals($newWebContent->url, "http://nowhere.invalid/");
     $this->assertEquals($newWebContent->height, "100");
     $this->assertEquals($newWebContent->width, "200");
     /* try constructing using magic factory */
     $cal = new Zend_Gdata_Calendar();
     $newWebContent2 = $cal->newWebContent();
     $newWebContent2->transferFromXML($newWebContent->saveXML());
     $this->assertEquals(count($newWebContent2->extensionElements), 1);
     $this->assertEquals($newWebContent2->url, "http://nowhere.invalid/");
     $this->assertEquals($newWebContent2->height, "100");
     $this->assertEquals($newWebContent2->width, "200");
 }
Beispiel #2
0
/**
 * Creates a new web content event on the authenticated user's default 
 * calendar with the specified event details. For simplicity, the event 
 * is created as an all day event and does not include a description.
 *
 * @param Zend_Http_Client $client The authenticated client object
 * @param string $title The event title
 * @param string $startDate The start date of the event in YYYY-MM-DD format
 * @param string $endDate The end time of the event in HH:MM 24hr format
 * @param string $icon URL pointing to a 16x16 px icon representing the event.
 * @param string $url The URL containing the web content for the event.
 * @param string $height The desired height of the web content pane.
 * @param string $width The desired width of the web content pane.
 * @param string $type The MIME type of the web content.
 * @return string The ID URL for the event.
 */
function createWebContentEvent($client, $title = 'World Cup 2006', $startDate = '2006-06-09', $endDate = '2006-06-09', $icon = 'http://www.google.com/calendar/images/google-holiday.gif', $url = 'http://www.google.com/logos/worldcup06.gif', $height = '120', $width = '276', $type = 'image/gif')
{
    $gc = new Zend_Gdata_Calendar($client);
    $newEntry = $gc->newEventEntry();
    $newEntry->title = $gc->newTitle(trim($title));
    $when = $gc->newWhen();
    $when->startTime = $startDate;
    $when->endTime = $endDate;
    $newEntry->when = array($when);
    $wc = $gc->newWebContent();
    $wc->url = $url;
    $wc->height = $height;
    $wc->width = $width;
    $wcLink = $gc->newLink();
    $wcLink->rel = "http://schemas.google.com/gCal/2005/webContent";
    $wcLink->title = $title;
    $wcLink->type = $type;
    $wcLink->href = $icon;
    $wcLink->webContent = $wc;
    $newEntry->link = array($wcLink);
    $createdEntry = $gc->insertEvent($newEntry);
    return $createdEntry->id->text;
}