Projet

Général

Profil

Paste
Télécharger (1,37 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / feeds / tests / http_request.test @ 41cc1b08

1
<?php
2

    
3
/**
4
 * @file
5
 * Tests for http_request.inc.
6
 */
7

    
8
/**
9
 * Tests for the http library.
10
 */
11
class FeedsHTTPRequestTestCase extends FeedsUnitTestHelper {
12
  public static function getInfo() {
13
    return array(
14
      'name' => 'HTTP library',
15
      'description' => 'Tests for Feeds HTTP library.',
16
      'group' => 'Feeds',
17
    );
18
  }
19

    
20
  public function setUp() {
21
    parent::setUp();
22
    feeds_include_library('http_request.inc', 'http_request');
23
  }
24

    
25
  /**
26
   * Tests http_request_find_feeds().
27
   */
28
  public function testHTTPRequestFindFeeds() {
29
    $html = <<<EOF
30
<html>
31
  <head>
32
    <title>Welcome to Example.com</title>
33
    <link rel="stylesheet" type="text/css" media="screen, projection" href="/stuff.css" >
34
    <link rel="search"    title="Something" href="//example.com/search">
35
    <link rel="alternate" title="Something RSS" href="http://example.com/rss.xml" type="application/rss+xml">
36
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
37
  </head>
38
  <body>
39
    This is a body.
40
  </body>
41
</html
42
EOF;
43

    
44
    $links = http_request_find_feeds($html);
45
    $this->assertEqual(count($links), 1);
46
    $this->assertEqual($links[0], 'http://example.com/rss.xml');
47

    
48
    // Test single quoted HTML.
49
    $links = http_request_find_feeds(str_replace('"', "'", $html));
50
    $this->assertEqual(count($links), 1);
51
    $this->assertEqual($links[0], 'http://example.com/rss.xml');
52
  }
53

    
54
}