You are here

public function LinkSanitizeTest::testBlankTitleWithMultipleQueries in Link 7

Test that multiple query URLs can be turned into absolute URLs.

File

tests/LinkSanitizeTest.test, line 148

Class

LinkSanitizeTest
Test for _link_sanitize().

Code

public function testBlankTitleWithMultipleQueries() {
  $item['title'] = '';
  $item['url'] = 'https://www.drupal.org/?page=42&mango=thebest';
  list($field, $instance, $entity) = $this
    ->generateParams();

  // Disable the URL cutoff to confirm the URL.
  $instance['settings']['display']['url_cutoff'] = FALSE;
  _link_sanitize($item, NULL, $field, $instance, $entity);
  $this
    ->verbose('<pre>' . print_r($item, TRUE) . '</pre>');
  $this
    ->assertEqual('https://www.drupal.org/?page=42&mango=thebest', $item['display_url']);
  $this
    ->assertEqual('https://www.drupal.org/', $item['url']);
  $this
    ->assertTrue(is_array($item['query']));
  $this
    ->assertTrue(isset($item['query']['page']));
  $this
    ->assertEqual($item['query']['page'], 42);
  $this
    ->assertTrue(isset($item['query']['page']));
  $this
    ->assertEqual($item['query']['mango'], 'thebest');

  // Make sure there aren't any other items in the 'query' array.
  unset($item['query']['mango']);
  unset($item['query']['page']);
  $this
    ->assertEqual(array(), $item['query']);
  $this
    ->assertEqual(NULL, $item['fragment']);
}