/** * @Then The CalDAV HTTP status code should be :code */ public function theCaldavHttpStatusCodeShouldBe($code) { if ((int) $code !== $this->response->getStatusCode()) { throw new \Exception(sprintf('Expected %s got %s', (int) $code, $this->response->getStatusCode())); } $body = $this->response->getBody()->getContents(); if ($body && substr($body, 0, 1) === '<') { $reader = new Sabre\Xml\Reader(); $reader->xml($body); $this->responseXml = $reader->parse(); } }
/** * @return array * @throws \Exception */ public function read() { if (!file_exists($this->configFile)) { $this->log('<error>Config file not exists.</error>'); return false; } else { $reader = new \Sabre\Xml\Reader(); $reader->xml(file_get_contents($this->configFile)); $xml = $reader->parse(); $config = []; return $config; } }
public function __construct(\Sculptor\Clay $clay) { $reader = new \Sabre\Xml\Reader(); $reader->xml(file_get_contents($clay->input)); $this->data = $reader->parse(); foreach ($this->data['value'] as $data) { foreach ($data['value'] as $value) { if ($value['name'] == "{}item") { $post = $this->addPost($value); $post->write($clay->output); } } } }
/** * @When :user requests addressbook :addressBook with statuscode :statusCode */ public function requestsAddressbookWithStatuscode($user, $addressBook, $statusCode) { $davUrl = $this->baseUrl . '/remote.php/dav/addressbooks/users/' . $addressBook; $password = $user === 'admin' ? 'admin' : '123456'; try { $this->response = $this->client->get($davUrl, ['auth' => [$user, $password]]); } catch (\GuzzleHttp\Exception\ClientException $e) { $this->response = $e->getResponse(); } if ((int) $statusCode !== $this->response->getStatusCode()) { throw new \Exception(sprintf('Expected %s got %s', (int) $statusCode, $this->response->getStatusCode())); } $body = $this->response->getBody()->getContents(); if (substr($body, 0, 1) === '<') { $reader = new Sabre\Xml\Reader(); $reader->xml($body); $this->responseXml = $reader->parse(); } }
public function getArrayKeysAndValues($pathFile) { $reader = new \Sabre\Xml\Reader(); $reader->open($pathFile); $reader->elementMap = ['{http://apache.org/cocoon/i18n/2.1}catalogue' => 'Sabre\\Xml\\Element\\KeyValue']; $rows = array(); $output = array(); foreach ($reader->parse() as $key => $row) { if (!is_array($row) || count($row) == 1) { continue; } $rows = $row; } $reader->close(); foreach ($rows as $key => $row) { $key = $row['attributes']['key']; $value = $row['value']; $output[$key] = $value; } return $output; }
/** * @expectedException Sabre\DAV\Exception\NotImplemented */ function testUnserializeDeny() { $source = '<?xml version="1.0"?> <d:root xmlns:d="DAV:"> <d:ignore-me /> <d:ace> <d:deny> <d:privilege> <d:write/> </d:privilege> </d:deny> <d:principal><d:href>/principals/evert</d:href></d:principal> </d:ace> </d:root> '; $reader = new \Sabre\Xml\Reader(); $reader->elementMap['{DAV:}root'] = 'Sabre\\DAVACL\\Xml\\Property\\Acl'; $reader->xml($source); $result = $reader->parse(); }