Example #1
0
 public function testIsInitialized()
 {
     $e = new Zend_Feed_Entry_Atom();
     $e->author->name['last'] = 'hagenbuch';
     $e->author->name['first'] = 'chuck';
     $e->author->name->{'chuck:url'} = 'marina.horde.org';
     $e->author->title['foo'] = 'bar';
     if ($e->pants()) {
         $this->fail('<pants> does not exist, it should not have a true value');
         // This should not create an element in the actual tree.
     }
     if ($e->pants()) {
         $this->fail('<pants> should not have been created by testing for it');
         // This should not create an element in the actual tree.
     }
     $xml = $e->saveXML();
     $this->assertFalse(strpos($xml, 'pants'), '<pants> should not be in the xml output');
     $this->assertTrue(strpos($xml, 'marina.horde.org') !== false, 'the url attribute should be set');
 }
/**
 * Creates an event on the authenticated user's default calendar with the
 * specified event details.
 *
 * @param Zend_Http_Client $client The authenticated client object
 * @param string $title The event title
 * @param string $desc The detailed description of the event
 * @param string $startDate The start date of the event in YYYY-MM-DD format
 * @param string $startTime The start time of the event in HH:MM 24hr format
 * @param string $endTime The end time of the event in HH:MM 24hr format
 * @param string $tzOffset The offset from GMT/UTC in [+-]DD format (eg -08)
 * @return void
 */
function createEvent($client, $title = 'Tennis with Beth', $desc = 'Meet for a quick lesson', $where = 'On the courts', $startDate = '2008-01-20', $startTime = '10:00', $endDate = '2008-01-20', $endTime = '11:00', $tzOffset = '-08')
{
    $gdataCal = new Zend_Gdata_Calendar($client);
    Zend_Feed::registerNamespace('gd', 'http://schemas.google.com/g/2005');
    $newEntry = new Zend_Feed_Entry_Atom();
    $newEntry->title = trim($title);
    $newEntry->{'gd:where'}['valueString'] = $where;
    $newEntry->content = $desc;
    $newEntry->content['type'] = 'text';
    $when = $newEntry->{'gd:when'};
    $when['startTime'] = "{$startDate}T{$startTime}:00.000{$tzOffset}:00";
    $when['endTime'] = "{$endDate}T{$endTime}:00.000{$tzOffset}:00";
    $gdataCal->post($newEntry->saveXML());
}