Welcome to mirror list, hosted at ThFree Co, Russian Federation.

invalidpathtest.php « exception « sabre « connector « lib « tests - github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d2d58887d6217907ca4672931d578942e269c503 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php

namespace Test\Connector\Sabre\Exception;

use OC\Connector\Sabre\Exception\InvalidPath;

/**
 * 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.
 */
class InvalidPathTest extends \Test\TestCase {

	public function testSerialization() {

		// create xml doc
		$DOM = new \DOMDocument('1.0','utf-8');
		$DOM->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 = <<<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;

		$ex = new InvalidPath($message, $retry);
		$server = $this->getMock('Sabre\DAV\Server');
		$ex->serialize($server, $error);

		// assert
		$xml = $DOM->saveXML();
		$this->assertEquals($expectedXml, $xml);
	}
}