diff options
Diffstat (limited to 'vendor/fguillot/picofeed/tests/Serialization')
m--------- | vendor/fguillot/picofeed | 0 | ||||
-rw-r--r-- | vendor/fguillot/picofeed/tests/Serialization/ExportTest.php | 70 | ||||
-rw-r--r-- | vendor/fguillot/picofeed/tests/Serialization/ImportTest.php | 61 |
3 files changed, 131 insertions, 0 deletions
diff --git a/vendor/fguillot/picofeed b/vendor/fguillot/picofeed deleted file mode 160000 -Subproject 0a1d0d3950f7f047dc8fb1d80aa6296e15f306d diff --git a/vendor/fguillot/picofeed/tests/Serialization/ExportTest.php b/vendor/fguillot/picofeed/tests/Serialization/ExportTest.php new file mode 100644 index 000000000..fa68c05ca --- /dev/null +++ b/vendor/fguillot/picofeed/tests/Serialization/ExportTest.php @@ -0,0 +1,70 @@ +<?php +namespace PicoFeed\Serialization; + +use PHPUnit_Framework_TestCase; + + +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); + } +}
\ No newline at end of file diff --git a/vendor/fguillot/picofeed/tests/Serialization/ImportTest.php b/vendor/fguillot/picofeed/tests/Serialization/ImportTest.php new file mode 100644 index 000000000..8fd010486 --- /dev/null +++ b/vendor/fguillot/picofeed/tests/Serialization/ImportTest.php @@ -0,0 +1,61 @@ +<?php +namespace PicoFeed\Serialization; + +use PHPUnit_Framework_TestCase; + + +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); + } +}
\ No newline at end of file |