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

Last change on this file since 587 was 587, checked in by kake, 17 years ago

Encapsulate config data in OpenGuides::Config.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.6 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    my $guide = OpenGuides->new( config => $config );
27    my $wiki = $guide->wiki;
28
29    # Clear out the database from any previous runs.
30    foreach my $del_node ( $wiki->list_all_nodes ) {
31        $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
32    }
33
34    $wiki->write_node( "Test Page", "#REDIRECT [[Test Page 2]]" )
35      or die "Can't write node";
36    $wiki->write_node( "Test Page 2", "foo" )
37      or die "Can't write node";
38    my $output = eval {
39        $guide->display_node( id => "Test Page", return_output => 1 );
40    };
41    is( $@, "", "->display_node doesn't die when page is a redirect" );
42
43    # Old versions of CGI.pm mistakenly print location: instead of Location:
44    like( $output,
45          qr/[lL]ocation: http:\/\/example.com\/wiki.cgi\?Test_Page_2/,
46          "...and redirects to the right place" );
47}
Note: See TracBrowser for help on using the repository browser.