Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1820551
BrokerTester.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
3 KB
Subscribers
None
BrokerTester.php
View Options
<?php
namespace
Sabre\VObject\ITip
;
use
Sabre\VObject\Reader
;
/**
* Utilities for testing the broker
*
* @copyright Copyright (C) 2011-2015 fruux GmbH (https://fruux.com/).
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
abstract
class
BrokerTester
extends
\Sabre\VObject\TestCase
{
function
parse
(
$oldMessage
,
$newMessage
,
$expected
=
array
(),
$currentUser
=
'mailto:one@example.org'
)
{
$broker
=
new
Broker
();
$result
=
$broker
->
parseEvent
(
$newMessage
,
$currentUser
,
$oldMessage
);
$this
->
assertEquals
(
count
(
$expected
),
count
(
$result
));
foreach
(
$expected
as
$index
=>
$ex
)
{
$message
=
$result
[
$index
];
foreach
(
$ex
as
$key
=>
$val
)
{
if
(
$key
===
'message'
)
{
$this
->
assertVObjEquals
(
$val
,
$message
->
message
->
serialize
()
);
}
else
{
$this
->
assertEquals
(
$val
,
$message
->
$key
);
}
}
}
}
function
process
(
$input
,
$existingObject
=
null
,
$expected
=
false
)
{
$version
=
\Sabre\VObject\Version
::
VERSION
;
$vcal
=
Reader
::
read
(
$input
);
foreach
(
$vcal
->
getComponents
()
as
$mainComponent
)
{
break
;
}
$message
=
new
Message
();
$message
->
message
=
$vcal
;
$message
->
method
=
isset
(
$vcal
->
METHOD
)?
$vcal
->
METHOD
->
getValue
():
null
;
$message
->
component
=
$mainComponent
->
name
;
$message
->
uid
=
$mainComponent
->
uid
->
getValue
();
$message
->
sequence
=
isset
(
$vcal
->
VEVENT
[
0
])?(
string
)
$vcal
->
VEVENT
[
0
]->
SEQUENCE
:
null
;
if
(
$message
->
method
===
'REPLY'
)
{
$message
->
sender
=
$mainComponent
->
ATTENDEE
->
getValue
();
$message
->
senderName
=
isset
(
$mainComponent
->
ATTENDEE
[
'CN'
])?
$mainComponent
->
ATTENDEE
[
'CN'
]->
getValue
():
null
;
$message
->
recipient
=
$mainComponent
->
ORGANIZER
->
getValue
();
$message
->
recipientName
=
isset
(
$mainComponent
->
ORGANIZER
[
'CN'
])?
$mainComponent
->
ORGANIZER
[
'CN'
]:
null
;
}
$broker
=
new
Broker
();
if
(
is_string
(
$existingObject
))
{
$existingObject
=
str_replace
(
'%foo%'
,
"VERSION:2.0
\n
PRODID:-//Sabre//Sabre VObject $version//EN
\n
CALSCALE:GREGORIAN"
,
$existingObject
);
$existingObject
=
Reader
::
read
(
$existingObject
);
}
$result
=
$broker
->
processMessage
(
$message
,
$existingObject
);
if
(
is_string
(
$expected
))
{
$expected
=
str_replace
(
'%foo%'
,
"VERSION:2.0
\n
PRODID:-//Sabre//Sabre VObject $version//EN
\n
CALSCALE:GREGORIAN"
,
$expected
);
$expected
=
str_replace
(
"
\n
"
,
"
\r\n
"
,
$expected
);
}
if
(
$result
instanceof
\Sabre\VObject\Component\VCalendar
)
{
$result
=
$result
->
serialize
();
$result
=
rtrim
(
$result
,
"
\r\n
"
);
}
$this
->
assertEquals
(
$expected
,
$result
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Dec 22, 5:27 AM (5 d, 5 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
916437
Default Alt Text
BrokerTester.php (3 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment