source: trunk/t/53_show_index.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;
4use OpenGuides::Test;
5use Test::More tests => 6;
6
7eval { require DBD::SQLite; };
8my $have_sqlite = $@ ? 0 : 1;
9
10SKIP: {
11    skip "DBD::SQLite not installed - no database to test with", 6
12      unless $have_sqlite;
13
14    Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
15    my $config = OpenGuides::Test->make_basic_config;
16    $config->script_name( "wiki.cgi" );
17    $config->script_url( "http://example.com/" );
18    my $guide = OpenGuides->new( config => $config );
19    isa_ok( $guide, "OpenGuides" );
20    my $wiki = $guide->wiki;
21    isa_ok( $wiki, "Wiki::Toolkit" );
22
23    # Clear out the database from any previous runs.
24    foreach my $del_node ( $wiki->list_all_nodes ) {
25        print "# Deleting node $del_node\n";
26        $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
27    }
28
29    $wiki->write_node( "Test Page", "foo", undef,
30                       { category => "Alpha" } )
31      or die "Couldn't write node";
32    $wiki->write_node( "Test Page 2", "foo", undef,
33                       { category => "Alpha" } )
34      or die "Couldn't write node";
35    my $output = eval {
36        $guide->show_index(
37                            type          => "category",
38                            value         => "Alpha",
39                            return_output => 1,
40                          );
41    };
42    is( $@, "", "->show_index doesn't die" );
43    like( $output, qr|wiki.cgi\?Test_Page|,
44          "...and includes correct links" );
45    unlike( $output, qr|<title>\s*-|, "...sets <title> correctly" );
46
47    $output = $guide->show_index(
48                                  type          => "category",
49                                  value         => "Alpha",
50                                  return_output => 1,
51                                  format        => "rdf"
52                                );
53    like( $output, qr|Content-Type: application/rdf\+xml|,
54          "RDF output gets content-type of application/rdf+xml" );
55}
Note: See TracBrowser for help on using the repository browser.