/tests/pptx_processor_test.php

http://www.seekquarry.com/ · PHP · 124 lines · 57 code · 8 blank · 59 comment · 1 complexity · a67cf6d618dfe0e5119cbbaa14c9c9aa MD5 · raw file

  1. <?php
  2. /**
  3. * SeekQuarry/Yioop --
  4. * Open Source Pure PHP Search Engine, Crawler, and Indexer
  5. *
  6. * Copyright (C) 2009 - 2013 Chris Pollett chris@pollett.org
  7. *
  8. * LICENSE:
  9. *
  10. * This program is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation, either version 3 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  22. *
  23. * END LICENSE
  24. *
  25. * @author Nakul Natu nakul.natu@gmail.com
  26. * @package seek_quarry
  27. * @subpackage test
  28. * @license http://www.gnu.org/licenses/ GPL3
  29. * @link http://www.seekquarry.com/
  30. * @copyright 2009 - 2013
  31. * @filesource
  32. */
  33. if(!defined('BASE_DIR')) {echo "BAD REQUEST"; exit();}
  34. /** Load search engine-wide configuration file */
  35. require_once BASE_DIR.'configs/config.php';
  36. /** Load PPTX class we'll test */
  37. require_once BASE_DIR."lib/processors/pptx_processor.php";
  38. /**
  39. * UnitTest for the PptxProcessor class. It is used to process
  40. * pptx files which are xml based zip format
  41. *
  42. * @author Nakul Natu
  43. * @package seek_quarry
  44. * @subpackage test
  45. */
  46. class PptxProcessorTest extends UnitTest implements CrawlConstants
  47. {
  48. /**
  49. * Creates a summary of pptx document to check
  50. */
  51. function setUp()
  52. {
  53. $processor = new PptxProcessor();
  54. $filename = BASE_DIR . "/tests/test_files/test.pptx";
  55. $page = file_get_contents($filename);
  56. $url = "";
  57. $summary = array();
  58. $summary = $processor->process($page, $url);
  59. $this->test_objects['summary'] = $summary;
  60. }
  61. /**
  62. * Test object is set to null
  63. */
  64. function tearDown()
  65. {
  66. $this->test_objects = NULL;
  67. }
  68. /**
  69. * Checks title of the pptx is correct or not
  70. */
  71. function checkTitleTestCase()
  72. {
  73. $objects = $this->test_objects['summary'];
  74. $title="Nakul Natu";
  75. $this->assertEqual($objects[self::TITLE],
  76. $title,"Correct Title Retrieved");
  77. }
  78. /**
  79. * Checks Language of pptx is correct or not
  80. */
  81. function checkLangTestCase()
  82. {
  83. $objects = $this->test_objects['summary'];
  84. $lang="en-US";
  85. $this->assertEqual(
  86. $objects[self::LANG], $lang,"Correct Language Retrieved");
  87. }
  88. /**
  89. * Checks the links are correct or not
  90. */
  91. function checkLinksTestCase()
  92. {
  93. $objects = $this->test_objects['summary'];
  94. $testLinks = array();
  95. $testLinks[0] = "http://www.google.com/";
  96. $testLinks[1] = "http://www.facebook.com/";
  97. $links = array();
  98. $links = $objects[self::LINKS];
  99. $i = 0;
  100. foreach ($links as $link) {
  101. $this->assertEqual(
  102. $link, $testLinks[$i],"Correct Link Retrieved");
  103. $i++;
  104. }
  105. }
  106. /**
  107. * Checks if description is not null
  108. */
  109. function checkDescriptionTestCase()
  110. {
  111. $objects = $this->test_objects['summary'];
  112. $this->assertTrue(
  113. isset($objects[self::DESCRIPTION]),"Description is not null");
  114. }
  115. }
  116. ?>