gunnar: server/php-kolab/Kolab_Freebusy/tests .cvsignore, NONE, 1.1 Freebusy_recurrence.phpt, NONE, 1.1
cvs at kolab.org
cvs at kolab.org
Thu Aug 16 07:09:03 CEST 2007
Author: gunnar
Update of /kolabrepository/server/php-kolab/Kolab_Freebusy/tests
In directory doto:/tmp/cvs-serv25133/tests
Added Files:
.cvsignore Freebusy_recurrence.phpt
Log Message:
Add the freebusy tests back in.
--- NEW FILE: .cvsignore ---
*.diff
*.exp
*.log
*.out
*.php
--- NEW FILE: Freebusy_recurrence.phpt ---
--TEST--
Check how freebuy handles recurring events.
Run using
pear run-tests Freebusy_recurrence.phpt
--FILE--
<?php
// We need the basic PEAR library
require_once 'PEAR.php';
// Check for syntax errors
require_once dirname(__FILE__) . '/../Freebusy/misc.php';
require_once dirname(__FILE__) . '/../Freebusy/recurrence.class.php';
require_once dirname(__FILE__) . '/../Freebusy/freebusy.class.php';
class TestRecurrence extends Recurrence {
function setBusy( $start, $end, $duration ) {
$this->periods[] = array($start,$end,$duration);
}
function printperiods() {
foreach( $this->periods as $p ) {
if( $p[1] ) {
print Recurrence::ts2string( $p[0] ).' - '.Recurrence::ts2string( $p[1] )."\n";
} else {
print Recurrence::ts2string( $p[0] ).' - '.Recurrence::ts2string( $p[0]+$p[2] )."\n";
}
}
}
var $periods = array();
};
/*
* Recurrence tests
*/
// Test1: "daynumber in month"
$r =& new TestRecurrence();
$r->setStartDate( FreeBusy::parseDateTime( "2005-03-21T09:00:00Z" ) );
$r->setEndDate( FreeBusy::parseDateTime( "2005-03-21T10:00:00Z" ) );
$r->setCycletype( 'monthly' );
$r->setType( 'daynumber' );
$r->setInterval(1);
$r->setDaynumber(21);
$r->expand( FreeBusy::parseDateTime( "2005-02-01T00:00:00Z" ),
FreeBusy::parseDateTime( "2005-12-01T00:00:00Z" ) );
print "Test1 result:\n";
$r->printperiods();
if( $r->periods != array( /* Results adjusted for CET/CEST switching */
array( FreeBusy::parseDateTime( "2005-03-21T09:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-04-21T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-05-21T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-06-21T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-07-21T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-08-21T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-09-21T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-10-21T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-11-21T09:00:00Z" ),
false, 3600 )
) ) {
print_r($r->periods);
print "Test1 failed\n";
$tests_failed++;
} else {
print "Test1 succeeded\n";
$tests_succeeded++;
}
$tests_total++;
// Test2: "Nth weekday in month"
$r =& new TestRecurrence();
$r->setStartDate( FreeBusy::parseDateTime( "2005-03-21T09:00:00Z" ) );
$r->setEndDate( FreeBusy::parseDateTime( "2005-03-21T10:00:00Z" ) );
$r->setCycletype( 'monthly' );
$r->setType( 'weekday' );
$r->setInterval(1);
$r->setDaynumber(3);
$r->setDay('wednesday');
$r->expand( FreeBusy::parseDateTime( "2005-02-01T00:00:00Z" ),
FreeBusy::parseDateTime( "2005-12-01T00:00:00Z" ) );
print "Test2 result:\n";
$r->printperiods();
if( $r->periods != array( // Results adjusted for CET/CEST switching
array( FreeBusy::parseDateTime( "2005-04-20T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-05-18T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-06-15T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-07-20T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-08-17T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-09-21T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-10-19T08:00:00Z" ),
false, 3600 ),
array( FreeBusy::parseDateTime( "2005-11-16T09:00:00Z" ),
false, 3600 )
) ) {
print_r($r->periods);
print "Test2 failed\n";
$tests_failed++;
} else {
print "Test2 succeeded\n";
$tests_succeeded++;
}
$tests_total++;
// Test3:
?>
--EXPECT--
More information about the commits
mailing list