chat_functions.lib.test.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'course.lib.php');
  3. class TestChatFunctions extends UnitTestCase {
  4. public function __construct(){
  5. $this->UnitTestCase('Chat library - main/chat/chat_functions.lib.test.php');
  6. }
  7. public function setUp() {
  8. $this->tcourse = new CourseManager();
  9. }
  10. public function tearDown() {
  11. $this->tcourse = null;
  12. }
  13. function CreateChatConnection($database_name) {
  14. $session_id = 1;
  15. $tbl_chat_connected = Database::get_main_table(TABLE_MAIN_CHAT);
  16. $sql = "SELECT user_id FROM $tbl_chat_connected WHERE user_id = 1";
  17. $result = Database::query($sql);
  18. //The user_id exists so we must do an UPDATE and not a INSERT
  19. $current_time = date('Y-m-d H:i:s');
  20. if (Database::num_rows($result)==0) {
  21. $query="INSERT INTO $tbl_chat_connected(user_id,last_connection,session_id)
  22. VALUES(1,'$current_time','$session_id')";
  23. } else {
  24. $query="UPDATE $tbl_chat_connected set last_connection='".$current_time."'
  25. WHERE user_id=1 AND session_id='$session_id'";
  26. }
  27. Database::query($query);
  28. }
  29. }
  30. ?>