Make WordPress Core

Changeset 11 in tests


Ignore:
Timestamp:
09/20/2007 06:54:45 AM (19 years ago)
Author:
tellyworth
Message:

more useful rss tests

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • README.txt

    r9 r11  
    1818
    1919wp-test.php is intended to run at the command line, not via a web server.
     20
     21The 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  
    22
    33include_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.
    49
    510class TestFeedRss2 extends _WPMediumBlog {
     
    1217    }
    1318
    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() {
    1564        $this->http('/feed/');
    1665        $feed = $this->do_rss2();
    1766        $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']);
    2181    }
    2282}
  • wp-testdata/sample_blogs.php

    r8 r11  
    1313        $this->author = get_userdatabylogin(WP_USER_NAME);
    1414        $this->_delete_all_posts();
     15        // clear out some caching stuff that's likely to cause unexpected results
     16        unset($GLOBALS['cache_lastpostmodified']);
    1517    }
    1618
  • wp-testlib/utils.php

    r1 r11  
    6767    $n = count($a);
    6868
    69     var_dump(__FUNCTION__, $a, $n);
     69#   var_dump(__FUNCTION__, $a, $n);
    7070
    7171    $out = array();
     
    7575
    7676    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]);
    7979        if ($tree[$i]['name'] == $a[0]) {
    80             echo "n == {$n}\n";
     80#           echo "n == {$n}\n";
    8181            if ($n == 1)
    8282                $out[] = $tree[$i];
Note: See TracChangeset for help on using the changeset viewer.