xmlsitemap_engines_test.module 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. /**
  3. * @file
  4. * Unit tests for the XML sitemap engines project.
  5. */
  6. /**
  7. * Implements hook_menu().
  8. */
  9. function xmlsitemap_engines_test_menu() {
  10. $items['ping'] = array(
  11. 'page callback' => 'xmlsitemap_engines_test_pinged',
  12. // @codingStandardsIgnoreLine
  13. 'access callback' => TRUE,
  14. 'type' => MENU_CALLBACK,
  15. );
  16. return $items;
  17. }
  18. /**
  19. * Implements hook_xmlsitemap_engine_info().
  20. */
  21. function xmlsitemap_engines_test_xmlsitemap_engine_info() {
  22. $engines['simpletest'] = array(
  23. 'name' => t('SimpleTest'),
  24. 'url' => 'http://example.com/',
  25. );
  26. return $engines;
  27. }
  28. /**
  29. * Implements hook_xmlsitemap_engine_info_alter().
  30. */
  31. function xmlsitemap_engines_test_xmlsitemap_engine_info_alter(&$engines) {
  32. $engines['simpletest']['url'] = url('ping', array('absolute' => TRUE, 'query' => array('sitemap' => ''))) . '[sitemap]';
  33. }
  34. /**
  35. * Test pinged.
  36. */
  37. function xmlsitemap_engines_test_pinged() {
  38. if (empty($_GET['sitemap']) || !valid_url($_GET['sitemap'])) {
  39. watchdog('xmlsitemap', 'No valid sitemap parameter provided.', array(), WATCHDOG_WARNING);
  40. // @todo Remove this? Causes an extra watchdog error to be handled.
  41. return MENU_NOT_FOUND;
  42. }
  43. else {
  44. watchdog('xmlsitemap', 'Recieved ping for @sitemap.', array('@sitemap' => $_GET['sitemap']));
  45. }
  46. }