Changeset 11 in tests for wp-testcase/test_includes_feed_rss2.php
- Timestamp:
- 09/20/2007 06:54:45 AM (19 years ago)
- File:
-
- 1 edited
-
wp-testcase/test_includes_feed_rss2.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
wp-testcase/test_includes_feed_rss2.php
r1 r11 2 2 3 3 include_once(DIR_TESTDATA . '/sample_blogs.php'); 4 5 // test the RSS 2.0 feed by generating a feed, parsing it, and checking that the 6 // contents are correct. Since we're using a real XML parser, this also ensures 7 // that the feed is valid XML, and that the contents are correctly escaped and 8 // encoded. 4 9 5 10 class TestFeedRss2 extends _WPMediumBlog { … … 12 17 } 13 18 14 function test_rss2() { 19 function test_rss() { 20 $this->http('/feed/'); 21 $feed = $this->do_rss2(); 22 $xml = xml_to_array($feed); 23 24 // get the rss element 25 $rss = xml_find($xml, 'rss'); 26 27 // there should only be one rss element 28 $this->assertEquals(1, count($rss)); 29 30 $this->assertEquals('2.0', $rss[0]['attributes']['version']); 31 $this->assertEquals('http://purl.org/rss/1.0/modules/content/', $rss[0]['attributes']['xmlns:content']); 32 $this->assertEquals('http://wellformedweb.org/CommentAPI/', $rss[0]['attributes']['xmlns:wfw']); 33 $this->assertEquals('http://purl.org/dc/elements/1.1/', $rss[0]['attributes']['xmlns:dc']); 34 35 // rss should have exactly one child element (channel) 36 $this->assertEquals(1, count($rss[0]['child'])); 37 } 38 39 function test_channel() { 40 $this->http('/feed/'); 41 $feed = $this->do_rss2(); 42 $xml = xml_to_array($feed); 43 44 // get the rss -> channel element 45 $channel = xml_find($xml, 'rss', 'channel'); 46 47 $this->assertTrue(empty($channel[0]['attributes'])); 48 49 $title = xml_find($xml, 'rss', 'channel', 'title'); 50 $this->assertEquals(get_option('blogname'), $title[0]['content']); 51 52 $desc = xml_find($xml, 'rss', 'channel', 'description'); 53 $this->assertEquals(get_option('blogdescription'), $desc[0]['content']); 54 55 $link = xml_find($xml, 'rss', 'channel', 'link'); 56 $this->assertEquals(get_option('siteurl'), $link[0]['content']); 57 58 $pubdate = xml_find($xml, 'rss', 'channel', 'pubDate'); 59 $this->assertEquals(strtotime(get_lastpostmodified()), strtotime($pubdate[0]['content'])); 60 } 61 62 63 function test_entry_titles() { 15 64 $this->http('/feed/'); 16 65 $feed = $this->do_rss2(); 17 66 $data = xml_to_array($feed); 18 #var_dump($data); 19 #var_dump(xml_find($data, 'rss', 'channel', 'item', 'title')); 20 #var_dump($data); 67 68 // get all the rss -> channel -> item -> title elements 69 $titles = xml_find($data, 'rss', 'channel', 'item', 'title'); 70 71 $this->assertEquals('post title 24', $titles[0]['content']); 72 $this->assertEquals('post title 23', $titles[1]['content']); 73 $this->assertEquals('post title 22', $titles[2]['content']); 74 $this->assertEquals('post title 21', $titles[3]['content']); 75 $this->assertEquals('post title 20', $titles[4]['content']); 76 $this->assertEquals('post title 19', $titles[5]['content']); 77 $this->assertEquals('post title 18', $titles[6]['content']); 78 $this->assertEquals('post title 17', $titles[7]['content']); 79 $this->assertEquals('post title 16', $titles[8]['content']); 80 $this->assertEquals('post title 15', $titles[9]['content']); 21 81 } 22 82 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)