source: trunk/t/51_display_node.t @ 812

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

Use Wiki::Toolkit. Note that CGI::Wiki::Plugin::Diff hasn't been converted yet,
so tests will be broken for now.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1use strict;
2use Wiki::Toolkit::Setup::SQLite;
3use OpenGuides::Config;
4use OpenGuides;
5use Test::More tests => 7;
6
7eval { require DBD::SQLite; };
8my $have_sqlite = $@ ? 0 : 1;
9
10SKIP: {
11    skip "DBD::SQLite not installed - no database to test with", 5
12      unless $have_sqlite;
13
14    Wiki::Toolkit::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                     home_name          => "Home",
25                   }
26    );
27    eval { require Wiki::Toolkit::Search::Plucene; };
28    if ( $@ ) { $config->use_plucene ( 0 ) };
29
30    my $guide = OpenGuides->new( config => $config );
31    isa_ok( $guide, "OpenGuides" );
32    my $wiki = $guide->wiki;
33    isa_ok( $wiki, "Wiki::Toolkit" );
34    $wiki->write_node( "Test Page", "foo", undef, { source => "alternate.cgi?Test_Page" } );
35    my $output = eval {
36        $guide->display_node( id => "Test Page", return_output => 1 );
37    };
38    is( $@, "", "->display_node doesn't die" );
39
40    like( $output, qr{\<a.*?\Qhref="alternate.cgi?id=Test_Page;action=edit">Edit this page</a>\E}, "...and edit link is redirected to source URL" );
41    $config->home_name( "My Home Page" );
42    $output = $guide->display_node( return_output => 1 );
43    like( $output, qr/My Home Page/, "...and defaults to the home node, and takes notice of what we want to call it" );
44    like( $output, qr{\Q<a href="wiki.cgi?action=edit;id=My_Home_Page">Edit this page</a>\E}, "...and home page has an edit link" );
45    my %tt_vars = $guide->display_node( return_tt_vars => 1 );
46    ok( defined $tt_vars{recent_changes}, "...and recent_changes is set for the home node even if we have changed its name" );
47}
Note: See TracBrowser for help on using the repository browser.