mirror of
https://github.com/nextcloud/server.git
synced 2026-04-21 22:27:31 -04:00
a few tests
This commit is contained in:
parent
d0ec6b9c15
commit
77216e7ca9
2 changed files with 89 additions and 0 deletions
|
|
@ -334,6 +334,24 @@ EOD;
|
|||
$this->assertEquals($event, $changes['added'][0]);
|
||||
}
|
||||
|
||||
public function testPublications() {
|
||||
$this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', []);
|
||||
|
||||
$calendarInfo = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER)[0];
|
||||
|
||||
$l10n = $this->getMockBuilder('\OCP\IL10N')
|
||||
->disableOriginalConstructor()->getMock();
|
||||
|
||||
$calendar = new Calendar($this->backend, $calendarInfo, $l10n);
|
||||
$this->backend->setPublishStatus(true, $calendar);
|
||||
$this->assertEquals(true, $this->backend->getPublishStatus($calendar));
|
||||
|
||||
$publicCalendars = $this->backend->getPublicCalendars();
|
||||
$this->assertEquals(1, count($publicCalendars));
|
||||
$this->assertEquals(true, $publicCalendars[0]['{http://owncloud.org/ns}public']);
|
||||
|
||||
}
|
||||
|
||||
public function testSubscriptions() {
|
||||
$id = $this->backend->createSubscription(self::UNIT_TEST_USER, 'Subscription', [
|
||||
'{http://calendarserver.org/ns/}source' => new Href('test-source'),
|
||||
|
|
|
|||
71
apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php
Normal file
71
apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\DAV\Tests\unit\CalDAV\Publishing;
|
||||
|
||||
use OCA\DAV\CalDAV\Calendar;
|
||||
use OCA\DAV\CalDAV\Publishing\PublishPlugin;
|
||||
use OCA\DAV\Connector\Sabre\Auth;
|
||||
use OCP\IRequest;
|
||||
use Sabre\DAV\Server;
|
||||
use Sabre\DAV\SimpleCollection;
|
||||
use Sabre\HTTP\Request;
|
||||
use Sabre\HTTP\Response;
|
||||
use Test\TestCase;
|
||||
|
||||
class PluginTest extends TestCase {
|
||||
|
||||
/** @var Plugin */
|
||||
private $plugin;
|
||||
/** @var Server */
|
||||
private $server;
|
||||
/** @var Calendar | \PHPUnit_Framework_MockObject_MockObject */
|
||||
private $book;
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
/** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */
|
||||
$authBackend = $this->getMockBuilder('OCA\DAV\DAV\PublicAuth')->disableOriginalConstructor()->getMock();
|
||||
$authBackend->method('isDavAuthenticated')->willReturn(true);
|
||||
|
||||
/** @var IRequest $request */
|
||||
$request = $this->getMockBuilder('OCP\IRequest')->disableOriginalConstructor()->getMock();
|
||||
$this->plugin = new PublishPlugin($authBackend, $request);
|
||||
|
||||
$root = new SimpleCollection('calendars');
|
||||
$this->server = new Server($root);
|
||||
/** @var SimpleCollection $node */
|
||||
$this->book = $this->getMockBuilder('OCA\DAV\CalDAV\Calendar')->
|
||||
disableOriginalConstructor()->
|
||||
getMock();
|
||||
$this->book->method('getName')->willReturn('cal1');
|
||||
$root->addChild($this->book);
|
||||
$this->plugin->initialize($this->server);
|
||||
}
|
||||
|
||||
public function testPublishing() {
|
||||
|
||||
$this->book->expects($this->once())->method('setPublishStatus')->with(true);
|
||||
|
||||
// setup request
|
||||
$request = new Request();
|
||||
$request->addHeader('Content-Type', 'application/xml');
|
||||
$request->setUrl('cal1');
|
||||
$request->setBody('<o:publish-calendar xmlns:o="http://calendarserver.org/ns/"/>');
|
||||
$response = new Response();
|
||||
$this->plugin->httpPost($request, $response);
|
||||
}
|
||||
|
||||
public function testUnPublishing() {
|
||||
|
||||
$this->book->expects($this->once())->method('setPublishStatus')->with(true);
|
||||
|
||||
// setup request
|
||||
$request = new Request();
|
||||
$request->addHeader('Content-Type', 'application/xml');
|
||||
$request->setUrl('cal1');
|
||||
$request->setBody('<o:unpublish-calendar xmlns:o="http://calendarserver.org/ns/"/>');
|
||||
$response = new Response();
|
||||
$this->plugin->httpPost($request, $response);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue