Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1821032
CardTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
4 KB
Subscribers
None
CardTest.php
View Options
<?php
namespace
Sabre\CardDAV
;
class
CardTest
extends
\PHPUnit_Framework_TestCase
{
/**
* @var Sabre\CardDAV\Card
*/
protected
$card
;
/**
* @var Sabre\CardDAV\MockBackend
*/
protected
$backend
;
function
setUp
()
{
$this
->
backend
=
new
Backend\Mock
();
$this
->
card
=
new
Card
(
$this
->
backend
,
array
(
'uri'
=>
'book1'
,
'id'
=>
'foo'
,
'principaluri'
=>
'principals/user1'
,
),
array
(
'uri'
=>
'card1'
,
'addressbookid'
=>
'foo'
,
'carddata'
=>
'card'
,
)
);
}
function
testGet
()
{
$result
=
$this
->
card
->
get
();
$this
->
assertEquals
(
'card'
,
$result
);
}
function
testGet2
()
{
$this
->
card
=
new
Card
(
$this
->
backend
,
array
(
'uri'
=>
'book1'
,
'id'
=>
'foo'
,
'principaluri'
=>
'principals/user1'
,
),
array
(
'uri'
=>
'card1'
,
'addressbookid'
=>
'foo'
,
)
);
$result
=
$this
->
card
->
get
();
$this
->
assertEquals
(
"BEGIN:VCARD
\n
VERSION:3.0
\n
UID:12345
\n
END:VCARD"
,
$result
);
}
/**
* @depends testGet
*/
function
testPut
()
{
$file
=
fopen
(
'php://memory'
,
'r+'
);
fwrite
(
$file
,
'newdata'
);
rewind
(
$file
);
$this
->
card
->
put
(
$file
);
$result
=
$this
->
card
->
get
();
$this
->
assertEquals
(
'newdata'
,
$result
);
}
function
testDelete
()
{
$this
->
card
->
delete
();
$this
->
assertEquals
(
1
,
count
(
$this
->
backend
->
cards
[
'foo'
]));
}
function
testGetContentType
()
{
$this
->
assertEquals
(
'text/vcard; charset=utf-8'
,
$this
->
card
->
getContentType
());
}
function
testGetETag
()
{
$this
->
assertEquals
(
'"'
.
md5
(
'card'
)
.
'"'
,
$this
->
card
->
getETag
());
}
function
testGetETag2
()
{
$card
=
new
Card
(
$this
->
backend
,
array
(
'uri'
=>
'book1'
,
'id'
=>
'foo'
,
'principaluri'
=>
'principals/user1'
,
),
array
(
'uri'
=>
'card1'
,
'addressbookid'
=>
'foo'
,
'carddata'
=>
'card'
,
'etag'
=>
'"blabla"'
,
)
);
$this
->
assertEquals
(
'"blabla"'
,
$card
->
getETag
());
}
function
testGetLastModified
()
{
$this
->
assertEquals
(
null
,
$this
->
card
->
getLastModified
());
}
function
testGetSize
()
{
$this
->
assertEquals
(
4
,
$this
->
card
->
getSize
());
$this
->
assertEquals
(
4
,
$this
->
card
->
getSize
());
}
function
testGetSize2
()
{
$card
=
new
Card
(
$this
->
backend
,
array
(
'uri'
=>
'book1'
,
'id'
=>
'foo'
,
'principaluri'
=>
'principals/user1'
,
),
array
(
'uri'
=>
'card1'
,
'addressbookid'
=>
'foo'
,
'etag'
=>
'"blabla"'
,
'size'
=>
4
,
)
);
$this
->
assertEquals
(
4
,
$card
->
getSize
());
}
function
testACLMethods
()
{
$this
->
assertEquals
(
'principals/user1'
,
$this
->
card
->
getOwner
());
$this
->
assertNull
(
$this
->
card
->
getGroup
());
$this
->
assertEquals
(
array
(
array
(
'privilege'
=>
'{DAV:}read'
,
'principal'
=>
'principals/user1'
,
'protected'
=>
true
,
),
array
(
'privilege'
=>
'{DAV:}write'
,
'principal'
=>
'principals/user1'
,
'protected'
=>
true
,
),
),
$this
->
card
->
getACL
());
}
function
testOverrideACL
()
{
$card
=
new
Card
(
$this
->
backend
,
array
(
'uri'
=>
'book1'
,
'id'
=>
'foo'
,
'principaluri'
=>
'principals/user1'
,
),
array
(
'uri'
=>
'card1'
,
'addressbookid'
=>
'foo'
,
'carddata'
=>
'card'
,
'acl'
=>
array
(
array
(
'privilege'
=>
'{DAV:}read'
,
'principal'
=>
'principals/user1'
,
'protected'
=>
true
,
),
),
)
);
$this
->
assertEquals
(
array
(
array
(
'privilege'
=>
'{DAV:}read'
,
'principal'
=>
'principals/user1'
,
'protected'
=>
true
,
),
),
$card
->
getACL
());
}
/**
* @expectedException Sabre\DAV\Exception\MethodNotAllowed
*/
function
testSetACL
()
{
$this
->
card
->
setACL
(
array
());
}
function
testGetSupportedPrivilegeSet
()
{
$this
->
assertNull
(
$this
->
card
->
getSupportedPrivilegeSet
()
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Dec 23, 1:22 AM (1 d, 17 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914374
Default Alt Text
CardTest.php (4 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment