1 common.test CommonBackdropAddFeedTestCase::testBasicFeedAddNoTitle()

Test backdrop_add_feed() with paths, URLs, and titles.

File

core/modules/simpletest/tests/common.test, line 3255
Tests for common.inc functionality.

Class

CommonBackdropAddFeedTestCase
Basic tests for backdrop_add_feed().

Code

function testBasicFeedAddNoTitle() {
  $path = $this->randomName(12);
  $external_url = 'http://' . $this->randomName(12) . '/' . $this->randomName(12);
  $fully_qualified_local_url = url($this->randomName(12), array('absolute' => TRUE));

  $path_for_title = $this->randomName(12);
  $external_for_title = 'http://' . $this->randomName(12) . '/' . $this->randomName(12);
  $fully_qualified_for_title = url($this->randomName(12), array('absolute' => TRUE));

  // Possible permutations of backdrop_add_feed() to test.
  // - 'input_url': the path passed to backdrop_add_feed(),
  // - 'output_url': the expected URL to be found in the header.
  // - 'title' == the title of the feed as passed into backdrop_add_feed().
  $urls = array(
    'path without title' => array(
      'input_url' => $path,
      'output_url' => url($path, array('absolute' => TRUE)),
      'title' => '',
    ),
    'external URL without title' => array(
      'input_url' => $external_url,
      'output_url' => $external_url,
      'title' => '',
    ),
    'local URL without title' => array(
      'input_url' => $fully_qualified_local_url,
      'output_url' => $fully_qualified_local_url,
      'title' => '',
    ),
    'path with title' => array(
      'input_url' => $path_for_title,
      'output_url' => url($path_for_title, array('absolute' => TRUE)),
      'title' => $this->randomName(12),
    ),
    'external URL with title' => array(
      'input_url' => $external_for_title,
      'output_url' => $external_for_title,
      'title' => $this->randomName(12),
    ),
    'local URL with title' => array(
      'input_url' => $fully_qualified_for_title,
      'output_url' => $fully_qualified_for_title,
      'title' => $this->randomName(12),
    ),
  );

  foreach ($urls as $description => $feed_info) {
    backdrop_add_feed($feed_info['input_url'], $feed_info['title']);
  }

  $this->backdropSetContent(backdrop_get_html_head());
  foreach ($urls as $description => $feed_info) {
    $this->assertPattern($this->urlToRSSLinkPattern($feed_info['output_url'], $feed_info['title']), format_string('Found correct feed header for %description', array('%description' => $description)));
  }
}