export.lib.inc.test.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. require_once(api_get_path(LIBRARY_PATH).'export.lib.inc.php');
  3. require_once(api_get_path(LIBRARY_PATH).'document.lib.php');
  4. /** Test about export csv using class document manager
  5. * @author Arthur portugal
  6. * To can test and show the var_dump is necesary comment inside the class
  7. * DocumentManager in the file document.lib.php the word "exit()", because
  8. * "exit" not permit show the result.
  9. */
  10. class TestExport extends UnitTestCase {
  11. public function __construct() {
  12. $this->UnitTestCase('Export library - main/inc/lib/export.lib.inc.test.php');
  13. }
  14. /**
  15. * Checks the export_table_csv method.
  16. * @todo check that a new file is created in api_get_path(SYS_ARCHIVE_PATH)
  17. */
  18. function testExportTableCsv() {
  19. $data = array();
  20. // can only be tested if headers were not sent
  21. ob_start();
  22. $res = Export::export_table_csv($data, $filename = 'export');
  23. $this->assertFalse($res);
  24. ob_end_clean();
  25. }
  26. function testExportTableXls() {
  27. $data = array();
  28. $filename = 'export';
  29. ob_start();
  30. $res=Export::export_table_xls($data,$filename);
  31. $this->assertFalse($res);
  32. ob_end_clean();
  33. }
  34. function testExportTableXml() {
  35. $data = array();
  36. $filename = 'export';
  37. $item_tagname = 'item';
  38. $wrapper_tagname = null;
  39. $encoding=null;
  40. ob_start();
  41. $res=Export::export_table_xml($data,$filename,$item_tagname,
  42. $wrapper_tagname,$encoding);
  43. $this->assertFalse($res);
  44. ob_end_clean();
  45. }
  46. function testExportComplexTableXml() {
  47. $data = array();
  48. $filename = 'export';
  49. $wrapper_tagname=null;
  50. $encoding='ISO-8859-1';
  51. ob_start();
  52. $res=Export::export_complex_table_xml($data,$filename,
  53. $wrapper_tagname,$encoding);
  54. $this->assertFalse($res);
  55. ob_end_clean();
  56. }
  57. function testExportComplexTableXmlHelper() {
  58. $data = array();
  59. $level=1;
  60. ob_start();
  61. $res=Export::_export_complex_table_xml_helper($data,$level);
  62. $this->assertTrue(is_string($res));
  63. ob_end_clean();
  64. }
  65. function testBackupDatabase() {
  66. $link='';
  67. $db_name='';
  68. $structure='';
  69. $donnees='';
  70. $format = 'SQL';
  71. $whereSave = '.';
  72. $insertComplet = '';
  73. $verbose = false;
  74. global $error_msg, $error_no;
  75. $res=backupDatabase($link, $db_name, $structure, $donnees);
  76. $this->assertTrue(is_bool($res));
  77. //var_dump($res);
  78. }
  79. /* DEPRECATED
  80. function testCopydir() {
  81. $origine='';
  82. $destination='';
  83. $verbose = '';
  84. $res =Export::copydir($origine, $destination, $verbose = false);
  85. $this->assertTrue($res);
  86. var_dump($verbose);
  87. }*/
  88. function testmakeTheBackup() {
  89. global $error_msg, $error_no, $db, $archiveRepositorySys,
  90. $archiveRepositoryWeb, $appendCourse, $appendMainDb, $archiveName,
  91. $_configuration, $_course, $TABLEUSER, $TABLECOURSUSER,
  92. $TABLECOURS, $TABLEANNOUNCEMENT;
  93. $exportedCourseId='';
  94. $res=makeTheBackup($exportedCourseId);
  95. $this->assertTrue(is_bool($res));
  96. //var_dump($res);
  97. }
  98. }
  99. ?>