1 views_cache.test ViewsCacheTest::testHttpHeadersCaching()

Check that HTTP headers are cached for views.


core/modules/views/tests/views_cache.test, line 207
Definition of ViewsCacheTest.


Basic test for pluggable caching.


function testHttpHeadersCaching() {
  // Create a few nodes to appear in RSS feed.
  for ($i = 0; $i < 5; $i++) {

  // Make the first request and check returned content type.
  $first_content = $this->backdropGetContent();
  $first_content_type = $this->backdropGetHeader('content-type');
  $expected_type = 'application/rss+xml';
  $this->assertIdentical(0, strpos(trim($first_content_type), $expected_type), t('Expected content type returned.'));

  // Check that we have 7 items in RSS feed returned by the first request.
  $xml = simplexml_load_string($first_content);
  $items = $xml->xpath('/rss/channel/item');
  $this->assertEqual(5, count($items), t('The number of RSS feed items matched.'));

  // Create another node to be sure we get cached results on the second
  // request.

  // Make the second request, check content type and content matching.
  $second_content = $this->backdropGetContent();
  $this->assertEqual($first_content, $second_content, t('The second result fetched from cache.'));
  $second_content_type = $this->backdropGetHeader('content-type');
  $this->assertEqual($first_content_type, $second_content_type, t('Content types of responses are equal.'));