2015-02-18 16:44:13 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2015 Thomas Müller <deepdiver@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
2015-11-13 13:13:16 +00:00
|
|
|
|
|
|
|
namespace OCA\DAV\Tests\Unit\Connector\Sabre\Exception;
|
|
|
|
|
|
|
|
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
|
|
|
|
|
2015-02-18 17:28:24 +00:00
|
|
|
class InvalidPathTest extends \Test\TestCase {
|
2015-02-18 16:44:13 +00:00
|
|
|
|
|
|
|
public function testSerialization() {
|
|
|
|
|
|
|
|
// create xml doc
|
|
|
|
$DOM = new \DOMDocument('1.0','utf-8');
|
|
|
|
$DOM->formatOutput = true;
|
|
|
|
$error = $DOM->createElementNS('DAV:','d:error');
|
2015-02-18 17:28:24 +00:00
|
|
|
$error->setAttribute('xmlns:s', \Sabre\DAV\Server::NS_SABREDAV);
|
2015-02-18 16:44:13 +00:00
|
|
|
$DOM->appendChild($error);
|
|
|
|
|
|
|
|
// serialize the exception
|
|
|
|
$message = "1234567890";
|
|
|
|
$retry = false;
|
|
|
|
$expectedXml = <<<EOD
|
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
<d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns" xmlns:o="http://owncloud.org/ns">
|
|
|
|
<o:retry xmlns:o="o:">false</o:retry>
|
|
|
|
<o:reason xmlns:o="o:">1234567890</o:reason>
|
|
|
|
</d:error>
|
|
|
|
|
|
|
|
EOD;
|
|
|
|
|
2015-02-18 17:28:24 +00:00
|
|
|
$ex = new InvalidPath($message, $retry);
|
2015-02-18 16:44:13 +00:00
|
|
|
$server = $this->getMock('Sabre\DAV\Server');
|
|
|
|
$ex->serialize($server, $error);
|
|
|
|
|
|
|
|
// assert
|
|
|
|
$xml = $DOM->saveXML();
|
|
|
|
$this->assertEquals($expectedXml, $xml);
|
|
|
|
}
|
|
|
|
}
|