session_handler.class.test.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'session_handler.class.php');
  3. class TestSessionHandler extends UnitTestCase {
  4. var $connection;
  5. var $connection_handler;
  6. var $lifetime;
  7. var $session_name;
  8. public function TestSessionHandler(){
  9. $this->UnitTestCase('Session handler library - main/inc/lib/session_handler.class.test.php');
  10. }
  11. function testClose() {
  12. $instancia = new SessionHandler();
  13. $res=$instancia->close();
  14. $this->assertTrue(is_bool($res));
  15. //var_dump($res);
  16. }
  17. function testdestroy() {
  18. $instancia = new SessionHandler();
  19. $sess_id='';
  20. $res=$instancia->destroy($sess_id);
  21. $this->assertTrue(is_bool($res));
  22. //var_dump($res);
  23. }
  24. function testgarbage() {
  25. $instancia = new SessionHandler();
  26. $lifetime='';
  27. $res=$instancia->garbage($lifetime);
  28. $this->assertTrue(is_bool($res));
  29. //var_dump($res);
  30. }
  31. function testopen() {
  32. $instancia = new SessionHandler();
  33. $path='';
  34. $name='';
  35. $res=$instancia->open($path,$name);
  36. $this->assertTrue(is_bool($res));
  37. //var_dump($res);
  38. }
  39. function testread() {
  40. $instancia = new SessionHandler();
  41. $sess_id='';
  42. $res=$instancia->read($sess_id);
  43. $this->assertTrue(is_string($res));
  44. //var_dump($res);
  45. }
  46. /*
  47. //No se puede probar por tener el mismo nombre de la clase
  48. function testsessionhandler() {
  49. $instancia = new session_handler();
  50. global $_configuration;
  51. $res=$instancia->session_handler();
  52. $this->assertTrue(is_string($res));
  53. var_dump($res);
  54. }
  55. */
  56. function testsqlClose() {
  57. $instancia = new SessionHandler();
  58. $res=$instancia->sqlClose();
  59. $this->assertTrue(is_bool($res));
  60. //var_dump($res);
  61. }
  62. function testsqlConnect() {
  63. $instancia = new SessionHandler();
  64. $res=$instancia->sqlConnect();
  65. $this->assertTrue(is_bool($res));
  66. //var_dump($res);
  67. }
  68. function testsqlQuery() {
  69. global $_configuration;
  70. $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
  71. $query = 'select user_id from '.$tbl_user;
  72. $instancia = new SessionHandler();
  73. $instancia->connection_handler = mysql_connect($_configuration['db_host'],
  74. $_configuration['db_user'],
  75. $_configuration['db_password']);
  76. $res= $instancia->sqlQuery($query, false);
  77. $this->assertTrue(is_resource($res));
  78. $this->assertTrue($res);
  79. }
  80. function testwrite() {
  81. $instancia = new SessionHandler();
  82. $sess_id='';
  83. $sess_value='';
  84. $res=$instancia->write($sess_id,$sess_value);
  85. $this->assertTrue(is_bool($res));
  86. //var_dump($res);
  87. }
  88. }
  89. ?>