10 '{http://sabre.io/ns}test' =>
'Test!',
14 $util->elementMap = $elems;
17 $this->assertInstanceOf(
'Sabre\\Xml\\Reader',
$reader);
18 $this->assertEquals($elems,
$reader->elementMap);
25 'http://sabre.io/ns' =>
's',
29 $util->namespaceMap = $ns;
31 $writer = $util->getWriter();
32 $this->assertInstanceOf(
'Sabre\\Xml\\Writer', $writer);
33 $this->assertEquals($ns, $writer->namespaceMap);
43<root xmlns=
"http://sabre.io/ns">
49 $this->assertEquals(
'{http://sabre.io/ns}root', $rootElement);
53 'name' =>
'{http://sabre.io/ns}child',
72<root xmlns=
"http://sabre.io/ns">
76 $stream = fopen(
'php://memory',
'r+');
82 $this->assertEquals(
'{http://sabre.io/ns}root', $rootElement);
86 'name' =>
'{http://sabre.io/ns}child',
105<root xmlns=
"http://sabre.io/ns">
110 $result = $util->expect(
'{http://sabre.io/ns}root',
$xml);
114 'name' =>
'{http://sabre.io/ns}child',
132<root xmlns=
"http://sabre.io/ns">
137 $stream = fopen(
'php://memory',
'r+');
146 'name' =>
'{http://sabre.io/ns}child',
165<root xmlns=
"http://sabre.io/ns">
170 $util->expect(
'{http://sabre.io/ns}error',
$xml);
180 $util->namespaceMap = [
181 'http://sabre.io/ns' =>
's',
183 $result = $util->write(
'{http://sabre.io/ns}root', [
184 '{http://sabre.io/ns}child' =>
'value',
189<s:root xmlns:s=
"http://sabre.io/ns">
190 <s:child>value</s:child>
205<order xmlns=
"http://sabredav.org/ns">
207 <amount>99.99</amount>
208 <description>black friday deal</description>
211 <label>processed</label>
217 $ns =
'http://sabredav.org/ns';
218 $orderService = new \Sabre\Xml\Service();
219 $orderService->mapValueObject(
'{' . $ns .
'}order',
'Sabre\Xml\Order');
220 $orderService->mapValueObject(
'{' . $ns .
'}status',
'Sabre\Xml\OrderStatus');
221 $orderService->namespaceMap[$ns] =
null;
223 $order = $orderService->parse(
$input);
224 $expected =
new Order();
225 $expected->id = 1234;
226 $expected->amount = 99.99;
227 $expected->description =
'black friday deal';
229 $expected->status->id = 5;
230 $expected->status->label =
'processed';
232 $this->assertEquals($expected, $order);
234 $writtenXml = $orderService->writeValueObject($order);
235 $this->assertEquals(
$input, $writtenXml);
242<order xmlns=
"http://sabredav.org/ns">
244 <amount>99.99</amount>
245 <description>black friday deal</description>
248 <label>processed</label>
256 $ns =
'http://sabredav.org/ns';
257 $orderService = new \Sabre\Xml\Service();
258 $orderService->mapValueObject(
'{' . $ns .
'}order',
'Sabre\Xml\Order');
259 $orderService->mapValueObject(
'{' . $ns .
'}status',
'Sabre\Xml\OrderStatus');
260 $orderService->namespaceMap[$ns] =
null;
262 $order = $orderService->parse(
$input);
263 $expected =
new Order();
264 $expected->id = 1234;
265 $expected->amount = 99.99;
266 $expected->description =
'black friday deal';
268 $expected->status->id = 5;
269 $expected->status->label =
'processed';
270 $expected->link = [
'http://example.org/',
'http://example.com/'];
272 $this->assertEquals($expected, $order);
274 $writtenXml = $orderService->writeValueObject($order);
275 $this->assertEquals(
$input, $writtenXml);
284 $service->writeValueObject(
new \StdClass());
290 $this->assertEquals([
291 'http://sabredav.org/ns',
An exception for terminatinating execution or to throw for unit testing.
asset for testMapValueObject()
asset for testMapValueObject()
testParse()
@depends testGetReader
testExpect()
@depends testGetReader
testExpectWrong()
@depends testGetReader @expectedException \Sabre\Xml\ParseException
testParseClarkNotationFail()
@expectedException \InvalidArgumentException
testParseStream()
@depends testGetReader
testMapValueObjectArrayProperty()
testWriteVoNotFound()
@expectedException \InvalidArgumentException
testExpectStream()
@depends testGetReader
testWrite()
@depends testGetWriter
XML parsing and writing service.
static parseClarkNotation($str)
Parses a clark-notation string, and returns the namespace and element name components.
$stream
PHP stream implementation.
static http()
Fetches the global http state from ILIAS.