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

Last change on this file since 1064 was 1064, checked in by kake, 14 years ago

Add intercept_redirect parameter to Openguides->display_node - used with the return_output parameter for testing.

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