formatOutput = true; $error = $DOM->createElementNS('DAV:', 'd:error'); $error->setAttribute('xmlns:s', \Sabre\DAV\Server::NS_SABREDAV); $DOM->appendChild($error); // serialize the exception $message = '1234567890'; $retry = false; $expectedXml = << false 1234567890 EOD; $ex = new InvalidPath($message, $retry); $server = $this->getMockBuilder('Sabre\DAV\Server') ->disableOriginalConstructor() ->getMock(); $ex->serialize($server, $error); // assert $xml = $DOM->saveXML(); $this->assertEquals($expectedXml, $xml); } }