export.lib.inc.test.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 arrayToCsv method.
  16. * @todo check that a new file is created in api_get_path(SYS_ARCHIVE_PATH)
  17. */
  18. function testArrayToCsv() {
  19. $data = array();
  20. // can only be tested if headers were not sent
  21. ob_start();
  22. $res = Export::arrayToCsv($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::arrayToXls($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::arrayToXml($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. }