assertEquals('foo', $notification->getId()); $this->assertEquals('"1"', $notification->getETag()); $simpleExpected = '' . "\n"; $this->namespaceMap['http://calendarserver.org/ns/'] = 'cs'; $xml = $this->write($notification); $this->assertXmlStringEqualsXmlString($simpleExpected, $xml); $this->namespaceMap['urn:ietf:params:xml:ns:caldav'] = 'cal'; $xml = $this->writeFull($notification); $this->assertXmlStringEqualsXmlString($expected, $xml); } function dataProvider() { $dtStamp = new \DateTime('2012-01-01 00:00:00', new \DateTimeZone('GMT')); return array( array( array( 'id' => 'foo', 'dtStamp' => $dtStamp, 'etag' => '"1"', 'href' => 'mailto:foo@example.org', 'type' => CalDAV\SharingPlugin::STATUS_ACCEPTED, 'readOnly' => true, 'hostUrl' => 'calendar', 'organizer' => 'principal/user1', 'commonName' => 'John Doe', 'summary' => 'Awesome stuff!' ), << 20120101T000000Z foo mailto:foo@example.org /calendar Awesome stuff! /principal/user1 John Doe John Doe FOO ), array( array( 'id' => 'foo', 'dtStamp' => $dtStamp, 'etag' => '"1"', 'href' => 'mailto:foo@example.org', 'type' => CalDAV\SharingPlugin::STATUS_DECLINED, 'readOnly' => true, 'hostUrl' => 'calendar', 'organizer' => 'principal/user1', 'commonName' => 'John Doe', ), << 20120101T000000Z foo mailto:foo@example.org /calendar /principal/user1 John Doe John Doe FOO ), array( array( 'id' => 'foo', 'dtStamp' => $dtStamp, 'etag' => '"1"', 'href' => 'mailto:foo@example.org', 'type' => CalDAV\SharingPlugin::STATUS_NORESPONSE, 'readOnly' => true, 'hostUrl' => 'calendar', 'organizer' => 'principal/user1', 'firstName' => 'Foo', 'lastName' => 'Bar', ), << 20120101T000000Z foo mailto:foo@example.org /calendar /principal/user1 Foo Bar Foo Bar FOO ), array( array( 'id' => 'foo', 'dtStamp' => $dtStamp, 'etag' => '"1"', 'href' => 'mailto:foo@example.org', 'type' => CalDAV\SharingPlugin::STATUS_DELETED, 'readOnly' => false, 'hostUrl' => 'calendar', 'organizer' => 'mailto:user1@fruux.com', 'supportedComponents' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT','VTODO']), ), << 20120101T000000Z foo mailto:foo@example.org /calendar mailto:user1@fruux.com FOO ), ); } /** * @expectedException InvalidArgumentException */ function testMissingArg() { new Invite(array()); } /** * @expectedException InvalidArgumentException */ function testUnknownArg() { new Invite(array( 'foo-i-will-break' => true, 'id' => 1, 'etag' => '"bla"', 'href' => 'abc', 'dtStamp' => 'def', 'type' => 'ghi', 'readOnly' => true, 'hostUrl' => 'jkl', 'organizer' => 'mno', )); } function writeFull($input) { $writer = new Writer(); $writer->contextUri = '/'; $writer->namespaceMap = $this->namespaceMap; $writer->openMemory(); $writer->startElement('{http://calendarserver.org/ns/}root'); $input->xmlSerializeFull($writer); $writer->endElement(); return $writer->outputMemory(); } }