Skip to content

Commit

Permalink
Reinstate and improve Feed::parse tests
Browse files Browse the repository at this point in the history
Original test was being skipped because it was hitting the internet
- the major relevant functionality here is the parsing rather than
the remote access.

Added local example feeds for RSS2.0 as well as the previously
tested atom feed. Also improved the tests to check for the title
as well as the number of elements since we now have known
content to work with.
  • Loading branch information
acoulton committed Sep 23, 2014
1 parent c7bc251 commit e9cd5ed
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 4 deletions.
13 changes: 9 additions & 4 deletions tests/kohana/FeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public function provider_parse()
{
return array(
// $source, $expected
array('http://dev.kohanaframework.org/projects/kohana3/activity.atom', 15),
array(realpath(__DIR__.'/../test_data/feeds/activity.atom'), array('Proposals (Political/Workflow) #4839 (New)', 'Proposals (Political/Workflow) #4782')),
array(realpath(__DIR__.'/../test_data/feeds/example.rss20'), array('Example entry')),
);
}

Expand All @@ -38,11 +39,15 @@ public function provider_parse()
* @param string $source URL to test
* @param integer $expected Count of items
*/
public function test_parse($source, $expected)
public function test_parse($source, $expected_titles)
{
$this->markTestSkipped('We don\'t go to the internet for tests.');
$titles = array();
foreach (Feed::parse($source) as $item)
{
$titles[] = $item['title'];
}

$this->assertEquals($expected, count(Feed::parse($source)));
$this->assertSame($expected_titles, $titles);
}

/**
Expand Down
58 changes: 58 additions & 0 deletions tests/test_data/feeds/activity.atom
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>Kohana v3.x: Activity</title>
<link href="http://dev.kohanaframework.org/projects/kohana3/activity.atom" rel="self"/>
<link href="http://dev.kohanaframework.org/projects/kohana3/activity" rel="alternate"/>
<id>http://dev.kohanaframework.org/</id>
<icon>http://dev.kohanaframework.org/favicon.ico?1392677580</icon>
<updated>2014-08-28T01:52:12Z</updated>
<author>
<name>Kohana Development</name>
</author>
<generator uri="http://www.redmine.org/">
Redmine </generator>
<entry>
<title>Proposals (Political/Workflow) #4839 (New)</title>
<link href="http://dev.kohanaframework.org/issues/4839" rel="alternate"/>
<id>http://dev.kohanaframework.org/issues/4839</id>
<updated>2014-08-28T01:52:12Z</updated>
<author>
<name>Guillaume Poirier-Morency</name>
<email>[email protected]</email>
</author>
<content type="html">
&lt;p&gt;I have a prototype here &lt;a class="external" href="https://github.com/arteymix/kohana-makefile"&gt;https://github.com/arteymix/kohana-makefile&lt;/a&gt;&lt;/p&gt;


&lt;p&gt;The tool is very useful for settings permissions and running tests.&lt;/p&gt;


&lt;p&gt;I think we should consider having a good make tool in the sample application for the 3.4.*.&lt;/p&gt; </content>
</entry>
<entry>
<title>Proposals (Political/Workflow) #4782</title>
<link href="http://dev.kohanaframework.org/issues/4782#change-17279" rel="alternate"/>
<id>http://dev.kohanaframework.org/issues/4782#change-17279</id>
<updated>2014-08-28T01:44:26Z</updated>
<author>
<name>Guillaume Poirier-Morency</name>
<email>[email protected]</email>
</author>
<content type="html">
&lt;p&gt;Moving to composer is a nice idea. This will allow Kohana modules to define a wide range of dependencies.&lt;/p&gt;


&lt;p&gt;Although, I think that modules designed specifically for Kohana should end in modules and external libraries in application/vendor. This makes a clear dinsinction between what gets autoloaded by the CFS and what gets loaded by composer. Technically, we add "vendor-dir": "application/vendor" in "config" in composer.json.&lt;/p&gt;


&lt;p&gt;Then, only add a line after the modules loading in bootstrap.php&lt;/p&gt;


&lt;pre&gt;
// Autoloading composer packages
require Kohana::find_file('vendor', 'autoload');
&lt;/pre&gt;

&lt;p&gt;This is pretty much what I do right now. This doesn't break anything and allow a full access to composer.&lt;/p&gt; </content>
</entry>
</feed>
20 changes: 20 additions & 0 deletions tests/test_data/feeds/example.rss20
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>RSS Title</title>
<description>This is an example of an RSS feed</description>
<link>http://www.example.com/main.html</link>
<lastBuildDate>Mon, 06 Sep 2010 00:01:00 +0000 </lastBuildDate>
<pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>
<ttl>1800</ttl>

<item>
<title>Example entry</title>
<description>Here is some text containing an interesting description.</description>
<link>http://www.example.com/blog/post/1</link>
<guid>7bd204c6-1655-4c27-aeee-53f933c5395f</guid>
<pubDate>Sun, 06 Sep 2009 16:20:00 +0000</pubDate>
</item>

</channel>
</rss>

0 comments on commit e9cd5ed

Please sign in to comment.