source: trunk/t/54_redirect.t @ 663

Last change on this file since 663 was 663, checked in by Dominic Hargreaves, 16 years ago

test fix

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.8 KB
Line 
1use strict;
2use CGI::Wiki::Setup::SQLite;
3use OpenGuides::Config;
4use OpenGuides;
5use Test::More tests => 2;
6
7eval { require DBD::SQLite; };
8my $have_sqlite = $@ ? 0 : 1;
9
10SKIP: {
11    skip "DBD::SQLite not installed - no database to test with", 2
12      unless $have_sqlite;
13
14    CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } );
15    my $config = OpenGuides::Config->new(
16           vars => {
17                     dbtype             => "sqlite",
18                     dbname             => "t/node.db",
19                     indexing_directory => "t/indexes",
20                     script_name        => "wiki.cgi",
21                     script_url         => "http://example.com/",
22                     site_name          => "Test Site",
23                     template_path      => "./templates",
24                   }
25    );
26    eval { require CGI::Wiki::Search::Plucene; };
27    if ( $@ ) { $config->use_plucene ( 0 ) };
28           
29    my $guide = OpenGuides->new( config => $config );
30    my $wiki = $guide->wiki;
31
32    # Clear out the database from any previous runs.
33    foreach my $del_node ( $wiki->list_all_nodes ) {
34        $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
35    }
36
37    $wiki->write_node( "Test Page", "#REDIRECT [[Test Page 2]]" )
38      or die "Can't write node";
39    $wiki->write_node( "Test Page 2", "foo" )
40      or die "Can't write node";
41    my $output = eval {
42        $guide->display_node( id => "Test Page", return_output => 1 );
43    };
44    is( $@, "", "->display_node doesn't die when page is a redirect" );
45
46    # Old versions of CGI.pm mistakenly print location: instead of Location:
47    like( $output,
48          qr/[lL]ocation: http:\/\/example.com\/wiki.cgi\?id=Test_Page_2\;oldid=Test_Page/,
49          "...and redirects to the right place" );
50}
Note: See TracBrowser for help on using the repository browser.