function testdbRoomLogsModule() { // Creates some room logs to add to the database $today = date('y-m-d'); $roomLog1 = new RoomLog($today); $roomLog2 = new RoomLog("11-02-07"); // Alter the status and log notes of a room $roomLog2->set_log_notes("Room Log 2"); $roomLog2->set_status("archived"); // test the insert function $this->assertTrue(insert_dbRoomLog($roomLog1)); $this->assertTrue(insert_dbRoomLog($roomLog2)); // test the retrieve function $this->assertEqual(retrieve_dbRoomLog($roomLog1->get_id())->get_status(), "unpublished"); $this->assertEqual(retrieve_dbRoomLog($roomLog2->get_id())->get_status(), "archived"); // test the update function $roomLog1->set_log_notes("Room Log 1 notes"); $this->assertTrue(update_dbRoomLog($roomLog1)); $this->assertEqual(retrieve_dbRoomLog($roomLog1->get_id())->get_log_notes(), "Room Log 1 notes"); // test the delete function $this->assertTrue(delete_dbRoomLog($roomLog1->get_id())); $this->assertFalse(retrieve_dbRoomLog($roomLog1->get_id())); $this->assertTrue(delete_dbRoomLog($roomLog2->get_id())); echo "testdbRoomLogs complete"; }
/** * function to update an entry in the dbRoomLogs database * @param $roomLog the room log to update */ function update_dbRoomLog($roomLog) { // check if the room log is a room log if (!$roomLog instanceof RoomLog) { //print an error echo "Invalid argument for update dbRoomLog function\n"; return false; } // find the roomlog in the database if (delete_dbRoomLog($roomLog->get_id())) { return insert_dbRoomLog($roomLog); // Update every room in the room log as well } else { echo mysql_error() . " unable to update dbRoomLog :" . $roomLog->get_id() . "\n"; return false; } }