Dokeos PHP Cross Reference Learning Management Systems

Source: /tests/main/inc/lib/database.lib.test.php - 290 lines - 7404 bytes - Summary - Text - Print

   1  <?php
   2  require_once(api_get_path(LIBRARY_PATH).'database.lib.php');
   3  
   4  class TestDatabase extends UnitTestCase {
   5  
   6       public $dbase;
   7  	 public function TestDatabase() {
   8           $this->UnitTestCase('data base test');
   9       }
  10  
  11  	 public function setUp() {
  12            $this->dbase = new Database();
  13       }
  14  
  15  	 public function tearDown() {
  16           $this->dbase = null;
  17       }
  18  
  19  	public function testAffectedRows() {
  20          $res=$this->dbase->affected_rows();
  21          $this->assertTrue(is_numeric($res));
  22      }
  23  
  24  	public function testCountRows() {
  25          $table='class';
  26          $res=$this->dbase->count_rows($table);
  27          $this->assertTrue(is_numeric($res));
  28      }
  29  
  30  	public function testError() {
  31          $res=$this->dbase->error();
  32          $this->assertTrue(is_string($res));
  33      }
  34  
  35  	public function testEscapeString() {
  36          $string='Lore"May';
  37          $res=$this->dbase->escape_string($string);
  38          //print_r($string);
  39          $this->assertTrue(is_string($res));
  40      }
  41  
  42  	public function testFetchArray() {
  43          $sql = 'select 1';
  44          $res=Database::query($sql,__FILE__,__LINE__);
  45          $resu=$this->dbase->fetch_array($res);
  46          $this->assertTrue(is_array($resu));
  47          $this->assertFalse(is_null($resu));
  48      }
  49  
  50  	public function testFetchArrayError() {
  51          $sql ="SELECT  1";
  52          $res=Database::query($sql,__FILE__,__LINE__);
  53          $resu=$this->dbase->fetch_array($res);
  54          $this->assertTrue(is_array($resu));
  55      }
  56  
  57  	function testFetchObject() {
  58          $sql ="SELECT  1";
  59          $res=Database::query($sql,__FILE__,__LINE__);
  60          $resu=$this->dbase->fetch_object($res);
  61          $this->assertTrue(is_object($resu));
  62      }
  63  
  64  	function testFetchRow() {
  65          $sql ="SELECT  1";
  66          $res=Database::query($sql,__FILE__,__LINE__);
  67          $resu=$this->dbase->fetch_row($res);
  68          $this->assertTrue(is_array($resu));
  69      }
  70  
  71  	function testFixDatabaseParameterEmpty() {
  72          $course_info = api_get_course_info();
  73          $database_name= $course_info[""];
  74          $res=$this->dbase->fix_database_parameter($database_name);
  75          if(!is_null($res)) :
  76          $this->assertTrue(is_string($res));
  77          endif;
  78          //var_dump($res);
  79      }
  80  
  81  	function testFixDatabaseParameterReturnString() {
  82          $course_info = api_get_course_info();
  83          $database_name= $course_info["dbName"];
  84          $res=$this->dbase->fix_database_parameter($course_info);
  85          $this->assertTrue(is_string($res));
  86      }
  87  
  88  	function testFormatGluedCourseTableName()  {
  89          $database_name_with_glue='';
  90          $table='';
  91          $res=$this->dbase->format_glued_course_table_name($database_name_with_glue, $table);
  92          $this->assertTrue(is_string($res));
  93      }
  94  
  95  	function testFormatTableName() {
  96          $database='';
  97          $table='';
  98          $res=$this->dbase->format_table_name($database, $table);
  99          $this->assertTrue(is_string($res));
 100      }
 101  
 102  	function testGenerateAbstractCourseFieldNames() {
 103          $result_array='';
 104          $res=$this->dbase->generate_abstract_course_field_names($result_array);
 105          $this->assertTrue(is_array($res));
 106      }
 107  
 108  	function testGenerateAbstractUserFieldNames() {
 109          $result_array='';
 110          $res=$this->dbase->generate_abstract_user_field_names($result_array);
 111          $this->assertTrue(is_array($res));
 112      }
 113  
 114  	function get_course_by_category() {
 115          $category_id='1';
 116          $res=$this->dbase->get_course_by_category($category_id);
 117          $this->assertTrue(is_string($res));
 118      }
 119  
 120  	function testGetCourseChatConnectedTable() {
 121          $database_name='dokeosla';
 122          $res=$this->dbase->get_course_chat_connected_table($database_name);
 123          $this->assertTrue(is_string($res));
 124      }
 125  
 126  	function testGetCourseInfo() {
 127          $course_code='AYDD';
 128          $res=$this->dbase->get_course_info($course_code);
 129          $this->assertTrue(is_array($res));
 130      }
 131  
 132  	function testGetCourseList() {
 133          $sql_query = "SELECT * FROM $table";
 134          $res=$this->dbase->get_course_list($sql_query);
 135          $this->assertTrue(is_array($res));
 136      }
 137  
 138  	function testGetCourseTable() {
 139          $short_table_name='';
 140          $database_name='';
 141          $res=$this->dbase->get_course_table($short_table_name,$database_name);
 142          $this->assertTrue(is_string($res));
 143      }
 144  
 145  	function testGetCourseTableFromCode() {
 146          $course_code='AYDD';
 147          $table='course';
 148          $ret = NULL;
 149          $res=$this->dbase->get_course_table_from_code($course_code, $table);
 150          $this->assertTrue(is_string($res));
 151      }
 152  
 153  	function testGetCourseTablePrefix() {
 154          global $_configuration;
 155          $res=$this->dbase->get_course_table_prefix($_configuration);
 156          $this->assertTrue(is_string($res));
 157      }
 158  
 159  	function testGetCurrentCourseDatabase() {
 160          $res=$this->dbase->get_current_course_database();
 161          if(!is_null($res)) :
 162          $this->assertTrue(is_string($res));
 163          endif;
 164          //var_dump($res);
 165      }
 166  
 167  	function testGetCurrentCourseGluedDatabase() {
 168          $res=$this->dbase->get_current_course_glued_database();
 169          if(!is_null($res)):
 170          $this->assertTrue(is_string($res));
 171          endif;
 172          //var_dump($res);
 173      }
 174  
 175  	function testGetDatabaseGlue()
 176      {
 177          global $_configuration;
 178          $res=$this->dbase->get_database_glue($_configuration);
 179          $this->assertTrue(is_string($res));
 180      }
 181  
 182  	function testGetDatabaseNamePrefix() {
 183          global $_configuration;
 184          $res=$this->dbase->get_database_name_prefix($_configuration);
 185          $this->assertTrue(is_string($res));
 186      }
 187  
 188  	function testGetMainDatabase() {
 189          global $_configuration;
 190          $res=$this->dbase->get_main_database();
 191          $this->assertTrue(is_string($res));
 192      }
 193  
 194  	function testGetMainTable() {
 195          $short_table_name='';
 196          $res=$this->dbase->get_main_table($short_table_name);
 197          $this->assertTrue(is_string($res));
 198      }
 199  
 200  	function testGetScormDatabase() {
 201          global $_configuration;
 202          $res=$this->dbase->get_scorm_database();
 203          $this->assertTrue(is_string($res));
 204      }
 205  
 206  		function testGetScorm_table() {
 207          $short_table_name='';
 208          $res=$this->dbase->get_scorm_table();
 209          $this->assertTrue(is_string($res));
 210          $this->assertTrue($res);
 211      }
 212  
 213  	function testGetStatisticDatabase() {
 214          global $_configuration;
 215          $res=$this->dbase->get_statistic_database($_configuration);
 216          $this->assertTrue(is_string($res));
 217          $this->assertTrue($res);
 218      }
 219  
 220  	function testGetStatisticTable() {
 221          $short_table_name='';
 222          $res=$this->dbase->get_statistic_table($short_table_name);
 223          $this->assertTrue(is_string($res));
 224          $this->assertTrue($res);
 225      }
 226  
 227  	function testGetUserInfoFromId() {
 228          $user_id = '';
 229          $res=$this->dbase->get_user_info_from_id($user_id);
 230          $this->assertTrue(is_array($res));
 231          $this->assertTrue($res);
 232      }
 233  
 234  	function testGetUserPersonalDatabase() {
 235          global $_configuration;
 236          $res=$this->dbase->get_user_personal_database($_configuration);
 237          $this->assertTrue(is_string($res));
 238          $this->assertTrue($res);
 239      }
 240  
 241  	function testGetUserPersonalTable(){
 242          $short_table_name='';
 243          $res=$this->dbase->    get_user_personal_table();
 244          $this->assertTrue(is_string($res));
 245          $this->assertTrue($res);
 246      }
 247  
 248  	function testGlueCourseDatabaseName() {
 249          $database_name='';
 250          $res=$this->dbase->glue_course_database_name($database_name);
 251          $this->assertTrue(is_string($res));
 252          $this->assertTrue($res);
 253      }
 254  
 255  	function testInsertId() {
 256          $res=$this->dbase->insert_id();
 257          $this->assertTrue(is_numeric($res));
 258      }
 259  
 260  	function testNumRows() {
 261          $res='';
 262          $resul=$this->dbase->num_rows($res);
 263          $this->assertTrue(is_string($res));
 264      }
 265  
 266  	function testQuery() {
 267          $sql ="SELECT 1";
 268          $res=$this->dbase->query($sql,__FILE__,__LINE__);
 269          $this->assertTrue(is_resource($res));
 270      }
 271  
 272  	function testResult() {
 273          $sql="SELECT 1";
 274          $resource=$this->dbase->query($sql,__FILE__,__LINE__);
 275          $rows='1';
 276          $res=$this->dbase->result($resource,$rows);
 277          //var_dump($res);
 278          $this->assertTrue(is_bool($res));
 279      }
 280  
 281  	function testStoreResult(){
 282          $sql="SELECT 1";
 283          $resource=$this->dbase->query($sql,__FILE__,__LINE__);
 284          $res = $this->dbase->store_result($resource);
 285          $this->assertTrue(is_array($res));
 286          //var_dump($res);
 287      }
 288  
 289  }
 290  ?>

title

Description

title

Description

title

Description

title

title

Body