From 238c2a61e6337c6cca094a06ee90667c2ada5988 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 2 Apr 2009 20:50:37 +0000 Subject: - Patch #417560 by JamesAn: moving the test files to a test directory. --- modules/aggregator/aggregator.test | 2 +- modules/aggregator/aggregator_test.info | 8 --- modules/aggregator/aggregator_test.module | 59 ---------------------- modules/aggregator/aggregator_test_rss091.xml | 30 ----------- modules/aggregator/tests/aggregator_test.info | 8 +++ modules/aggregator/tests/aggregator_test.module | 59 ++++++++++++++++++++++ .../aggregator/tests/aggregator_test_rss091.xml | 30 +++++++++++ 7 files changed, 98 insertions(+), 98 deletions(-) delete mode 100644 modules/aggregator/aggregator_test.info delete mode 100644 modules/aggregator/aggregator_test.module delete mode 100644 modules/aggregator/aggregator_test_rss091.xml create mode 100644 modules/aggregator/tests/aggregator_test.info create mode 100644 modules/aggregator/tests/aggregator_test.module create mode 100644 modules/aggregator/tests/aggregator_test_rss091.xml diff --git a/modules/aggregator/aggregator.test b/modules/aggregator/aggregator.test index 058af286c..7d71760a5 100644 --- a/modules/aggregator/aggregator.test +++ b/modules/aggregator/aggregator.test @@ -239,7 +239,7 @@ EOF; } function getRSS091Sample() { - return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/aggregator_test_rss091.xml'; + return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml'; } function createSampleNodes() { diff --git a/modules/aggregator/aggregator_test.info b/modules/aggregator/aggregator_test.info deleted file mode 100644 index 1cc6ebfe8..000000000 --- a/modules/aggregator/aggregator_test.info +++ /dev/null @@ -1,8 +0,0 @@ -; $Id$ -name = "Aggregator module tests" -description = "Support module for aggregator related testing." -package = Testing -version = VERSION -core = 7.x -files[] = aggregator_test.module -hidden = TRUE diff --git a/modules/aggregator/aggregator_test.module b/modules/aggregator/aggregator_test.module deleted file mode 100644 index 6ea04db07..000000000 --- a/modules/aggregator/aggregator_test.module +++ /dev/null @@ -1,59 +0,0 @@ - 'Test feed static last modified date', - 'description' => "A cached test feed with a static last modified date.", - 'page callback' => 'aggregator_test_feed', - 'access arguments' => array('access content'), - 'type' => MENU_CALLBACK, - ); - return $items; -} - -/** - * Page callback. Generates a test feed and simulates last-modified and etags. - * - * @param $use_last_modified - * Set TRUE to send a last modified header. - * @param $use_etag - * Set TRUE to send an etag. - */ -function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) { - $last_modified = strtotime('Sun, 19 Nov 1978 05:00:00 GMT'); - $etag = md5($last_modified); - - $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE; - $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE; - - // Send appropriate response. We respond with a 304 not modified on either - // etag or on last modified. - if ($use_last_modified) { - drupal_set_header("Last-Modified: " . gmdate(DATE_RFC1123, $last_modified)); - } - if ($use_etag) { - drupal_set_header("ETag: " .$etag); - } - // Return 304 not modified if either last modified or etag match. - if ($last_modified == $if_modified_since || $etag == $if_none_match) { - drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); - return; - } - - // The following headers force validation of cache: - drupal_set_header("Expires: Sun, 19 Nov 1978 05:00:00 GMT"); - drupal_set_header("Cache-Control: must-revalidate"); - drupal_set_header('Content-Type: application/rss+xml; charset=utf-8'); - - // Read actual feed from file. - $file_name = DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/aggregator_test_rss091.xml'; - $handle = fopen($file_name, 'r'); - $feed = fread($handle, filesize($file_name)); - fclose($handle); - - print $feed; -} diff --git a/modules/aggregator/aggregator_test_rss091.xml b/modules/aggregator/aggregator_test_rss091.xml deleted file mode 100644 index 9576f7c16..000000000 --- a/modules/aggregator/aggregator_test_rss091.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - Example - http://example.com - Example updates - en-us - Copyright 2000, Example team. - editor@example.com - webmaster@example.com - - Example - http://example.com/images/druplicon.png - http://example.com - 88 - 100 - Example updates - - - Example turns one - http://example.com/example-turns-one - Example turns one. - - - Example turns two - http://example.com/example-turns-two - Example turns two. - - - \ No newline at end of file diff --git a/modules/aggregator/tests/aggregator_test.info b/modules/aggregator/tests/aggregator_test.info new file mode 100644 index 000000000..1cc6ebfe8 --- /dev/null +++ b/modules/aggregator/tests/aggregator_test.info @@ -0,0 +1,8 @@ +; $Id$ +name = "Aggregator module tests" +description = "Support module for aggregator related testing." +package = Testing +version = VERSION +core = 7.x +files[] = aggregator_test.module +hidden = TRUE diff --git a/modules/aggregator/tests/aggregator_test.module b/modules/aggregator/tests/aggregator_test.module new file mode 100644 index 000000000..4c17d73f6 --- /dev/null +++ b/modules/aggregator/tests/aggregator_test.module @@ -0,0 +1,59 @@ + 'Test feed static last modified date', + 'description' => "A cached test feed with a static last modified date.", + 'page callback' => 'aggregator_test_feed', + 'access arguments' => array('access content'), + 'type' => MENU_CALLBACK, + ); + return $items; +} + +/** + * Page callback. Generates a test feed and simulates last-modified and etags. + * + * @param $use_last_modified + * Set TRUE to send a last modified header. + * @param $use_etag + * Set TRUE to send an etag. + */ +function aggregator_test_feed($use_last_modified = FALSE, $use_etag = FALSE) { + $last_modified = strtotime('Sun, 19 Nov 1978 05:00:00 GMT'); + $etag = md5($last_modified); + + $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) : FALSE; + $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : FALSE; + + // Send appropriate response. We respond with a 304 not modified on either + // etag or on last modified. + if ($use_last_modified) { + drupal_set_header("Last-Modified: " . gmdate(DATE_RFC1123, $last_modified)); + } + if ($use_etag) { + drupal_set_header("ETag: " .$etag); + } + // Return 304 not modified if either last modified or etag match. + if ($last_modified == $if_modified_since || $etag == $if_none_match) { + drupal_set_header($_SERVER['SERVER_PROTOCOL'] . ' 304 Not Modified'); + return; + } + + // The following headers force validation of cache: + drupal_set_header("Expires: Sun, 19 Nov 1978 05:00:00 GMT"); + drupal_set_header("Cache-Control: must-revalidate"); + drupal_set_header('Content-Type: application/rss+xml; charset=utf-8'); + + // Read actual feed from file. + $file_name = DRUPAL_ROOT . '/' . drupal_get_path('module', 'aggregator') . '/tests/aggregator_test_rss091.xml'; + $handle = fopen($file_name, 'r'); + $feed = fread($handle, filesize($file_name)); + fclose($handle); + + print $feed; +} diff --git a/modules/aggregator/tests/aggregator_test_rss091.xml b/modules/aggregator/tests/aggregator_test_rss091.xml new file mode 100644 index 000000000..9576f7c16 --- /dev/null +++ b/modules/aggregator/tests/aggregator_test_rss091.xml @@ -0,0 +1,30 @@ + + + + Example + http://example.com + Example updates + en-us + Copyright 2000, Example team. + editor@example.com + webmaster@example.com + + Example + http://example.com/images/druplicon.png + http://example.com + 88 + 100 + Example updates + + + Example turns one + http://example.com/example-turns-one + Example turns one. + + + Example turns two + http://example.com/example-turns-two + Example turns two. + + + \ No newline at end of file -- cgit v1.2.3