Skip to content

Commit f743840

Browse files
committed
Added a bunch of tests. Increasing the coverage a bit.
1 parent d24035a commit f743840

File tree

15 files changed

+178
-80
lines changed

15 files changed

+178
-80
lines changed

examples/calendarserver.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ function exception_error_handler($errno, $errstr, $errfile, $errline) {
6868
/* WebDAV-Sync plugin */
6969
$server->addPlugin(new Sabre\DAV\Sync\Plugin());
7070

71+
/* CalDAV Sharing support */
72+
$server->addPlugin(new Sabre\DAV\Sharing\Plugin());
73+
$server->addPlugin(new Sabre\CalDAV\SharingPlugin());
74+
7175
// Support for html frontend
7276
$browser = new Sabre\DAV\Browser\Plugin();
7377
$server->addPlugin($browser);

lib/CalDAV/Backend/PDO.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,7 @@ function getInvites($calendarId) {
15021502
*/
15031503
function setPublishStatus($calendarId, $value) {
15041504

1505-
throw new \Exception('Not implemented');
1505+
throw new \Sabre\DAV\Exception\NotImplemented('Not implemented');
15061506

15071507
}
15081508

lib/CalDAV/Xml/Property/ScheduleCalendarTransp.php

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
use Sabre\Xml\Element;
66
use Sabre\Xml\Reader;
7+
use Sabre\Xml\Deserializer;
78
use Sabre\Xml\Writer;
8-
use Sabre\Xml\Element\Elements;
99
use Sabre\CalDAV\Plugin;
1010

1111
/**
@@ -116,23 +116,13 @@ function xmlSerialize(Writer $writer) {
116116
*/
117117
static function xmlDeserialize(Reader $reader) {
118118

119-
$elems = Elements::xmlDeserialize($reader);
119+
$elems = Deserializer\enum($reader, Plugin::NS_CALDAV);
120120

121-
$value = null;
122-
123-
foreach ($elems as $elem) {
124-
switch ($elem) {
125-
case '{' . Plugin::NS_CALDAV . '}opaque' :
126-
$value = self::OPAQUE;
127-
break;
128-
case '{' . Plugin::NS_CALDAV . '}transparent' :
129-
$value = self::TRANSPARENT;
130-
break;
131-
}
121+
if (in_array('transparent', $elems)) {
122+
$value = self::TRANSPARENT;
123+
} else {
124+
$value = self::OPAQUE;
132125
}
133-
if (is_null($value))
134-
return null;
135-
136126
return new self($value);
137127

138128
}

lib/DAV/Auth/Backend/File.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class File extends AbstractDigest {
2525
/**
2626
* Creates the backend object.
2727
*
28-
* If the filename argument is passed in, it will parse out the specified file fist.
28+
* If the filename argument is passed in, it will parse out the specified file first.
2929
*
3030
* @param string|null $filename
3131
*/

lib/DAV/FSExt/Directory.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,7 @@ function getChildren() {
131131

132132
foreach ($iterator as $entry) {
133133

134-
$node = $entry->getFilename();
135-
136-
if ($node === '.sabredav')
137-
continue;
138-
139-
$nodes[] = $this->getChild($node);
134+
$nodes[] = $this->getChild($entry->getFilename());
140135

141136
}
142137
return $nodes;
@@ -153,9 +148,6 @@ function delete() {
153148
// Deleting all children
154149
foreach ($this->getChildren() as $child) $child->delete();
155150

156-
// Removing resource info, if its still around
157-
if (file_exists($this->path . '/.sabredav')) unlink($this->path . '/.sabredav');
158-
159151
// Removing the directory itself
160152
rmdir($this->path);
161153

lib/DAV/Xml/Property/ShareAccess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static function xmlDeserialize(Reader $reader) {
127127
switch ($elem['name']) {
128128
case '{DAV:}not-shared' :
129129
return new self(SharingPlugin::ACCESS_NOTSHARED);
130-
case '{DAV:}sharedowner' :
130+
case '{DAV:}shared-owner' :
131131
return new self(SharingPlugin::ACCESS_SHAREDOWNER);
132132
case '{DAV:}read' :
133133
return new self(SharingPlugin::ACCESS_READ);

lib/DAV/Xml/Property/SupportedMethodSet.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,11 @@ class SupportedMethodSet implements XmlSerializable, HtmlOutput {
3232
/**
3333
* Creates the property
3434
*
35-
* Any reports passed in the constructor
36-
* should be valid report-types in clark-notation.
37-
*
38-
* Either a string or an array of strings must be passed.
39-
*
40-
* @param string|string[] $methods
35+
* @param string[] $methods
4136
*/
42-
function __construct($methods = null) {
37+
function __construct(array $methods) {
4338

44-
$this->methods = (array)$methods;
39+
$this->methods = $methods;
4540

4641
}
4742

tests/Sabre/CalDAV/Backend/AbstractPDOTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1418,4 +1418,14 @@ function testDeleteSharedCalendar() {
14181418

14191419
}
14201420

1421+
/**
1422+
* @expectedException \Sabre\DAV\Exception\NotImplemented
1423+
*/
1424+
function testSetPublishStatus() {
1425+
1426+
$backend = new PDO($this->pdo);
1427+
$backend->setPublishStatus([1, 1], true);
1428+
1429+
}
1430+
14211431
}

tests/Sabre/CalDAV/Xml/Property/InviteTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ function setUp() {
1919

2020
function testSimple() {
2121

22-
$sccs = new Invite([]);
23-
$this->assertInstanceOf('Sabre\CalDAV\Xml\Property\Invite', $sccs);
22+
$invite = new Invite([]);
23+
$this->assertInstanceOf('Sabre\CalDAV\Xml\Property\Invite', $invite);
24+
$this->assertEquals([], $invite->getValue());
2425

2526
}
2627

tests/Sabre/DAV/Auth/Backend/FileTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ function testConstruct() {
2323
function testLoadFileBroken() {
2424

2525
file_put_contents(SABRE_TEMPDIR . '/backend', 'user:realm:hash');
26-
$file = new File();
27-
$file->loadFile(SABRE_TEMPDIR . '/backend');
26+
$file = new File(SABRE_TEMPDIR . '/backend');
2827

2928
}
3029

0 commit comments

Comments
 (0)