source: trunk/t/22_rss_modwiki.t @ 753

Last change on this file since 753 was 753, checked in by Earle Martin, 16 years ago

New module, OpenGuides::Feed: this extracts the stuff formerly in OpenGuides::RDF (as sub make_recentchanges_rss) that was invoking CGI::Wiki::Plugin::RSS::ModWiki, and replaces it with a single make_feed method that can be used for any feed format, including Atom (using the new CGI::Wiki::Plugin::Atom). Changes to OpenGuides.pm and wiki.cgi are to use this new module appropriately.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.9 KB
RevLine 
[126]1use strict;
[361]2use CGI::Wiki::Setup::SQLite;
[587]3use OpenGuides::Config;
[550]4use OpenGuides;
[361]5use OpenGuides::RDF;
6use OpenGuides::Utils;
[550]7use Test::More;
[126]8
[361]9eval { require DBD::SQLite; };
[550]10if ( $@ ) {
11    plan skip_all => "DBD::SQLite not installed";
[552]12    exit 0;
13}
[126]14
[552]15eval { require CGI::Wiki::Search::Plucene; };
16if ( $@ ) {
17    plan skip_all => "Plucene not installed";
18    exit 0;
19}
[126]20
[552]21plan tests => 7;
[126]22
[552]23# Clear out the database from any previous runs.
24unlink "t/node.db";
25unlink <t/indexes/*>;
[550]26
[552]27CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } );
[587]28my $config = OpenGuides::Config->new(
29       vars => {
[552]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
[587]39               }
40);
[126]41
[552]42# Basic sanity check first.
43my $wiki = OpenGuides::Utils->make_wiki_object( config => $config );
[126]44
[753]45my $feed = OpenGuides::Feed->new( wiki   => $wiki,
46                                  config => $config );
[126]47
[753]48my $rss = eval { $feed->make_feed(feed_type => 'rss'); };
49is( $@, "", "->make_feed for rss doesn't croak" );
[552]50
51# Now write some data, first a minor edit then a non-minor one.
52my $guide = OpenGuides->new( config => $config );
[550]53   
[552]54# Set up CGI parameters ready for a node write.
55# Most of these are in here to avoid uninitialised value warnings.
56my $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";
[126]73
[552]74my $output = $guide->commit_node(
75                                  return_output => 1,
76                                  id => "Wombats",
77                                  cgi_obj => $q,
78                                );
[550]79
[552]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                             );
[550]86
[552]87$q->param( -name => "username", -value => "Kake" );
88$output = $guide->commit_node(
89                               return_output => 1,
90                               id => "Wombles",
91                               cgi_obj => $q,
92                             );
[550]93
[552]94# Check that the writes went in.
95ok( $wiki->node_exists( "Wombats" ), "Wombats written" );
96ok( $wiki->node_exists( "Badgers" ), "Badgers written" );
97ok( $wiki->node_exists( "Wombles" ), "Wombles written" );
[550]98
[552]99# Check that the minor edits can be filtered out.
[753]100$output = $guide->display_feed(
101                               feed_type          => "rss",
[552]102                               items              => 5,
103                               username           => "bob",
104                               ignore_minor_edits => 1,
105                               return_output      => 1,
106                             );
107unlike( $output, qr/Wombats/, "minor edits filtered out when required" );
108like( $output, qr/Badgers/, "but normal edits still in" );
[550]109
[552]110# Check that the username parameter is taken notice of.
111unlike( $output, qr/Wombles/, "username parameter taken note of" );
Note: See TracBrowser for help on using the repository browser.