[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] [18623] Unit tests for calendar module.
From: |
Johan Gunnarsson |
Subject: |
[Phpgroupware-cvs] [18623] Unit tests for calendar module. |
Date: |
Thu, 26 Jun 2008 00:22:13 +0000 |
Revision: 18623
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18623
Author: johang
Date: 2008-06-26 00:22:12 +0000 (Thu, 26 Jun 2008)
Log Message:
-----------
Unit tests for calendar module. Not done.
Added Paths:
-----------
trunk/calendar/test/
trunk/calendar/test/all_test.php
trunk/calendar/test/class.bocalendar_test.inc.php
trunk/calendar/test/class.ipc_calendar_test.inc.php
Added: trunk/calendar/test/all_test.php
===================================================================
--- trunk/calendar/test/all_test.php (rev 0)
+++ trunk/calendar/test/all_test.php 2008-06-26 00:22:12 UTC (rev 18623)
@@ -0,0 +1,57 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * Calendar module
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2008 Free Software Foundation, Inc.
+ * @license GNU General Public License
+ * @package calendar
+ * @version $Id$
+ */
+
+ /*
+ you need simpletest in include_path to run this test case. get
it from
+ their site (http://simpletest.sourceforge.net/en/download.html)
or your
+ nearest debian or debian-like repository (php-simpletest).
+ */
+
+ $_SERVER["HTTP_HOST"] = NULL;
+
+ define("TEST_USER", "demo");
+ define("TEST_PASSWORD", "test");
+
+ /*
+ run this file from within the calendar/ directory.
+
+ $ php test/all_tests.php
+ */
+
+ $phpgw_info = array();
+
+ $GLOBALS['phpgw_info']['flags'] = array(
+ 'disable_template_class' => True,
+ 'currentapp' => 'login',
+ 'noheader' => True
+ );
+
+ require_once 'simpletest/reporter.php';
+ require_once("../header.inc.php");
+
+ $GLOBALS['phpgw']->db->query('TRUNCATE phpgw_access_log');
+
+ $GLOBALS['phpgw']->session->create(TEST_USER, md5(TEST_PASSWORD),
'md5');
+
+ $bocalendar = CreateObject('calendar.bocalendar');
+ //$ipccalendar = CreateObject('calendar.ipc_calendar');
+
+ foreach(glob("test/*_test.inc.php") as $n)
+ {
+ require_once($n);
+ }
+
+ $group = new GroupTest('Calendar tests');
+ $group->addTestCase(new bocalendar_test($bocalendar));
+ //$group->addTestCase(new ipc_calendar_test($ipccalendar));
+ $group->run(new TextReporter());
+?>
Added: trunk/calendar/test/class.bocalendar_test.inc.php
===================================================================
--- trunk/calendar/test/class.bocalendar_test.inc.php
(rev 0)
+++ trunk/calendar/test/class.bocalendar_test.inc.php 2008-06-26 00:22:12 UTC
(rev 18623)
@@ -0,0 +1,138 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * Calendar module
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2008 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package calendar
+ * @version $Id$
+ */
+
+ /*
+ you need simpletest in include_path to run this test case. get
it from
+ their site (http://simpletest.sourceforge.net/en/download.html)
or your
+ nearest debian or debian-like repository (php-simpletest).
+ */
+
+ require_once 'simpletest/unit_tester.php';
+
+ /**
+ * Test bocalendar class in calendar module.
+ *
+ * @todo switch over to phpunit.
+ */
+ class bocalendar_test extends UnitTestCase
+ {
+ private $bocalendar;
+
+ private $to_be_deleted;
+
+ private $sample_item = array(
+ 'cal' => array(
+ 'id' => '1000',
+ 'owner' => '8',
+ 'reference' => '0',
+ 'title' => 'TITLE!',
+ 'description' => 'DESCRIPTION!',
+ 'location' => 'LOCATION!',
+ 'priority' => '0',
+ 'recur_type' => '0',
+ 'recur_interval' => ''
+ ),
+ 'recur_exception' => '',
+ 'start' => array(
+ 'str' => '2008/06/25',
+ 'hour' => '00',
+ 'min' => '09'
+ ),
+ 'end' => array(
+ 'str' => '2008/06/25',
+ 'hour' => '00',
+ 'min' => '11'
+ ),
+ 'participants' => array(
+ '8A'
+ ),
+ 'recur_enddate' => array(
+ 'str' => '2008/06/26'
+ )
+ );
+
+ function __construct($bocalendar)
+ {
+ $this->bocalendar = $bocalendar;
+ }
+
+ function setup()
+ {
+ $this->to_be_deleted = array();
+ }
+
+ function teardown()
+ {
+ foreach($this->to_be_deleted as $d)
+ {
+ $this->bocalendar->delete_entry($d);
+ }
+
+ $this->bocalendar->expunge();
+ }
+
+ function test_save_and_get()
+ {
+ $item = $this->sample_item;
+ unset($item['cal']['id']);
+
+ $this->bocalendar->update($item, false);
+
+ $id = $GLOBALS['phpgw_info']['cal_new_event_id'];
+
+ $this->assertFalse($id === FALSE);
+
+ $data = $this->bocalendar->read_entry($id);
+
+ $this->assertTrue($data !== FALSE);
+
+ $this->assertEqual(
+ $this->sample_item['cal']['title'],
$data['title']);
+ $this->assertEqual(
+ $this->sample_item['cal']['description'],
$data['description']);
+
+ $this->to_be_deleted[] = $id;
+ }
+
+ function test_list()
+ {
+ }
+
+ function test_delete()
+ {
+ // remove ID. we want to insert.
+ $item = $this->sample_item;
+ unset($item['cal']['id']);
+
+ $this->bocalendar->update($item, false);
+
+ $id = $GLOBALS['phpgw_info']['cal_new_event_id'];
+
+ $this->assertTrue($id !== FALSE);
+
+ $this->assertNotEqual(
+ $this->bocalendar->read_entry($id), array());
+
+ $this->bocalendar->delete_entry($id);
+ $this->bocalendar->expunge();
+
+ $this->assertEqual(
+ $this->bocalendar->read_entry($id), array());
+
+ $this->to_be_deleted[] = $id;
+ }
+
+ function test_exists()
+ {
+ }
+ }
+?>
Added: trunk/calendar/test/class.ipc_calendar_test.inc.php
===================================================================
--- trunk/calendar/test/class.ipc_calendar_test.inc.php
(rev 0)
+++ trunk/calendar/test/class.ipc_calendar_test.inc.php 2008-06-26 00:22:12 UTC
(rev 18623)
@@ -0,0 +1,79 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * Calendar module
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2008 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package calendar
+ * @version $Id$
+ */
+
+ /*
+ you need simpletest in include_path to run this test case. get
it from
+ their site (http://simpletest.sourceforge.net/en/download.html)
or your
+ nearest debian or debian-like repository (php-simpletest).
+ */
+
+ require_once 'simpletest/unit_tester.php';
+
+ /**
+ * Test ipccalendar class in calendar module.
+ *
+ * @calendar switch over to phpunit.
+ */
+ class ipc_calendar_test extends UnitTestCase
+ {
+ private $ipc;
+
+ private $sample_ical;
+
+ private $sample_item;
+
+ function __construct($ipccalendar)
+ {
+ $this->ipc = $ipccalendar;
+ }
+
+ function setup()
+ {
+ }
+
+ function teardown()
+ {
+ foreach($this->to_be_deleted as $d)
+ {
+ $this->ipc->removeData($d);
+ }
+ }
+
+ function test_addData_and_getData()
+ {
+ }
+
+ function test_getIdList()
+ {
+ }
+
+ function test_removeData()
+ {
+ }
+
+ function test_replaceData()
+ {
+ }
+
+ function test_existData()
+ {
+ }
+
+ function test_convertData_from_ical_1()
+ {
+ }
+
+ function test_convertData_to_ical_1()
+ {
+ }
+ }
+?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] [18623] Unit tests for calendar module.,
Johan Gunnarsson <=