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