summaryrefslogtreecommitdiffstats
path: root/3rdparty/fguillot/picofeed/tests/ExportTest.php
blob: b90fea06d9e476e1e391a0e513185fb62d1fbb77 (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
62
63
64
65
66
67
68
69
70
<?php

require_once 'lib/PicoFeed/PicoFeed.php';

use PicoFeed\Export;

class ExportTest extends PHPUnit_Framework_TestCase
{
    public function testOuput()
    {
        $feeds = array(
            array(
                'title' => 'Site title',
                'description' => 'Optional description',
                'site_url' => 'http://blabla.fr/',
            ),
            array(
                'title' => 'Site title',
                'description' => 'Optional description',
                'site_url' => 'http://petitcodeur.fr/',
                'feed_url' => 'http://petitcodeur.fr/feed.xml',
            )
        );

        $export = new Export($feeds);
        $opml = $export->execute();

        $expected = '<?xml version="1.0" encoding="utf-8"?>
<opml><head><title>OPML Export</title></head><body><outline xmlUrl="http://petitcodeur.fr/feed.xml" htmlUrl="http://petitcodeur.fr/" title="Site title" text="Site title" description="Optional description" type="rss" version="RSS"/></body></opml>
';

        $this->assertEquals($expected, $opml);
    }

    public function testCategoryOuput()
    {
        $feeds = array(
            'my category' => array(
                array(
                    'title' => 'Site title',
                    'description' => 'Optional description',
                    'site_url' => 'http://blabla.fr/',
                ),
                array(
                    'title' => 'Site title',
                    'description' => 'Optional description',
                    'site_url' => 'http://petitcodeur.fr/',
                    'feed_url' => 'http://petitcodeur.fr/feed.xml',
                )
            ),
            'another category' => array(
                array(
                    'title' => 'Site title',
                    'description' => 'Optional description',
                    'site_url' => 'http://youpi.ici/',
                    'feed_url' => 'http://youpi.ici/feed.xml',
                )
            )
        );

        $export = new Export($feeds);
        $opml = $export->execute();

        $expected = '<?xml version="1.0" encoding="utf-8"?>
<opml><head><title>OPML Export</title></head><body><outline text="my category"><outline xmlUrl="http://petitcodeur.fr/feed.xml" htmlUrl="http://petitcodeur.fr/" title="Site title" text="Site title" description="Optional description" type="rss" version="RSS"/></outline><outline text="another category"><outline xmlUrl="http://youpi.ici/feed.xml" htmlUrl="http://youpi.ici/" title="Site title" text="Site title" description="Optional description" type="rss" version="RSS"/></outline></body></opml>
';

        $this->assertEquals($expected, $opml);
    }
}