You are here

public function FeedsFileHTTPTestCase::testNoRefetchOnSameRequest in Feeds 7.2

Tests that the source isn't fetched twice during the same request.

File

tests/feeds_fetcher_http.test, line 254
Contains FeedsFileHTTPTestCase.

Class

FeedsFileHTTPTestCase
HTTP fetcher test class.

Code

public function testNoRefetchOnSameRequest() {

  // Include http request functions.
  feeds_include_library('http_request.inc', 'http_request');

  // First request.
  $url = url('testing/feeds/nodes.csv', array(
    'absolute' => TRUE,
  ));
  $result1 = feeds_http_request($url);

  // Set flag that the source has changed.
  variable_set('feeds_tests_nodes_changed', TRUE);

  // Second request.
  $result2 = feeds_http_request($url);

  // Assert that the result is exactly the same.
  $this
    ->assertEqual($result1->data, $result2->data, 'The data was retrieved from cache.');

  // Assert that the data *is* refetched (and different) after a cache clear.
  drupal_flush_all_caches();
  drupal_static_reset();
  $result3 = feeds_http_request($url);
  $this
    ->assertNotEqual($result1->data, $result3->data, 'The data is refetched.');
}