steffen: server/kolab-resource-handlers/kolab-resource-handlers/freebusy/test README, NONE, 1.1 main.php, NONE, 1.1 testRecurrence.php, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Wed Feb 9 13:59:36 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-resource-handlers/kolab-resource-handlers/freebusy/test
In directory doto:/tmp/cvs-serv12064/test

Added Files:
	README main.php testRecurrence.php 
Log Message:
we need unit tests for this recurrence stuff...

--- NEW FILE: README ---
Unit tests for freebusy. Run test like this:

/kolab/bin/php main.php


--- NEW FILE: main.php ---
<?php
/*
 * Test driver for freebusy
 */

// Summary variables
$tests_failed    = 0;
$tests_succeeded = 0;
$tests_total     = 0;

include('testRecurrence.php');

print "\nDone with $tests_total tests: $tests_failed failed, $tests_succeeded succeeded\n";
?>
--- NEW FILE: testRecurrence.php ---
<?php
/*
 * Recurrence tests
 */

ini_set( 'include_path', '../../:../:'.ini_get('include_path'));

include('../misc.php');
include('../recurrence.class.php');
include('../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();
};

// 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:
?>




More information about the commits mailing list