|
|
|
@ -3,6 +3,7 @@ |
|
|
|
|
require_once(api_get_path(LIBRARY_PATH) . "/fckeditor/fckeditor.php"); |
|
|
|
|
require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php'); |
|
|
|
|
require_once(api_get_path(LIBRARY_PATH).'icalcreator/iCalcreator.class.php'); |
|
|
|
|
require_once(api_get_path(LIBRARY_PATH).'course.lib.php'); |
|
|
|
|
Mock::generate('Database'); |
|
|
|
|
Mock::generate('Display'); |
|
|
|
|
class TestCalendar extends UnitTestCase { |
|
|
|
@ -12,6 +13,14 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function setUp(){ |
|
|
|
|
$this->tcourse = new CourseManager(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function tearDown(){ |
|
|
|
|
$this->tcourse = null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testDisplayMinimonthcalendar(){ |
|
|
|
|
ob_start(); |
|
|
|
|
global $DaysShort; |
|
|
|
@ -55,11 +64,14 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
|
|
|
|
|
public function testStoreNewAgendaItem(){ |
|
|
|
|
global $_user; |
|
|
|
|
$res = store_new_agenda_item(); |
|
|
|
|
$this->assertFalse($res); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
$this->assertNull($res); |
|
|
|
|
//var_dump($res); |
|
|
|
|
$res_store = store_new_agenda_item(); |
|
|
|
|
$this->assertTrue(is_numeric($res_store)); |
|
|
|
|
|
|
|
|
|
//delete the new agenda item in the database |
|
|
|
|
if (is_numeric($res_store)) { |
|
|
|
|
$res_delete = delete_agenda_item($res_store); |
|
|
|
|
$this->assertTrue(is_numeric($res_store)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testDisplayCourseadminLinks(){ |
|
|
|
@ -80,24 +92,11 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetAgendaItem(){ |
|
|
|
|
$realgrouplist= new MockDatabase(); |
|
|
|
|
$id=1; |
|
|
|
|
$TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
$sql= "SELECT * FROM ".$TABLEAGENDA." WHERE id='".$id."'"; |
|
|
|
|
$sql_result = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$result= Database::fetch_array($result); |
|
|
|
|
$real_list[] = $result; |
|
|
|
|
$res = get_agenda_item($id); |
|
|
|
|
if(is_array($real_list)) |
|
|
|
|
$this->assertTrue(is_array($real_list)); |
|
|
|
|
else{ |
|
|
|
|
$this->assertTrue(is_null($real_list)); |
|
|
|
|
$this->assertTrue($real_list === true || $real_list === false); |
|
|
|
|
} |
|
|
|
|
$realgrouplist->expectOnce($real_list); |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
//var_dump($real_list); |
|
|
|
|
//var_dump($res); |
|
|
|
|
$id=4; |
|
|
|
|
$res = get_agenda_item($id); |
|
|
|
|
if(is_array($res)) { |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testStoreEditedAgendaItem(){ |
|
|
|
@ -132,111 +131,69 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($TABLEAGENDA); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testDeleteAgendaItem(){ |
|
|
|
|
$realagenda= new MockDatabase(); |
|
|
|
|
$realagenda1 = new MockDisplay(); |
|
|
|
|
global $_course; |
|
|
|
|
$id=Database::escape_string($id); |
|
|
|
|
$res = delete_agenda_item($id); |
|
|
|
|
$sql = "SELECT * FROM $t_agenda WHERE id = $id"; |
|
|
|
|
$sql_result = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$result = Database::fetch_array($sql_result); |
|
|
|
|
$real_agenda[] = $result; |
|
|
|
|
$res= delete_agenda_item($id); |
|
|
|
|
$realagenda->expectOnce($real_agenda); |
|
|
|
|
$this->assertTrue($real_agenda); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
$this->assertTrue(is_array($real_agenda)); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($real_agenda); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Makes an agenda item visible or invisible for a student |
|
|
|
|
* @param integer id the id of the agenda item we are changing the visibility of |
|
|
|
|
*/ |
|
|
|
|
public function testShowhideAgendaItem(){ |
|
|
|
|
ob_start(); |
|
|
|
|
$instans = new MockDisplay(); |
|
|
|
|
$id=1; |
|
|
|
|
global $nameTools; |
|
|
|
|
$res = showhide_agenda_item($id); |
|
|
|
|
//Show the message when the visibility was changed |
|
|
|
|
$real_show = Display::display_normal_message(get_lang("VisibilityChanged")); |
|
|
|
|
$instans_real[] = $real_show; |
|
|
|
|
$instans->expectOnce($instans_real); |
|
|
|
|
ob_end_clean(); |
|
|
|
|
$this->assertTrue(is_object($instans)); |
|
|
|
|
$this->assertTrue(is_array($instans_real)); |
|
|
|
|
//var_dump($instans); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($instans_real); |
|
|
|
|
if(!empty($res)){ |
|
|
|
|
$this->assertTrue($res); |
|
|
|
|
$this->assertTrue($real_show); |
|
|
|
|
} else { |
|
|
|
|
$this->assertNull($res); |
|
|
|
|
} |
|
|
|
|
//var_dump($res); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Para poder ejecutar la funcion display_agenda_items(), es |
|
|
|
|
* necesario comentar el die de la linea 718, porque sino, no se |
|
|
|
|
* podria realizar la prueba. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Displays all the agenda items |
|
|
|
|
*/ |
|
|
|
|
public function testDisplayAgendaItems(){ |
|
|
|
|
ob_start(); |
|
|
|
|
$realdisplay = new MockDatabase(); |
|
|
|
|
$TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
global $select_month, $select_year; |
|
|
|
|
global $DaysShort, $DaysLong, $MonthsLong; |
|
|
|
|
global $is_courseAdmin; |
|
|
|
|
global $dateFormatLong, $timeNoSecFormat,$charset, $_user, $_course; |
|
|
|
|
$sql = "SELECT * FROM ".$TABLEAGENDA.' ORDER BY start_date '.$_SESSION['sort']; |
|
|
|
|
$result=Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$real_display[] = $result; |
|
|
|
|
ob_start(); |
|
|
|
|
$_SESSION['is_courseAdmin'] = 1; |
|
|
|
|
$res = display_agenda_items(); |
|
|
|
|
ob_end_clean(); |
|
|
|
|
$realdisplay->expectOnce($real_display); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
$this->assertTrue(is_array($real_display)); |
|
|
|
|
$realdisplay->expectOnce($real_display); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($real_display); |
|
|
|
|
//var_dump($realdisplay); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Para poder ejecutar esta prueba es necesario comentar el |
|
|
|
|
* die de la linea 984. |
|
|
|
|
*/ |
|
|
|
|
* Displays only 1 agenda item. This is used when an agenda item is added to the learning path. |
|
|
|
|
*/ |
|
|
|
|
public function testDisplayOneAgendaItem(){ |
|
|
|
|
ob_start(); |
|
|
|
|
$realdisplayone = new MockDatabase(); |
|
|
|
|
$TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
global $TABLE_ITEM_PROPERTY; |
|
|
|
|
global $select_month, $select_year; |
|
|
|
|
global $DaysShort, $DaysLong, $MonthsLong; |
|
|
|
|
global $is_courseAdmin; |
|
|
|
|
global $dateFormatLong, $timeNoSecFormat, $charset; |
|
|
|
|
global $_user; |
|
|
|
|
$agenda_id=2; |
|
|
|
|
$agenda_id=Database::escape_string($agenda_id); |
|
|
|
|
$sql = "SELECT * FROM ".$TABLEAGENDA; |
|
|
|
|
$sql_result=Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$myrow=Database::fetch_array($sql_result); |
|
|
|
|
$real_display_one[]= $$myrow; |
|
|
|
|
//$res = display_one_agenda_item($agenda_id); |
|
|
|
|
ob_end_clean(); |
|
|
|
|
$realdisplayone->expectOnce($real_display_one); |
|
|
|
|
$this->assertTrue(is_array($real_display_one)); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($realdisplayone); |
|
|
|
|
//var_dump($real_display_one); |
|
|
|
|
} |
|
|
|
|
ob_start(); |
|
|
|
|
$agenda_id=1; |
|
|
|
|
$res = display_one_agenda_item($agenda_id); |
|
|
|
|
ob_end_clean(); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
|
|
|
|
|
/*public function testShowGroupFilterForm(){ |
|
|
|
|
$group_list=get_course_groups(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Show the form for adding a new agenda item. This is the same function that is used whenever we are editing an |
|
|
|
|
* agenda item. When the id parameter is empty (default behaviour), then we show an empty form, else we are editing and |
|
|
|
|
* we have to retrieve the information that is in the database and use this information in the forms. |
|
|
|
|
*/ |
|
|
|
|
public function testShowGroupFilterForm(){ |
|
|
|
|
ob_start(); |
|
|
|
|
$res = show_group_filter_form(); |
|
|
|
|
$this->assertTrue($res); |
|
|
|
|
//var_dump($res); |
|
|
|
|
ob_end_clean(); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testShowUserFilterForm(){ |
|
|
|
|
|
|
|
|
|
ob_start(); |
|
|
|
|
$res = show_user_filter_form(); |
|
|
|
|
$this->assertTrue($res); |
|
|
|
|
//var_dump($res); |
|
|
|
|
ob_end_clean(); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
public function testShowAddForm(){ |
|
|
|
|
ob_start(); |
|
|
|
|
global $MonthsLong; |
|
|
|
@ -248,52 +205,23 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetAgendaitems(){ |
|
|
|
|
$realgetagenda = new MockDatabase(); |
|
|
|
|
$$TABLEAGENDA = Database :: get_course_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
$month=06; |
|
|
|
|
$year=2010; |
|
|
|
|
global $MonthsLong; |
|
|
|
|
$month=Database::escape_string($month); |
|
|
|
|
$year=Database::escape_string($year); |
|
|
|
|
$sqlquery = "SELECT |
|
|
|
|
DISTINCT * |
|
|
|
|
FROM ".$TABLEAGENDA." |
|
|
|
|
WHERE |
|
|
|
|
MONTH(start_date)='".$month."' |
|
|
|
|
AND YEAR(start_date)='".$year."' |
|
|
|
|
GROUP BY id |
|
|
|
|
ORDER BY start_date "; |
|
|
|
|
$sql_result = Database::query($sqlquery, __FILE__, __LINE__); |
|
|
|
|
$result = Database::fetch_array($sql_result); |
|
|
|
|
$real_get_agenda[] = $result; |
|
|
|
|
$res = get_agendaitems($month, $year); |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
$realgetagenda->expectOnce($real_get_agenda); |
|
|
|
|
$this->assertTrue(is_array($real_get_agenda)); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($real_get_agenda); |
|
|
|
|
//var_dump($realgetagenda); |
|
|
|
|
global $_user; |
|
|
|
|
global $_configuration; |
|
|
|
|
$month='12'; |
|
|
|
|
$year='2009'; |
|
|
|
|
$res = get_agendaitems($month, $year); |
|
|
|
|
if(is_array($res)) { |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testDisplayUpcomingEvents(){ |
|
|
|
|
ob_start(); |
|
|
|
|
$realdisplay = new MockDatabase(); |
|
|
|
|
$TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
$sqlquery = "SELECT |
|
|
|
|
DISTINCT * |
|
|
|
|
FROM ".$TABLEAGENDA." |
|
|
|
|
ORDER BY start_date "; |
|
|
|
|
$result = Database::query($sqlquery, __FILE__, __LINE__); |
|
|
|
|
$resultado = Database::fetch_array($result,'ASSOC'); |
|
|
|
|
$real_display[] = $resultado; |
|
|
|
|
$res = display_upcoming_events(); |
|
|
|
|
$realdisplay->expectOnce($real_display); |
|
|
|
|
ob_end_clean(); |
|
|
|
|
$this->assertTrue(is_array($real_display)); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
//var_dump($real_display); |
|
|
|
|
//var_dump($realdisplay); |
|
|
|
|
//var_dump($res); |
|
|
|
|
$this->assertNull($res); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testCalculateStartEndOfWeek(){ |
|
|
|
@ -319,7 +247,7 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
//var_dump($res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testDisplayWeekcalendar(){ |
|
|
|
|
public function testDisplayWeekcalendar() { |
|
|
|
|
ob_start(); |
|
|
|
|
$agendaitems=''; |
|
|
|
|
$month=10; |
|
|
|
@ -332,197 +260,85 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
//var_dump($res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetDayAgendaitems(){ |
|
|
|
|
$realgetday = new MockDatabase(); |
|
|
|
|
$TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
global $_user; |
|
|
|
|
global $_configuration; |
|
|
|
|
global $setting_agenda_link; |
|
|
|
|
$courses_dbs=''; |
|
|
|
|
$month=11; |
|
|
|
|
$year=2009; |
|
|
|
|
$day=''; |
|
|
|
|
$sqlquery = "SELECT DISTINCT * |
|
|
|
|
FROM ".$TABLEAGENDA." |
|
|
|
|
WHERE |
|
|
|
|
DAYOFMONTH(start_date)='".$day."' AND MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."' |
|
|
|
|
GROUP BY agenda.id |
|
|
|
|
ORDER BY start_date "; |
|
|
|
|
$result = Database::query($sqlquery, __FILE__, __LINE__); |
|
|
|
|
$item = Database::fetch_array($result); |
|
|
|
|
$real_get_day[] = $item; |
|
|
|
|
public function testGetDayAgendaitems() { |
|
|
|
|
$courses_dbs=array(); |
|
|
|
|
$month='12'; |
|
|
|
|
$year='2009'; |
|
|
|
|
$day='1'; |
|
|
|
|
$res = get_day_agendaitems($courses_dbs, $month, $year, $day); |
|
|
|
|
$realgetday->expectOnce($real_get_day); |
|
|
|
|
$this->assertTrue(is_array($real_get_day)); |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($real_get_day); |
|
|
|
|
//var_dump($$realgetday); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetWeekAgendaitems(){ |
|
|
|
|
$realgetweek = new MockDatabase(); |
|
|
|
|
$TABLEAGENDA = Database :: get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
global $_user; |
|
|
|
|
global $_configuration; |
|
|
|
|
global $setting_agenda_link;$month=''; |
|
|
|
|
$courses_dbs=''; |
|
|
|
|
$year=''; |
|
|
|
|
$week = ''; |
|
|
|
|
$sqlquery = "SELECT DISTINCT * FROM ".$TABLEAGENDA." ORDER BY start_date"; |
|
|
|
|
$result = Database::query($sqlquery, __FILE__, __LINE__); |
|
|
|
|
$item = Database::fetch_array($result); |
|
|
|
|
$real_get_week[]= $item; |
|
|
|
|
$res = get_week_agendaitems($courses_dbs, $month, $year, $week); |
|
|
|
|
$realgetweek->expectOnce($real_get_week); |
|
|
|
|
$this->assertTrue(is_array($real_get_week)); |
|
|
|
|
$this->assertTrue($realgetweek); |
|
|
|
|
public function testGetWeekAgendaitems() { |
|
|
|
|
$courses_dbs=array(); |
|
|
|
|
$year='2009'; |
|
|
|
|
$month='12'; |
|
|
|
|
$res = get_week_agendaitems($courses_dbs, $month, $year); |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($real_get_week); |
|
|
|
|
//var_dump($realgetweek); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetRepeatedEventsDayView(){ |
|
|
|
|
$realgetrepeat = new MockDatabase(); |
|
|
|
|
$course_info=''; |
|
|
|
|
$start=0; |
|
|
|
|
$end=0; |
|
|
|
|
$params=''; |
|
|
|
|
$t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']); |
|
|
|
|
$t_ip = Database::get_course_table(TABLE_ITEM_PROPERTY,$course_info['dbName']); |
|
|
|
|
$sql = "SELECT c.id, c.title, c.content, " . |
|
|
|
|
" UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " . |
|
|
|
|
" cr.cal_type, cr.cal_end " . |
|
|
|
|
" FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " . |
|
|
|
|
" WHERE cr.cal_end >= $start " . |
|
|
|
|
" AND cr.cal_id = c.id " . |
|
|
|
|
" AND item_property.ref = c.id ". |
|
|
|
|
" AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ". |
|
|
|
|
" AND c.start_date <= '$db_start' " |
|
|
|
|
.(!empty($params['conditions'])?$params['conditions']:'') |
|
|
|
|
.(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'') |
|
|
|
|
.(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:''); |
|
|
|
|
$res = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$row = Database::fetch_array($res); |
|
|
|
|
$real_get_repeat[] = $row; |
|
|
|
|
$resul = get_repeated_events_day_view($course_info,$start,$end,$params); |
|
|
|
|
$realgetrepeat->expectOnce($real_get_repeat); |
|
|
|
|
$this->assertTrue(is_array($real_get_repeat)); |
|
|
|
|
$this->assertTrue(is_array($resul)); |
|
|
|
|
//var_dump($resul); |
|
|
|
|
//var_dump($realgetrepeat); |
|
|
|
|
//var_dump($real_get_repeat); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testget_repeated_events_week_view(){ |
|
|
|
|
$realgetrepeated = new MockDatabase(); |
|
|
|
|
$course_info=''; |
|
|
|
|
$start=0; |
|
|
|
|
$end=0; |
|
|
|
|
$params=''; |
|
|
|
|
$t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
$sql = "SELECT c.id, c.title, c.content " . |
|
|
|
|
" UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " . |
|
|
|
|
" FROM". $t_cal ." |
|
|
|
|
WHERE c.start_date <= '$db_start' " |
|
|
|
|
.(!empty($params['conditions'])?$params['conditions']:'') |
|
|
|
|
.(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'') |
|
|
|
|
.(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:''); |
|
|
|
|
$res = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$row = Database::fetch_array($res); |
|
|
|
|
$real_get_repeated[] = $row; |
|
|
|
|
$resul = get_repeated_events_week_view($course_info,$start,$end,$params); |
|
|
|
|
$realgetrepeated->expectOnce($real_get_repeated); |
|
|
|
|
|
|
|
|
|
global $_configuration; |
|
|
|
|
|
|
|
|
|
require_once api_get_path(SYS_PATH).'tests/main/inc/lib/add_course.lib.inc.test.php'; |
|
|
|
|
|
|
|
|
|
// create a course |
|
|
|
|
|
|
|
|
|
$course_datos = array( |
|
|
|
|
'wanted_code'=> 'COD21', |
|
|
|
|
'title'=>'metodologia de calculo diferencial', |
|
|
|
|
'tutor_name'=>'R. J. Wolfagan', |
|
|
|
|
'category_code'=>'2121', |
|
|
|
|
'course_language'=>'english', |
|
|
|
|
'course_admin_id'=>'1211', |
|
|
|
|
'db_prefix'=> $_configuration['db_prefix'].'COD21', |
|
|
|
|
'db_prefix'=> $_configuration['db_prefix'].'COD21', |
|
|
|
|
'firstExpirationDelay'=>'112' |
|
|
|
|
); |
|
|
|
|
$res = create_course($course_datos['wanted_code'], $course_datos['title'], |
|
|
|
|
$course_datos['tutor_name'], $course_datos['category_code'], |
|
|
|
|
$course_datos['course_language'],$course_datos['course_admin_id'], |
|
|
|
|
$course_datos['db_prefix'], $course_datos['firstExpirationDelay']); |
|
|
|
|
if ($res) { |
|
|
|
|
$start = 0; |
|
|
|
|
$end = 0; |
|
|
|
|
$params=''; |
|
|
|
|
$course_code = 'COD21'; |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$resul = get_repeated_events_day_view($course_info,$start,$end,$params); |
|
|
|
|
$this->assertTrue(is_array($resul)); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetRepeatedEventsWeekView(){ |
|
|
|
|
$course_info = 'COD21'; |
|
|
|
|
$resul = get_repeated_events_week_view($course_info, 0, 0, ''); |
|
|
|
|
$this->assertTrue(is_array($resul)); |
|
|
|
|
$this->assertTrue($real_get_repeated); |
|
|
|
|
//var_dump($resul); |
|
|
|
|
//var_dump($real_get_repeated); |
|
|
|
|
//var_dump($realgetrepeated); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetRepeatedEventsMonthView(){ |
|
|
|
|
$realgetrepeated= new MockDatabase(); |
|
|
|
|
$course_info=''; |
|
|
|
|
$start=''; |
|
|
|
|
$end=''; |
|
|
|
|
$params=''; |
|
|
|
|
$t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
$sql = "SELECT c.id, c.title, c.content, " . |
|
|
|
|
" UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " . |
|
|
|
|
" cr.cal_type, cr.cal_end " . |
|
|
|
|
" FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " . |
|
|
|
|
" WHERE cr.cal_end >= $start " . |
|
|
|
|
" AND cr.cal_id = c.id " . |
|
|
|
|
" AND item_property.ref = c.id ". |
|
|
|
|
" AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ". |
|
|
|
|
" AND c.start_date <= '$db_start' " |
|
|
|
|
.(!empty($params['conditions'])?$params['conditions']:'') |
|
|
|
|
.(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'') |
|
|
|
|
.(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:''); |
|
|
|
|
$res = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$row = Database::fetch_array($res); |
|
|
|
|
$real_get_repeated[] = $row; |
|
|
|
|
$resul= get_repeated_events_month_view($course_info,$start,$end,$params); |
|
|
|
|
$realgetrepeated->expectOnce($real_get_repeated); |
|
|
|
|
$course_code='COD21'; |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$resul= get_repeated_events_month_view($course_info,0,0,''); |
|
|
|
|
$this->assertTrue(is_array($resul)); |
|
|
|
|
$this->assertTrue(is_bool($res)); |
|
|
|
|
$this->assertTrue($res === false || $res === true); |
|
|
|
|
$this->assertTrue($real_get_repeated); |
|
|
|
|
//var_dump($resul); |
|
|
|
|
//var_dump($real_get_repeated); |
|
|
|
|
//var_dump($realgetrepeated); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testGetRepeatedEventsListView(){ |
|
|
|
|
$realgetrepeatedevents = new MockDatabase(); |
|
|
|
|
$course_info=''; |
|
|
|
|
$start=0; |
|
|
|
|
$end=0; |
|
|
|
|
$params=''; |
|
|
|
|
$t_cal = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']); |
|
|
|
|
$sql = "SELECT c.id, c.title, c.content, " . |
|
|
|
|
" UNIX_TIMESTAMP(c.start_date) as orig_start, UNIX_TIMESTAMP(c.end_date) as orig_end, " . |
|
|
|
|
" cr.cal_type, cr.cal_end " . |
|
|
|
|
" FROM $t_cal c, $t_cal_repeat cr, $t_ip as item_property " . |
|
|
|
|
" WHERE cr.cal_end >= $start " . |
|
|
|
|
" AND cr.cal_id = c.id " . |
|
|
|
|
" AND item_property.ref = c.id ". |
|
|
|
|
" AND item_property.tool = '".TOOL_CALENDAR_EVENT."' ". |
|
|
|
|
" AND c.start_date <= '$db_start' " |
|
|
|
|
.(!empty($params['conditions'])?$params['conditions']:'') |
|
|
|
|
.(!empty($params['groupby'])?' GROUP BY '.$params['groupby']:'') |
|
|
|
|
.(!empty($params['orderby'])?' ORDER BY '.$params['orderby']:''); |
|
|
|
|
$res = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$row = Database::fetch_array($res); |
|
|
|
|
$real_get_repeated_events[] = $row; |
|
|
|
|
$resul = get_repeated_events_list_view($course_info,$start,$end,$params); |
|
|
|
|
$realgetrepeatedevents->expectOnce($real_get_repeated_events); |
|
|
|
|
$this->assertTrue(is_array($real_get_repeated_events)); |
|
|
|
|
$course_code='COD21'; |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$resul = get_repeated_events_list_view($course_info,0,0,''); |
|
|
|
|
$this->assertTrue(is_array($resul)); |
|
|
|
|
$realgetrepeatedevents->expectCallCount($real_get_repeated_events); |
|
|
|
|
//var_dump($resul); |
|
|
|
|
//var_dump($real_get_repeated_events); |
|
|
|
|
//var_dump($realgetrepeatedevents); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testIsRepeatedEvent() { |
|
|
|
|
$realrepetead = new MockDatabase(); |
|
|
|
|
$id=1; |
|
|
|
|
$course=null; |
|
|
|
|
$sql = "SELECT * FROM $t_agenda_repeat WHERE cal_id = $id"; |
|
|
|
|
$res = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$result = Database::num_rows($res)>0; |
|
|
|
|
$real_repetead[] = $result; |
|
|
|
|
$resu = is_repeated_event($id,$course); |
|
|
|
|
$realrepetead->expectOnce($real_repetead); |
|
|
|
|
$this->assertTrue(is_bool($resu)); |
|
|
|
|
$this->assertTrue($resu === true || $resu === false); |
|
|
|
|
$this->assertTrue($real_repetead); |
|
|
|
|
$this->assertTrue($realrepetead); |
|
|
|
|
//var_dump($resu); |
|
|
|
|
//var_dump($real_repetead); |
|
|
|
|
//var_dump($realrepetead); |
|
|
|
|
//This is deprecated or not used |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testAddWeek(){ |
|
|
|
@ -548,103 +364,51 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
$this->assertTrue(is_numeric($res)); |
|
|
|
|
//var_dump($res); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* para poder realizar esta prueba, se tuvo que comentar el "die" ubicado en la |
|
|
|
|
* linea 2877 para que la prueba pudiera ejecutarse de manera exitosa. |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Adds an agenda item in the database. Similar to store_new_agenda_item() except it takes parameters |
|
|
|
|
* @param array Course info |
|
|
|
|
* @param string Event title |
|
|
|
|
* @param string Event content/description |
|
|
|
|
* @param string Start date |
|
|
|
|
* @param string End date |
|
|
|
|
* @param array List of groups to which this event is added |
|
|
|
|
* @param int Parent id (optional) |
|
|
|
|
* @return int The new item's DB ID |
|
|
|
|
*/ |
|
|
|
|
public function testAgendaAddItem(){ |
|
|
|
|
|
|
|
|
|
$realagenda = new MockDatabase(); |
|
|
|
|
global $_course; |
|
|
|
|
$course_info='null'; |
|
|
|
|
$course_code='COD21'; |
|
|
|
|
$course_info = api_get_course_info($course_code); |
|
|
|
|
$title='test'; |
|
|
|
|
$content='test function'; |
|
|
|
|
$db_start_date='07/11/2009'; |
|
|
|
|
$db_end_date='07/20/2009'; |
|
|
|
|
$to=array(); |
|
|
|
|
$parent_id=null; |
|
|
|
|
$t_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
$title = Database::escape_string($title); |
|
|
|
|
$content = Database::escape_string($content); |
|
|
|
|
$start_date = Database::escape_string($db_start_date); |
|
|
|
|
$end_date = Database::escape_string($db_end_date); |
|
|
|
|
$sql = "SELECT * FROM $t_agenda WHERE title='$title' AND content = '$content' AND start_date = '$start_date' |
|
|
|
|
AND end_date = '$end_date' ".(!empty($parent_id)? "AND parent_event_id = '$parent_id'":""); |
|
|
|
|
$result = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$sql1 = "INSERT INTO ".$t_agenda."(title,content, start_date, end_date)VALUES |
|
|
|
|
('".$title."','".$content."', '".$start_date."','".$end_date."')"; |
|
|
|
|
$result1 = Database::query($sql1,__FILE__,__LINE__); |
|
|
|
|
$real_agenda[]= $result; |
|
|
|
|
$real_agenda1[]= $result1; |
|
|
|
|
//$res = agenda_add_item($course_info, $title, $content, $db_start_date, $db_end_date, $to, $parent_id); |
|
|
|
|
$realagenda->expectOnce($real_agenda); |
|
|
|
|
$realagenda->expectOnce($real_agenda1); |
|
|
|
|
//$this->assertTrue(is_numeric($res)); |
|
|
|
|
$this->assertTrue(is_array($real_agenda)); |
|
|
|
|
$this->assertTrue(is_array($real_agenda1)); |
|
|
|
|
$res = agenda_add_item($course_info, $title, $content, $db_start_date, $db_end_date, $to=array(), $parent_id=null); |
|
|
|
|
$this->assertTrue(is_numeric($res)); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($real_agenda); |
|
|
|
|
//var_dump($real_agenda1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Adds a repetitive item to the database |
|
|
|
|
* @param array Course info |
|
|
|
|
* @param int The original event's id |
|
|
|
|
* @param string Type of repetition |
|
|
|
|
* @param int Timestamp of end of repetition (repeating until that date) |
|
|
|
|
* @param array Original event's destination |
|
|
|
|
* @return boolean False if error, True otherwise |
|
|
|
|
*/ |
|
|
|
|
public function testGetCalendarItems(){ |
|
|
|
|
$realgetcalendar = new MockDatabase(); |
|
|
|
|
global $_user, $_course; |
|
|
|
|
global $is_allowed_to_edit; |
|
|
|
|
$month='march'; |
|
|
|
|
global $_course; |
|
|
|
|
$month='12'; |
|
|
|
|
$year='2009'; |
|
|
|
|
$TABLEAGENDA = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR); |
|
|
|
|
$sql="SELECT |
|
|
|
|
DISTINCT * |
|
|
|
|
FROM ".$TABLEAGENDA." agenda |
|
|
|
|
WHERE MONTH(start_date)='".$month."' AND YEAR(start_date)='".$year."' |
|
|
|
|
GROUP BY id ". |
|
|
|
|
"ORDER BY start_date "; |
|
|
|
|
$result=Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$row=Database::fetch_array($result); |
|
|
|
|
$res = get_calendar_items($month, $year); |
|
|
|
|
$real_get_calendar[]= $row; |
|
|
|
|
$realgetcalendar->expectOnce($real_get_calendar); |
|
|
|
|
$realgetcalendar->expectCallCount($real_get_calendar); |
|
|
|
|
$this->assertTrue(is_bool($row)); |
|
|
|
|
$this->assertTrue(is_array($real_get_calendar)); |
|
|
|
|
$res = get_calendar_items($month, $year); |
|
|
|
|
$this->assertTrue(is_array($res)); |
|
|
|
|
//var_dump($real_get_calendar); |
|
|
|
|
//var_dump($row); |
|
|
|
|
//var_dump($res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testAgendaAddRepeatItem(){ |
|
|
|
|
$realagenda = new MockDatabase(); |
|
|
|
|
$course_info='course of test'; |
|
|
|
|
$orig_id=001; |
|
|
|
|
$type='daily'; |
|
|
|
|
$end=10; |
|
|
|
|
$orig_dest='monday'; |
|
|
|
|
$t_agenda = Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR,$course_info['dbName']); |
|
|
|
|
$sql = "SELECT title, content, start_date as sd, end_date as ed FROM $t_agenda WHERE id = $orig_id"; |
|
|
|
|
$res = Database::query($sql,__FILE__,__LINE__); |
|
|
|
|
$row = Database::fetch_array($res); |
|
|
|
|
$sql1 = "INSERT INTO $t_agenda_r (cal_id, cal_type, cal_end)" . |
|
|
|
|
" VALUES ($orig_id,'$type',$end)"; |
|
|
|
|
$res1 = Database::query($sql1,__FILE__,__LINE__); |
|
|
|
|
$resu= agenda_add_repeat_item($course_info,$orig_id,$type,$end,$orig_dest); |
|
|
|
|
$real_agenda[] = $row; |
|
|
|
|
$realagenda->expectOnce($real_agenda); |
|
|
|
|
$realagenda->expectCallCount($real_agenda); |
|
|
|
|
$realagenda->expectOnce($t_agenda); |
|
|
|
|
$realagenda->expectOnce($res1); |
|
|
|
|
if(is_bool($resu)){ |
|
|
|
|
$this->assertTrue(is_bool($resu)); |
|
|
|
|
$this->assertTrue($resu === true || $resu===false); |
|
|
|
|
}else |
|
|
|
|
$this->assertTrue(is_null($resu)); |
|
|
|
|
$this->assertTrue(is_array($real_agenda)); |
|
|
|
|
$this->assertTrue($row); |
|
|
|
|
//var_dump($resu); |
|
|
|
|
//var_dump($res); |
|
|
|
|
//var_dump($res1); |
|
|
|
|
//var_dump($real_agenda); |
|
|
|
|
//this function is not used or deprecated |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public function testAgendaImportIcal(){ |
|
|
|
@ -660,32 +424,16 @@ class TestCalendar extends UnitTestCase { |
|
|
|
|
}else{ |
|
|
|
|
$this->assertTrue($res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function testDeleteAgendaItem(){ |
|
|
|
|
global $_course; |
|
|
|
|
$course_code='COD21'; |
|
|
|
|
$id=1; |
|
|
|
|
$res = delete_agenda_item($id); |
|
|
|
|
$res = $this->tcourse->delete_course($course_code); |
|
|
|
|
$this->assertTrue(is_null($res)); |
|
|
|
|
//var_dump($res); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
?> |
|
|
|
|