Framework for testing RRULE handling.

This commit is contained in:
Andrew McMillan 2006-12-16 11:41:46 +13:00
parent 1e136a136e
commit 662b27e89a
2 changed files with 39 additions and 0 deletions

View File

@ -31,6 +31,8 @@ switch ( $request->method ) {
case 'LOCK': include_once("caldav-LOCK.php"); break;
case 'UNLOCK': include_once("caldav-LOCK.php"); break;
case 'TESTRRULE': include_once("test-RRULE.php"); break;
default:
dbg_error_log( "caldav", "Unhandled request method >>%s<<", $request->method );
dbg_log_array( "caldav", '_SERVER', $_SERVER, true );

37
inc/test-RRULE.php Normal file
View File

@ -0,0 +1,37 @@
<?php
require_once("../inc/always.php");
require_once("RRule.php");
header("Content-type: text/plain");
echo <<<EOTXT
Testing the RRule Library
EOTXT;
$tests = array(
"20061103T073000" => "RRULE:FREQ=DAILY;COUNT=7"
, "20061102T100000" => "RRULE:FREQ=WEEKLY;COUNT=26;INTERVAL=1;BYDAY=TH"
, "20061103T160000" => "RRULE:FREQ=WEEKLY;INTERVAL=2;UNTIL=20071222T235900"
, "20061103T073000" => "RRULE:FREQ=MONTHLY"
);
foreach( $tests AS $start => $rrule ) {
echo "$start - $rrule\n";
$rule = new RRule( $start, $rrule );
$i = 0;
do {
if ( ($i % 4) == 0 ) echo "\n";
$date = $rule->GetNext();
if ( isset($date) ) {
echo " " . $date->Render();
}
}
while( isset($date) && $i++ < 50 );
echo "\n\n\n";
}
exit(0);
?>