source: trunk/t/52_display_diffs.t @ 445

Last change on this file since 445 was 445, checked in by kake, 18 years ago

Fixed bug in diff view - versions are the right way round now!

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1use strict;
2use CGI::Wiki::Setup::SQLite;
3use Config::Tiny;
4use OpenGuides;
5use Test::More tests => 4;
6
7eval { require DBD::SQLite; };
8my $have_sqlite = $@ ? 0 : 1;
9
10SKIP: {
11    skip "DBD::SQLite not installed - no database to test with", 4
12      unless $have_sqlite;
13
14    CGI::Wiki::Setup::SQLite::setup( { dbname => "t/node.db" } );
15    my $config = Config::Tiny->new;
16    $config->{_} = {
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                   };
25    my $guide = OpenGuides->new( config => $config );
26    my $wiki = $guide->wiki;
27
28    # Clear out the database from any previous runs.
29    foreach my $del_node ( $wiki->list_all_nodes ) {
30        print "# Deleting node $del_node\n";
31        $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
32    }
33
34    $wiki->write_node( "I Like Pie", "Best pie is meat pie." )
35      or die "Couldn't write node";
36    my %data = $wiki->retrieve_node( "I Like Pie" );
37    $wiki->write_node( "I Like Pie", "Best pie is apple pie.",
38                       $data{checksum} )
39      or die "Couldn't write node";
40    %data = $wiki->retrieve_node( "I Like Pie" );
41    $wiki->write_node( "I Like Pie", "Best pie is lentil pie.",
42                       $data{checksum} )
43      or die "Couldn't write node";
44
45    my $output = eval {
46        $guide->display_diffs(
47                               id            => "I Like Pie",
48                               version       => 3,
49                               other_version => 2,
50                               return_output => 1,
51                             );
52    };
53    is( $@, "", "->display_diffs doesn't die" );
54    like( $output,
55          qr/differences between version 2 and version 3 of I Like Pie/i,
56          "...version numbers included in output" );
57    unlike( $output, qr/contents are identical/i,
58            "...'contents are identical' not printed when contents differ" );
59    like( $output, qr/<th.*Version\s+2.*Version\s+3.*apple.*lentil/s,
60          "...versions are right way round" );
61}
Note: See TracBrowser for help on using the repository browser.