Ignore:
Timestamp:
Jun 1, 2006, 3:47:57 PM (15 years ago)
Author:
nick
Message:

Test both rss and atom feeds

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/22_rss_modwiki.t

    r790 r795  
    1919}
    2020
    21 plan tests => 7;
    2221
    23 # Clear out the database from any previous runs.
    24 unlink "t/node.db";
    25 unlink <t/indexes/*>;
     22# Which feed types do we test?
     23my @feed_types = qw( rss atom );
     24plan tests => 7 * scalar @feed_types;
    2625
    27 Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
    28 my $config = OpenGuides::Config->new(
    29        vars => {
    30                  dbtype             => "sqlite",
    31                  dbname             => "t/node.db",
    32                  indexing_directory => "t/indexes",
    33                  script_name        => "wiki.cgi",
    34                  script_url         => "http://example.com/",
    35                  site_name          => "Test Site",
    36                  template_path      => "./templates",
    37                  home_name          => "Home",
    38                  use_plucene        => 1
    39                }
    40 );
    4126
    42 # Basic sanity check first.
    43 my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
     27foreach my $feed_type (@feed_types) {
     28    # Clear out the database from any previous runs.
     29    unlink "t/node.db";
     30    unlink <t/indexes/*>;
    4431
    45 my $feed = OpenGuides::Feed->new( wiki   => $wiki,
    46                                   config => $config );
     32    Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
     33    my $config = OpenGuides::Config->new(
     34           vars => {
     35                     dbtype             => "sqlite",
     36                     dbname             => "t/node.db",
     37                     indexing_directory => "t/indexes",
     38                     script_name        => "wiki.cgi",
     39                     script_url         => "http://example.com/",
     40                     site_name          => "Test Site",
     41                     template_path      => "./templates",
     42                     home_name          => "Home",
     43                     use_plucene        => 1
     44                   }
     45    );
    4746
    48 my $rss = eval { $feed->make_feed(feed_type => 'rss', feed_listing => 'recent_changes'); };
    49 is( $@, "", "->make_feed for rss doesn't croak" );
     47    # Basic sanity check first.
     48    my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
    5049
    51 # Now write some data, first a minor edit then a non-minor one.
    52 my $guide = OpenGuides->new( config => $config );
    53    
    54 # Set up CGI parameters ready for a node write.
    55 # Most of these are in here to avoid uninitialised value warnings.
    56 my $q = CGI->new;
    57 $q->param( -name => "content", -value => "foo" );
    58 $q->param( -name => "categories", -value => "" );
    59 $q->param( -name => "locales", -value => "" );
    60 $q->param( -name => "phone", -value => "" );
    61 $q->param( -name => "fax", -value => "" );
    62 $q->param( -name => "website", -value => "" );
    63 $q->param( -name => "hours_text", -value => "" );
    64 $q->param( -name => "address", -value => "" );
    65 $q->param( -name => "postcode", -value => "" );
    66 $q->param( -name => "map_link", -value => "" );
    67 $q->param( -name => "os_x", -value => "" );
    68 $q->param( -name => "os_y", -value => "" );
    69 $q->param( -name => "username", -value => "bob" );
    70 $q->param( -name => "comment", -value => "foo" );
    71 $q->param( -name => "edit_type", -value => "Minor tidying" );
    72 $ENV{REMOTE_ADDR} = "127.0.0.1";
     50    my $feed = OpenGuides::Feed->new( wiki   => $wiki,
     51                                      config => $config );
    7352
    74 my $output = $guide->commit_node(
    75                                   return_output => 1,
    76                                   id => "Wombats",
    77                                   cgi_obj => $q,
    78                                 );
     53    my $rss = eval { $feed->make_feed(feed_type => $feed_type, feed_listing => 'recent_changes'); };
     54    is( $@, "", "->make_feed for $feed_type doesn't croak" );
    7955
    80 $q->param( -name => "edit_type", -value => "Normal edit" );
    81 $output = $guide->commit_node(
    82                                return_output => 1,
    83                                id => "Badgers",
    84                                cgi_obj => $q,
    85                              );
     56    # Now write some data, first a minor edit then a non-minor one.
     57    my $guide = OpenGuides->new( config => $config );
     58       
     59    # Set up CGI parameters ready for a node write.
     60    # Most of these are in here to avoid uninitialised value warnings.
     61    my $q = CGI->new;
     62    $q->param( -name => "content", -value => "foo" );
     63    $q->param( -name => "categories", -value => "" );
     64    $q->param( -name => "locales", -value => "" );
     65    $q->param( -name => "phone", -value => "" );
     66    $q->param( -name => "fax", -value => "" );
     67    $q->param( -name => "website", -value => "" );
     68    $q->param( -name => "hours_text", -value => "" );
     69    $q->param( -name => "address", -value => "" );
     70    $q->param( -name => "postcode", -value => "" );
     71    $q->param( -name => "map_link", -value => "" );
     72    $q->param( -name => "os_x", -value => "" );
     73    $q->param( -name => "os_y", -value => "" );
     74    $q->param( -name => "username", -value => "bob" );
     75    $q->param( -name => "comment", -value => "foo" );
     76    $q->param( -name => "edit_type", -value => "Minor tidying" );
     77    $ENV{REMOTE_ADDR} = "127.0.0.1";
    8678
    87 $q->param( -name => "username", -value => "Kake" );
    88 $output = $guide->commit_node(
    89                                return_output => 1,
    90                                id => "Wombles",
    91                                cgi_obj => $q,
    92                              );
     79    my $output = $guide->commit_node(
     80                                      return_output => 1,
     81                                      id => "Wombats",
     82                                      cgi_obj => $q,
     83                                    );
    9384
    94 # Check that the writes went in.
    95 ok( $wiki->node_exists( "Wombats" ), "Wombats written" );
    96 ok( $wiki->node_exists( "Badgers" ), "Badgers written" );
    97 ok( $wiki->node_exists( "Wombles" ), "Wombles written" );
     85    $q->param( -name => "edit_type", -value => "Normal edit" );
     86    $output = $guide->commit_node(
     87                                   return_output => 1,
     88                                   id => "Badgers",
     89                                   cgi_obj => $q,
     90                                 );
    9891
    99 # Check that the minor edits can be filtered out.
    100 $output = $guide->display_feed(
    101                                feed_type          => "rss",
    102                                feed_listing       => "recent_changes",
    103                                items              => 5,
    104                                username           => "bob",
    105                                ignore_minor_edits => 1,
    106                                return_output      => 1,
    107                              );
    108 unlike( $output, qr/Wombats/, "minor edits filtered out when required" );
    109 like( $output, qr/Badgers/, "but normal edits still in" );
     92    $q->param( -name => "username", -value => "Kake" );
     93    $output = $guide->commit_node(
     94                                   return_output => 1,
     95                                   id => "Wombles",
     96                                   cgi_obj => $q,
     97                                 );
    11098
    111 # Check that the username parameter is taken notice of.
    112 unlike( $output, qr/Wombles/, "username parameter taken note of" );
     99    # Check that the writes went in.
     100    ok( $wiki->node_exists( "Wombats" ), "Wombats written" );
     101    ok( $wiki->node_exists( "Badgers" ), "Badgers written" );
     102    ok( $wiki->node_exists( "Wombles" ), "Wombles written" );
     103
     104    # Check that the minor edits can be filtered out.
     105    $output = $guide->display_feed(
     106                                   feed_type          => $feed_type,
     107                                   feed_listing       => "recent_changes",
     108                                   items              => 5,
     109                                   username           => "bob",
     110                                   ignore_minor_edits => 1,
     111                                   return_output      => 1,
     112                                 );
     113    unlike( $output, qr/Wombats/, "minor edits filtered out when required" );
     114    like( $output, qr/Badgers/, "but normal edits still in" );
     115
     116    # Check that the username parameter is taken notice of.
     117    unlike( $output, qr/Wombles/, "username parameter taken note of" );
     118}
Note: See TracChangeset for help on using the changeset viewer.