public function testAddURI() { $obj = new DAV_Element_href(); $obj->addURI('/path1'); $this->assertSame(array('/path1'), $obj->URIs, 'DAV_Element_href->URIs should contain one element when DAV_Element_href::addURI() is called once'); $obj->addURI('/path2'); $this->assertSame(array('/path1', '/path2'), $obj->URIs, 'DAV_Element_href->URIs should contain two elements when DAV_Element_href::addURI() is called twce'); $obj->addURI('/path3'); $this->assertSame(array('/path1', '/path2', '/path3'), $obj->URIs, 'DAV_Element_href->URIs should contain three elements when DAV_Element_href::addURI() is called thrice'); }
/** * Parses a piece of XML with <D:href> pieces * * @param string $hrefs * @return DAV_Element_href * @throws DAV_Status */ public static function parse_hrefs($hrefs) { $href = new DAV_Element_href(); if (!preg_match('@^\\s*(?:<D:href(?:\\s+[^>]*)?>\\s*[^\\s<]+\\s*</D:href>\\s*)*$@', $hrefs)) { return $href; } preg_match_all('@<D:href(?:\\s+[^>]*)?>\\s*([^\\s<]+)\\s*</D:href>@', $hrefs, $matches); foreach ($matches[1] as $match) { $href->addURI(DAV::parseURI($match, false)); } return $href; }