Changeset 11 in tests
- Timestamp:
- 09/20/2007 06:54:45 AM (19 years ago)
- Files:
-
- 4 edited
-
README.txt (modified) (1 diff)
-
wp-testcase/test_includes_feed_rss2.php (modified) (2 diffs)
-
wp-testdata/sample_blogs.php (modified) (1 diff)
-
wp-testlib/utils.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
README.txt
r9 r11 18 18 19 19 wp-test.php is intended to run at the command line, not via a web server. 20 21 The wordpress and wordpress-mu trunks are included as svn externals. By default wp-test.php will run tests against the wordpress branch. To run the same tests against the wordpress-mu branch instead: 22 23 $ php wp-test.php -v mu -
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 } -
wp-testdata/sample_blogs.php
r8 r11 13 13 $this->author = get_userdatabylogin(WP_USER_NAME); 14 14 $this->_delete_all_posts(); 15 // clear out some caching stuff that's likely to cause unexpected results 16 unset($GLOBALS['cache_lastpostmodified']); 15 17 } 16 18 -
wp-testlib/utils.php
r1 r11 67 67 $n = count($a); 68 68 69 var_dump(__FUNCTION__, $a, $n);69 # var_dump(__FUNCTION__, $a, $n); 70 70 71 71 $out = array(); … … 75 75 76 76 for ($i=0; $i<count($tree); $i++) { 77 echo "checking '{$tree[$i][name]}' == '{$a[0]}'\n";78 var_dump($tree[$i]['name'], $a[0]);77 # echo "checking '{$tree[$i][name]}' == '{$a[0]}'\n"; 78 # var_dump($tree[$i]['name'], $a[0]); 79 79 if ($tree[$i]['name'] == $a[0]) { 80 echo "n == {$n}\n";80 # echo "n == {$n}\n"; 81 81 if ($n == 1) 82 82 $out[] = $tree[$i];
Note: See TracChangeset
for help on using the changeset viewer.