summaryrefslogtreecommitdiffstats
path: root/3rdparty/fguillot/picofeed/tests/ImportTest.php
blob: 784a00d82fcb2e32dbab7871af1943b845f361ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php

require_once 'lib/PicoFeed/PicoFeed.php';

use PicoFeed\Import;

class ImportTest extends PHPUnit_Framework_TestCase
{
    public function testMalFormedFormat()
    {
        $import = new Import('boo');
        $this->assertFalse($import->execute());
    }

    public function testFormat()
    {
        $import = new Import(file_get_contents('tests/fixtures/subscriptionList.opml'));
        $entries = $import->execute();

        $this->assertEquals(14, count($entries));
        $this->assertEquals('CNET News.com', $entries[0]->title);
        $this->assertEquals('http://news.com.com/2547-1_3-0-5.xml', $entries[0]->feed_url);
        $this->assertEquals('http://news.com.com/', $entries[0]->site_url);
    }

    public function testGoogleReader()
    {
        $import = new Import(file_get_contents('tests/fixtures/google-reader.opml'));
        $entries = $import->execute();

        $this->assertEquals(22, count($entries));
        $this->assertEquals('Code', $entries[21]->category);
        $this->assertEquals('Vimeo / CocoaheadsRNS', $entries[21]->title);
        $this->assertEquals('http://vimeo.com/cocoaheadsrns/videos/rss', $entries[21]->feed_url);
        $this->assertEquals('http://vimeo.com/cocoaheadsrns/videos', $entries[21]->site_url);
    }

    public function testTinyTinyRss()
    {
        $import = new Import(file_get_contents('tests/fixtures/tinytinyrss.opml'));
        $entries = $import->execute();

        $this->assertEquals(2, count($entries));
        $this->assertEquals('coding', $entries[1]->category);
        $this->assertEquals('Planète jQuery', $entries[1]->title);
        $this->assertEquals('http://feeds.feedburner.com/PlaneteJqueryFr', $entries[1]->feed_url);
        $this->assertEquals('http://planete-jquery.fr', $entries[1]->site_url);
    }

    public function testNewsBeuter()
    {
        $import = new Import(file_get_contents('tests/fixtures/newsbeuter.opml'));
        $entries = $import->execute();

        $this->assertEquals(35, count($entries));
        $this->assertEquals('', $entries[1]->category);
        $this->assertEquals('code.flickr.com', $entries[1]->title);
        $this->assertEquals('http://code.flickr.net/feed/', $entries[1]->feed_url);
        $this->assertEquals('http://code.flickr.net', $entries[1]->site_url);
    }
}