Revision: 18627
          
http://svn.sv.gnu.org/viewvc/?view=rev&root=phpgroupware&revision=18627
Author:   johang
Date:     2008-06-26 14:17:05 +0000 (Thu, 26 Jun 2008)

Log Message:
-----------
Implement and test calendar.bocalendar.exists

Modified Paths:
--------------
    trunk/calendar/inc/class.bocalendar.inc.php
    trunk/calendar/test/class.bocalendar_test.inc.php

Modified: trunk/calendar/inc/class.bocalendar.inc.php
===================================================================
--- trunk/calendar/inc/class.bocalendar.inc.php 2008-06-26 11:34:51 UTC (rev 
18626)
+++ trunk/calendar/inc/class.bocalendar.inc.php 2008-06-26 14:17:05 UTC (rev 
18627)
@@ -441,7 +441,18 @@
                        return $this->so->list_events($startYear, $startMonth, 
$startDay,
                                $endYear, $endMonth, $endDay, $this->owner);
                }
-
+               
+               /**
+                * Check existance of an event.
+                *
+                * @param $event_id ID of event.
+                * @return bool True if exists, false if not exists.
+                */
+               function exists($event_id)
+               {
+                       return !is_null($this->read_entry($event_id));
+               }
+               
                function set_owner_to_group($owner)
                {
                        
print_debug('calendar::bocalendar::set_owner_to_group:owner',$owner);

Modified: trunk/calendar/test/class.bocalendar_test.inc.php
===================================================================
--- trunk/calendar/test/class.bocalendar_test.inc.php   2008-06-26 11:34:51 UTC 
(rev 18626)
+++ trunk/calendar/test/class.bocalendar_test.inc.php   2008-06-26 14:17:05 UTC 
(rev 18627)
@@ -104,6 +104,10 @@
                        $this->to_be_deleted[] = $id;
                }
 
+               /**
+                * list_events might not be ideal. take a look at
+                * bocalendar.store_to_cache.
+                */
                function test_list()
                {
                        $id_list_before = array();
@@ -165,6 +169,24 @@
 
                function test_exists()
                {
+                       // insert item
+                       $item = $this->sample_item;
+                       unset($item['cal']['id']);
+                       $this->bocalendar->update($item, false);
+                       $id = $GLOBALS['phpgw_info']['cal_new_event_id'];
+                       
+                       // make sure insert was OK
+                       $this->assertTrue($id !== FALSE);
+
+                       // make sure it exists
+                       $this->assertTrue($this->bocalendar->exists($id));
+
+                       // delete it
+                       $this->bocalendar->delete_entry($id);
+                       $this->bocalendar->expunge();
+
+                       // make sure it's gone
+                       $this->assertFalse($this->bocalendar->exists($id));
                }
        }
 ?>




_______________________________________________
phpGroupWare-cvs mailing list
phpGroupWare-cvs@gnu.org
http://lists.gnu.org/mailman/listinfo/phpgroupware-cvs

Reply via email to