Skip to content
Snippets Groups Projects
Commit dc611248 authored by jmorahan's avatar jmorahan Committed by Chris Leppanen
Browse files

Issue #1951736 by twistor, John Morahan: Discovery sometimes fails.

parent a7136bca
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,7 @@ files[] = tests/feeds_processor_user.test
files[] = tests/feeds_scheduler.test
files[] = tests/feeds_mapper_link.test
files[] = tests/feeds_mapper_taxonomy.test
files[] = tests/http_request.test
files[] = tests/parser_csv.test
; Views integration
......
......@@ -351,7 +351,11 @@ function http_request_find_feeds($html) {
preg_match_all(HTTP_REQUEST_PCRE_TAG_ATTRIBUTES, $link_tag, $attributes, PREG_SET_ORDER);
foreach ($attributes as $attribute) {
// Find the key value pairs, attribute[1] is key and attribute[2] is the
// value.
// value. However, if the link tag used single quotes, the value might
// be in attribute[3] instead.
if (empty($attribute[2])) {
$attribute[2] = $attribute[3];
}
if (!empty($attribute[1]) && !empty($attribute[2])) {
$candidate[drupal_strtolower($attribute[1])] = drupal_strtolower(decode_entities($attribute[2]));
}
......
<?php
/**
* @file
* Tests for http_request.inc.
*/
/**
* Tests for the http library.
*/
class FeedsHTTPRequestTestCase extends FeedsUnitTestHelper {
public static function getInfo() {
return array(
'name' => 'HTTP library',
'description' => 'Tests for Feeds HTTP library.',
'group' => 'Feeds',
);
}
public function setUp() {
parent::setUp();
feeds_include_library('http_request.inc', 'http_request');
}
/**
* Tests http_request_find_feeds().
*/
public function testHTTPRequestFindFeeds() {
$html = <<<EOF
<html>
<head>
<title>Welcome to Example.com</title>
<link rel="stylesheet" type="text/css" media="screen, projection" href="/stuff.css" >
<link rel="search" title="Something" href="//example.com/search">
<link rel="alternate" title="Something RSS" href="http://example.com/rss.xml" type="application/rss+xml">
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
</head>
<body>
This is a body.
</body>
</html
EOF;
$links = http_request_find_feeds($html);
$this->assertEqual(count($links), 1);
$this->assertEqual($links[0], 'http://example.com/rss.xml');
// Test single quoted HTML.
$links = http_request_find_feeds(str_replace('"', "'", $html));
$this->assertEqual(count($links), 1);
$this->assertEqual($links[0], 'http://example.com/rss.xml');
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment