source: trunk/t/51_display_node.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 => 5;
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    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                     home_name          => "Home",
25                   }
26    );
27    my $guide = OpenGuides->new( config => $config );
28    isa_ok( $guide, "OpenGuides" );
29    my $wiki = $guide->wiki;
30    isa_ok( $wiki, "CGI::Wiki" );
31    $wiki->write_node( "Test Page", "foo" );
32    my $output = eval {
33        $guide->display_node( id => "Test Page", return_output => 1 );
34    };
35    is( $@, "", "->display_node doesn't die" );
36
37    $config->home_name( "My Home Page" );
38    $output = $guide->display_node( return_output => 1 );
39    like( $output, qr/My Home Page/, "...and defaults to the home node, and takes notice of what we want to call it" );
40    my %tt_vars = $guide->display_node( return_tt_vars => 1 );
41    ok( defined $tt_vars{recent_changes}, "...and recent_changes is set for the home node even if we have changed its name" );
42}
Note: See TracBrowser for help on using the repository browser.