[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] [18616] Importing tests for botodo and ipctodo
From: |
Johan Gunnarsson |
Subject: |
[Phpgroupware-cvs] [18616] Importing tests for botodo and ipctodo |
Date: |
Thu, 19 Jun 2008 23:27:15 +0000 |
Revision: 18616
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18616
Author: johang
Date: 2008-06-19 23:27:14 +0000 (Thu, 19 Jun 2008)
Log Message:
-----------
Importing tests for botodo and ipctodo
Added Paths:
-----------
trunk/todo/test/
trunk/todo/test/all_test.php
trunk/todo/test/class.botodo_test.inc.php
trunk/todo/test/class.ipc_todo_test.inc.php
Added: trunk/todo/test/all_test.php
===================================================================
--- trunk/todo/test/all_test.php (rev 0)
+++ trunk/todo/test/all_test.php 2008-06-19 23:27:14 UTC (rev 18616)
@@ -0,0 +1,55 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * SyncML interface
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2007 Free Software Foundation, Inc.
+ * @license GNU General Public License
+ * @package syncml
+ * @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", "johan");
+ define("TEST_PASSWORD", "pannkaka");
+
+ /*
+ run this file from within the syncml/ 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']->session->create(TEST_USER, md5(TEST_PASSWORD),
'md5');
+
+ $botodo = CreateObject('todo.botodo');
+ $ipctodo = CreateObject('todo.ipc_todo');
+
+ foreach(glob("test/*_test.inc.php") as $n)
+ {
+ require_once($n);
+ }
+
+ $group = new GroupTest('Todo tests');
+ $group->addTestCase(new botodo_test($botodo));
+ $group->addTestCase(new ipc_todo_test($ipctodo));
+ $group->run(new TextReporter());
+?>
Added: trunk/todo/test/class.botodo_test.inc.php
===================================================================
--- trunk/todo/test/class.botodo_test.inc.php (rev 0)
+++ trunk/todo/test/class.botodo_test.inc.php 2008-06-19 23:27:14 UTC (rev
18616)
@@ -0,0 +1,147 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * Todo module
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2008 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package todo
+ * @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 botodo class in todo module.
+ *
+ * @todo switch over to phpunit.
+ */
+ class botodo_test extends UnitTestCase
+ {
+ private $botodo;
+
+ private $to_be_deleted;
+
+ private $sample_item = array(
+ 'title' => 'a test',
+ 'descr' => 'a test ...',
+ 'syear' => '2008',
+ 'smonth' => '6',
+ 'sday' => '12',
+ 'eyear' => '2008',
+ 'emonth' => '6',
+ 'eday' => '19',
+ 'daysfromstart' => '',
+ 'status' => '100',
+ 'pri' => '0',
+ 'access' => 'private',
+ 'cat' => 0,
+ 'parent' => 0,
+ 'main' => 0,
+ 'level' => 0,
+ 'assigned' => '6',
+ 'assigned_group' => '',
+ 'sdate' => '1213221600',
+ 'edate' => '1213833600'
+ );
+
+ function __construct($botodo)
+ {
+ $this->botodo = $botodo;
+ }
+
+ function setup()
+ {
+ $this->to_be_deleted = array();
+ }
+
+ function teardown()
+ {
+ foreach($this->to_be_deleted as $d)
+ {
+ $this->botodo->delete($d);
+ }
+ }
+
+ function test_save_and_get()
+ {
+ $id = $this->botodo->save($this->sample_item);
+
+ $this->assertFalse($id === FALSE);
+
+ $data = $this->botodo->read($id);
+
+ $this->assertTrue($data !== FALSE);
+ $this->assertEqual($this->sample_item["title"],
$data["title"]);
+ $this->assertEqual($this->sample_item["descr"],
$data["descr"]);
+ $this->assertEqual($this->sample_item["edate"],
$data["edate"]);
+ $this->assertEqual($this->sample_item["sdate"],
$data["sdate"]);
+
+ $this->to_be_deleted[] = $id;
+ }
+
+ function test_list()
+ {
+ $id_list_before = array();
+
+ foreach($this->botodo->_list() as $item)
+ {
+ $id_list_before[] = (int)$item["id"];
+ }
+
+ $a = (int)$this->botodo->save($this->sample_item);
+ $b = (int)$this->botodo->save($this->sample_item);
+ $c = (int)$this->botodo->save($this->sample_item);
+
+ $this->assertTrue($a !== FALSE);
+ $this->assertTrue($b !== FALSE);
+ $this->assertTrue($c !== FALSE);
+
+ $id_list_after = array();
+
+ foreach($this->botodo->_list() as $item)
+ {
+ $id_list_after[] = (int)$item["id"];
+ }
+
+ $this->assertEqual($id_list_after,
+ array_merge($id_list_before, array($a, $b,
$c)));
+
+ $this->to_be_deleted[] = $a;
+ $this->to_be_deleted[] = $b;
+ $this->to_be_deleted[] = $c;
+ }
+
+ function test_delete()
+ {
+ $id = $this->botodo->save($this->sample_item);
+
+ $this->assertTrue($id !== FALSE);
+ $this->assertNotEqual($this->botodo->read($id),
array());
+
+ $this->botodo->delete($id);
+
+ $this->assertEqual($this->botodo->read($id), array());
+
+ $this->to_be_deleted[] = $id;
+ }
+
+ function test_exists()
+ {
+ $id = $this->botodo->save($this->sample_item);
+
+ $this->assertTrue($this->botodo->exists($id));
+
+ $this->botodo->delete($id);
+
+ $this->assertFalse($this->botodo->exists($id));
+ }
+ }
+?>
Added: trunk/todo/test/class.ipc_todo_test.inc.php
===================================================================
--- trunk/todo/test/class.ipc_todo_test.inc.php (rev 0)
+++ trunk/todo/test/class.ipc_todo_test.inc.php 2008-06-19 23:27:14 UTC (rev
18616)
@@ -0,0 +1,199 @@
+<?php
+ /**
+ * phpGroupWare (http://phpgroupware.org/)
+ * Todo module
+ *
+ * @author Johan Gunnarsson <address@hidden>
+ * @copyright Copyright (c) 2008 Free Software Foundation, Inc.
+ * @license GNU General Public License 3 or later
+ * @package todo
+ * @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 ipctodo class in todo module.
+ *
+ * @todo switch over to phpunit.
+ */
+ class ipc_todo_test extends UnitTestCase
+ {
+ private $ipc;
+
+ private $sample_ical = "BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//ABC Corporation//NONSGML My Product//EN
+BEGIN:VTODO
+DTSTAMP:19980130T134500Z
+SEQUENCE:2
+UID:address@hidden
+ORGANIZER:MAILTO:address@hidden
+ATTENDEE;PARTSTAT=ACCEPTED:MAILTO:address@hidden
+DUE:19980415T235959
+STATUS:NEEDS-ACTION
+SUMMARY:Submit Income Taxes
+BEGIN:VALARM
+ACTION:AUDIO
+TRIGGER:19980403T120000
+ATTACH;FMTTYPE=audio/basic:http://host.com/pub/audio-
+ files/ssbanner.aud
+REPEAT:4
+DURATION:PT1H
+END:VALARM
+END:VTODO
+END:VCALENDAR";
+
+ private $sample_item = array
+ (
+ 'title' => 'a test',
+ 'descr' => 'a test ...',
+ 'syear' => '2008',
+ 'smonth' => '6',
+ 'sday' => '12',
+ 'eyear' => '2008',
+ 'emonth' => '6',
+ 'eday' => '19',
+ 'daysfromstart' => '',
+ 'status' => '100',
+ 'pri' => '0',
+ 'access' => 'private',
+ 'cat' => 0,
+ 'parent' => 0,
+ 'main' => 0,
+ 'level' => 0,
+ 'assigned' => '6',
+ 'assigned_group' => '',
+ 'sdate' => '1213221600',
+ 'edate' => '1213833600'
+ );
+
+ function __construct($ipctodo)
+ {
+ $this->ipc = $ipctodo;
+ }
+
+ function setup()
+ {
+ }
+
+ function teardown()
+ {
+ foreach($this->to_be_deleted as $d)
+ {
+ $this->ipc->removeData($d);
+ }
+ }
+
+ function test_addData_and_getData()
+ {
+ $id = $this->ipc->addData($this->sample_ical,
'text/x-vcalendar');
+ $this->assertFalse($id === FALSE);
+
+ $data = $this->ipc->getData($id, 'text/x-vcalendar');
+ $this->assertTrue(is_string($data));
+
+ $this->to_be_deleted[] = $id;
+ }
+
+ function test_getIdList()
+ {
+ $id_list_before = $this->ipc->getIdlist();
+
+ $a = $this->ipc->addData($this->sample_item,
+ "application/x-phpgw-todo");
+ $b = $this->ipc->addData($this->sample_item,
+ "application/x-phpgw-todo");
+ $c = $this->ipc->addData($this->sample_item,
+ "application/x-phpgw-todo");
+
+ $id_list_after = $this->ipc->getIdlist();
+
+ $this->assertEqual($id_list_after,
+ array_merge($id_list_before, array($a, $b,
$c)));
+
+ $this->to_be_deleted[] = $a;
+ $this->to_be_deleted[] = $b;
+ $this->to_be_deleted[] = $c;
+ }
+
+ function test_removeData()
+ {
+ $id = $this->ipc->addData($this->sample_item,
+ "application/x-phpgw-todo");
+
+ $this->assertTrue(is_array($this->ipc->getData($id,
+ "application/x-phpgw-todo")));
+
+ $this->ipc->removeData($id);
+
+ $this->assertFalse($this->ipc->getData($id,
+ "application/x-phpgw-todo"));
+
+ $this->to_be_deleted[] = $id;
+ }
+
+ function test_replaceData()
+ {
+ $id = $this->ipc->addData($this->sample_item,
+ "application/x-phpgw-todo");
+
+ $this->assertTrue(is_array($this->ipc->getData($id,
+ "application/x-phpgw-todo")));
+
+ $new_item = $this->sample_item;
+ $new_item["descr"] = "replaced description";
+
+ $this->ipc->replaceData($id,
+ $new_item, "application/x-phpgw-todo");
+
+ $data = $this->ipc->getData($id,
"application/x-phpgw-todo");
+
+ $this->assertEqual($data["descr"], "replaced
description");
+
+ // @todo test more properties
+
+ $this->to_be_deleted[] = $id;
+ }
+
+ function test_existData()
+ {
+ $id = $this->ipc->addData($this->sample_item,
+ "application/x-phpgw-todo");
+
+ $this->assertTrue($this->ipc->existData($id));
+
+ $this->ipc->removeData($id);
+
+ $this->assertFalse($this->ipc->existData($id));
+ }
+
+ function test_convertData_to_ical_1()
+ {
+ $converted_data = $this->ipc->convertData(
+ $this->sample_ical, "text/x-vcalendar",
+ "application/x-phpgw-todo");
+
+ $this->assertEqual($converted_data["title"], "Submit
Income Taxes");
+
+ // @todo test more properties
+ }
+
+ function test_convertData_from_ical_1()
+ {
+ $converted_data = $this->ipc->convertData(
+ $this->sample_item, "application/x-phpgw-todo",
+ "text/x-vcalendar");
+
+ $this->assertEqual($converted_data["summary"], "a test
...");
+
+ // @todo test more properties
+ }
+ }
+?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] [18616] Importing tests for botodo and ipctodo,
Johan Gunnarsson <=