Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1821424
ServerUpdatePropertiesTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
3 KB
Subscribers
None
ServerUpdatePropertiesTest.php
View Options
<?php
namespace
Sabre\DAV
;
use
Sabre\HTTP
;
class
ServerUpdatePropertiesTest
extends
\PHPUnit_Framework_TestCase
{
function
testUpdatePropertiesFail
()
{
$tree
=
array
(
new
SimpleCollection
(
'foo'
),
);
$server
=
new
Server
(
$tree
);
$result
=
$server
->
updateProperties
(
'foo'
,
array
(
'{DAV:}foo'
=>
'bar'
));
$expected
=
array
(
'{DAV:}foo'
=>
403
,
);
$this
->
assertEquals
(
$expected
,
$result
);
}
function
testUpdatePropertiesProtected
()
{
$tree
=
array
(
new
SimpleCollection
(
'foo'
),
);
$server
=
new
Server
(
$tree
);
$server
->
on
(
'propPatch'
,
function
(
$path
,
PropPatch
$propPatch
)
{
$propPatch
->
handleRemaining
(
function
()
{
return
true
;
});
});
$result
=
$server
->
updateProperties
(
'foo'
,
array
(
'{DAV:}getetag'
=>
'bla'
,
'{DAV:}foo'
=>
'bar'
));
$expected
=
array
(
'{DAV:}getetag'
=>
403
,
'{DAV:}foo'
=>
424
,
);
$this
->
assertEquals
(
$expected
,
$result
);
}
function
testUpdatePropertiesEventFail
()
{
$tree
=
array
(
new
SimpleCollection
(
'foo'
),
);
$server
=
new
Server
(
$tree
);
$server
->
on
(
'propPatch'
,
function
(
$path
,
PropPatch
$propPatch
)
{
$propPatch
->
setResultCode
(
'{DAV:}foo'
,
404
);
$propPatch
->
handleRemaining
(
function
()
{
return
true
;
});
});
$result
=
$server
->
updateProperties
(
'foo'
,
array
(
'{DAV:}foo'
=>
'bar'
,
'{DAV:}foo2'
=>
'bla'
,
));
$expected
=
array
(
'{DAV:}foo'
=>
404
,
'{DAV:}foo2'
=>
424
,
);
$this
->
assertEquals
(
$expected
,
$result
);
}
function
updatePropFail
(&
$propertyDelta
,
&
$result
,
$node
)
{
$result
[
404
]
=
array
(
'{DAV:}foo'
=>
null
,
);
unset
(
$propertyDelta
[
'{DAV:}foo'
]);
return
false
;
}
function
testUpdatePropertiesEventSuccess
()
{
$tree
=
array
(
new
SimpleCollection
(
'foo'
),
);
$server
=
new
Server
(
$tree
);
$server
->
on
(
'propPatch'
,
function
(
$path
,
PropPatch
$propPatch
)
{
$propPatch
->
handle
([
'{DAV:}foo'
,
'{DAV:}foo2'
],
function
()
{
return
[
'{DAV:}foo'
=>
200
,
'{DAV:}foo2'
=>
201
,
];
});
});
$result
=
$server
->
updateProperties
(
'foo'
,
array
(
'{DAV:}foo'
=>
'bar'
,
'{DAV:}foo2'
=>
'bla'
,
));
$expected
=
array
(
'{DAV:}foo'
=>
200
,
'{DAV:}foo2'
=>
201
,
);
$this
->
assertEquals
(
$expected
,
$result
);
}
function
updatePropSuccess
(&
$propertyDelta
,
&
$result
,
$node
)
{
$result
[
200
]
=
array
(
'{DAV:}foo'
=>
null
,
);
$result
[
201
]
=
array
(
'{DAV:}foo2'
=>
null
,
);
unset
(
$propertyDelta
[
'{DAV:}foo'
]);
unset
(
$propertyDelta
[
'{DAV:}foo2'
]);
return
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Tue, Dec 24, 12:06 AM (1 d, 7 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914641
Default Alt Text
ServerUpdatePropertiesTest.php (3 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment