2015-11-13 16:13:16 +03:00
|
|
|
<?php
|
|
|
|
/**
|
2016-01-12 17:02:16 +03:00
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
2016-07-21 17:49:16 +03:00
|
|
|
*
|
|
|
|
* @author Joas Schilling <coding@schilljs.com>
|
|
|
|
* @author Roeland Jago Douma <roeland@famdouma.nl>
|
|
|
|
*
|
2016-01-12 17:02:16 +03:00
|
|
|
* @license AGPL-3.0
|
|
|
|
*
|
|
|
|
* This code is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License, version 3,
|
|
|
|
* as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3,
|
2019-12-03 21:57:53 +03:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
2016-01-12 17:02:16 +03:00
|
|
|
*
|
2015-11-13 16:13:16 +03:00
|
|
|
*/
|
|
|
|
|
2016-05-25 17:04:15 +03:00
|
|
|
namespace OCA\DAV\Tests\unit\Connector\Sabre\Exception;
|
2015-11-13 16:13:16 +03:00
|
|
|
|
|
|
|
use OCA\DAV\Connector\Sabre\Exception\Forbidden;
|
|
|
|
|
|
|
|
class ForbiddenTest 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 Forbidden($message, $retry);
|
2016-07-15 10:52:46 +03:00
|
|
|
$server = $this->getMockBuilder('Sabre\DAV\Server')
|
|
|
|
->disableOriginalConstructor()
|
|
|
|
->getMock();
|
2015-11-13 16:13:16 +03:00
|
|
|
$ex->serialize($server, $error);
|
|
|
|
|
|
|
|
// assert
|
|
|
|
$xml = $DOM->saveXML();
|
|
|
|
$this->assertEquals($expectedXml, $xml);
|
|
|
|
}
|
|
|
|
}
|