]> CyberLeo.Net >> Repos - SourceForge/phpwiki.git/blob - tests/unit/lib/plugin/AtomFeedTest.php
No newline at end of file
[SourceForge/phpwiki.git] / tests / unit / lib / plugin / AtomFeedTest.php
1 <?php
2 // $Id$
3 /*
4  * Copyright 2010 Sébastien Le Callonnec
5  *
6  * This file is part of PhpWiki.
7  *
8  * PhpWiki is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * PhpWiki is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with PhpWiki; if not, write to the Free Software Foundation, Inc.,
20  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21  */
22 /**
23  * @author: Sébastien Le Callonnec
24  */
25 require_once('lib/plugin/AtomFeed.php');
26 require_once('lib/AtomParser.php');
27 require_once('lib/HtmlElement.php');
28
29 class AtomFeedTest
30 extends phpwiki_TestCase
31 {
32     var $atom_feed_plugin;
33
34     public function setUp() {
35         parent::setUp();
36         $this->atom_feed_plugin = new WikiPlugin_AtomFeed();
37     }
38
39     public function testRunMaxItem() {
40         global $request;
41         $expected_html = <<<EXPECTED
42 <div class="rss"><h3><a href="http://www.phpwiki.org/fakeurl">This is a fake feed</a></h3>
43 <dl>
44 <dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire</a></dt>
45 <dd><div xmlns="http://www.w3.org/1999/xhtml">Millenium Spire, Dublin
46           <div class="geo">Geo coordinates:
47             <abbr class="latitude" title="53.349441">53.349441</abbr>
48             <abbr class="longitude" title="-6.260282">-6.260282</abbr>
49           </div>
50         </div></dd>
51 </dl>
52 </div>
53 EXPECTED;
54         $html = $this->atom_feed_plugin->run(null, 'url=file://' . dirname(__FILE__) . '/atom-example.xml maxitem=1', $request, '.');
55         $this->assertEquals($expected_html, trim(html_entity_decode($html->asXML())));
56     }
57
58     public function testRunTitleOnly() {
59         global $request;
60         $expected_html = <<<EXPECTED
61 <div class="rss"><h3><a href="http://www.phpwiki.org/fakeurl">This is a fake feed</a></h3>
62 <dl>
63 <dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire</a></dt>
64 <dd></dd>
65 <dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire 2</a></dt>
66 <dd></dd>
67 <dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire 3</a></dt>
68 <dd></dd>
69 <dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire 4</a></dt>
70 <dd></dd>
71 <dt><a href="http://maps.google.com/maps?f=q&sll=53.125728,-6.068907&ie=UTF8">Foobar Éire 5</a></dt>
72 <dd></dd>
73 </dl>
74 </div>
75 EXPECTED;
76         $html = $this->atom_feed_plugin->run(null, 'url=file://' . dirname(__FILE__) . '/atom-example.xml titleonly=true', $request, '.');
77         $this->assertEquals($expected_html, trim(html_entity_decode($html->asXML())));
78     }
79 }
80 ?>