Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
 
3
require_once 'XML_Feed_Parser_TestCase.php';
4
 
5
/**
6
 * This is a set of tests for specific reported bugs.
7
 */
8
class Regressions extends XML_Feed_Parser_TestCase
9
{
10
    function setUp()
11
    {
12
        $this->sample_dir = XML_Feed_Parser_TestCase::getSampleDir();
13
    }
14
 
15
    /**
16
     * Issue 13215 reported some problems with HTML entity parsing not supporting
17
     * the correct content types
18
     *
19
     * @url http://pear.php.net/bugs/bug.php?id=13215
20
     */
21
    function test_entitiesSupportForIssue13215()
22
    {
23
      $xml = file_get_contents($this->sample_dir . "/bug13215.xml");
24
      $feed = new XML_Feed_Parser($xml);
25
      $entry = $feed->getEntryById('http://www.thepost.ohiou.edu/Articles/News/2008/03/07/23319/');
26
      $this->assertRegexp('/&ldquo;We&rsquo;re ready to take it to the courts/', $entry->content);
27
    }
28
 
29
    /**
30
     * Some feeds may have more than one <enclosure> element defined to
31
     * associate multiple files with a single field (eg., for the same video in
32
     * multiple formats).  XML_Feed_Parser seems to only support a single
33
     * <enclosure> element.  If more than one element is included in the feed,
34
     * only the last one will be accessible through $item->enclosure.
35
     *
36
     * @todo Get sample of feed to use in this test
37
     * @url http://pear.php.net/bugs/bug.php?id=12844
38
     **/
39
    function test_handlesMultipleEnclosuresInRSS()
40
    {
41
      $xml = file_get_contents($this->sample_dir . "/bug12844.xml");
42
      $feed = new XML_Feed_Parser($xml);
43
      $entry = $feed->getEntryByOffset(0);
44
      $first = $entry->enclosure(0);
45
      $second = $entry->enclosure(1);
46
      $this->assertEquals('http://www.scripting.com/mp3s/weatherReportSuite.mp3', $first['url']);
47
      $this->assertEquals('http://www.scripting.com/mp3s/weatherReportSuite2.mp3', $second['url']);
48
    }
49
 
50
    function test_handlesMultipleEnclosuresInAtom()
51
    {
52
      $xml = file_get_contents($this->sample_dir . "/bug12844-atom.xml");
53
      $feed = new XML_Feed_Parser($xml);
54
      $entry = $feed->getEntryByOffset(0);
55
      $first = $entry->enclosure(0);
56
      $second = $entry->enclosure(1);
57
      $this->assertEquals('http://example.org/audio/ph34r_my_podcast.mp3', $first['url']);
58
      $this->assertEquals('http://example.org/audio/ph34r_my_podcast2.mp3', $second['url']);
59
    }
60
 
61
    /**
62
     * German umlauts (ÄÖÜäöüß) from an atom xml file (encoding="iso-8859-1")
63
     * are displayed wrong after parsing, eg. http://www.keine-gentechnik.de/news-regionen.xml
64
     *
65
     * @url http://pear.php.net/bugs/bug.php?id=12916
66
     **/
67
    function test_handlesGermanUmlauts()
68
    {
69
      $xml = file_get_contents($this->sample_dir . "/bug12916.xml");
70
      $feed = new XML_Feed_Parser($xml);
71
      $entry = $feed->getEntryById('sample-feed:1');
72
 
73
      // Ensure that the parsed XML equals the input XML
74
      // $this->assertEquals($xml, (string)$feed);
75
      $this->assertEquals('ÄÜÖäüöß', $entry->title);
76
      $this->assertEquals('&Auml;&Uuml;&Ouml;&auml;&uuml;&ouml;&szlig;', $entry->content);
77
    }
78
 
79
    function test_handlesAmpersandsInUrls()
80
    {
81
      $xml = file_get_contents($this->sample_dir . "/bug12919.xml");
82
      $feed = new XML_Feed_Parser($xml);
83
      $entry = $feed->getEntryById('entry-id');
84
      $this->assertEquals('<a href="http://www.vzbv.de/start/index.php?page=presse&amp;bereichs_id=25">Linktext</a>',
85
        trim($entry->content));
86
    }
87
}