2015-02-18 11:44:13 -05:00
|
|
|
<?php
|
2024-05-28 06:34:11 -04:00
|
|
|
|
2025-05-27 17:36:08 -04:00
|
|
|
declare(strict_types=1);
|
2015-02-18 11:44:13 -05:00
|
|
|
/**
|
2024-05-28 06:34:11 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-02-18 11:44:13 -05:00
|
|
|
*/
|
2016-05-25 10:04:15 -04:00
|
|
|
namespace OCA\DAV\Tests\unit\Connector\Sabre\Exception;
|
2015-11-13 08:13:16 -05:00
|
|
|
|
|
|
|
|
use OCA\DAV\Connector\Sabre\Exception\InvalidPath;
|
2025-05-27 17:36:08 -04:00
|
|
|
use Sabre\DAV\Server;
|
2015-11-13 08:13:16 -05:00
|
|
|
|
2015-02-18 12:28:24 -05:00
|
|
|
class InvalidPathTest extends \Test\TestCase {
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testSerialization(): void {
|
2015-02-18 11:44:13 -05:00
|
|
|
|
|
|
|
|
// create xml doc
|
|
|
|
|
$DOM = new \DOMDocument('1.0', 'utf-8');
|
|
|
|
|
$DOM->formatOutput = true;
|
|
|
|
|
$error = $DOM->createElementNS('DAV:', 'd:error');
|
2015-02-18 12:28:24 -05:00
|
|
|
$error->setAttribute('xmlns:s', \Sabre\DAV\Server::NS_SABREDAV);
|
2015-02-18 11:44:13 -05: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 12:28:24 -05:00
|
|
|
$ex = new InvalidPath($message, $retry);
|
2025-05-27 17:36:08 -04:00
|
|
|
$server = $this->createMock(Server::class);
|
2015-02-18 11:44:13 -05:00
|
|
|
$ex->serialize($server, $error);
|
|
|
|
|
|
|
|
|
|
// assert
|
|
|
|
|
$xml = $DOM->saveXML();
|
|
|
|
|
$this->assertEquals($expectedXml, $xml);
|
|
|
|
|
}
|
|
|
|
|
}
|