root/tags/rel0_48/t/51_display_node.t

Revision 594, 1.7 kB (checked in by dom, 4 years ago)

Update tests so they pass without Plucene installed again (was affected by
config rejig).

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
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    eval { require CGI::Wiki::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, "CGI::Wiki" );
34    $wiki->write_node( "Test Page", "foo" );
35    my $output = eval {
36        $guide->display_node( id => "Test Page", return_output => 1 );
37    };
38    is( $@, "", "->display_node doesn't die" );
39
40    $config->home_name( "My Home Page" );
41    $output = $guide->display_node( return_output => 1 );
42    like( $output, qr/My Home Page/, "...and defaults to the home node, and takes notice of what we want to call it" );
43    my %tt_vars = $guide->display_node( return_tt_vars => 1 );
44    ok( defined $tt_vars{recent_changes}, "...and recent_changes is set for the home node even if we have changed its name" );
45}
Note: See TracBrowser for help on using the browser.