File: 307_search_summaries.t

package info (click to toggle)
openguides 0.84-1.1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,612 kB
  • sloc: perl: 4,812; sh: 56; javascript: 56; makefile: 19
file content (74 lines) | stat: -rw-r--r-- 2,242 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
use strict;
use Wiki::Toolkit::Setup::SQLite;
use OpenGuides::Config;
use OpenGuides::Search;
use OpenGuides::Test;
use Test::More;

eval { require DBD::SQLite; };
if ( $@ ) {
    my ($error) = $@ =~ /^(.*?)\n/;
    plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)";
}

my $have_lucy = eval { require Lucy; } ? 1 : 0;
my $have_plucene = eval { require Plucene; } ? 1 : 0;

my $num_tests = 2;

plan tests => $num_tests * 2;

SKIP: {
    skip "Plucene not installed.", $num_tests unless $have_plucene;
    run_tests();
}

SKIP: {
    skip "Lucy not installed.", $num_tests unless $have_lucy;
    run_tests( use_lucy => 1 );
}

sub run_tests {
    my %args = @_;

    # Clear out the database from any previous runs.
    OpenGuides::Test::refresh_db();

    my $config = OpenGuides::Config->new(
       vars => {
                 dbtype             => "sqlite",
                 dbname             => "t/node.db",
                 indexing_directory => "t/indexes",
                 script_name        => "wiki.cgi",
                 script_url         => "http://example.com/",
                 site_name          => "Test Site",
                 template_path      => "./templates",
               }
    );

    if ( $args{use_lucy} ) {
        $config->use_lucy( 1 );
        $config->use_plucene( 0 );
    } else {
        $config->use_plucene( 1 );
    }

    my $search = OpenGuides::Search->new( config => $config );
    isa_ok( $search, "OpenGuides::Search" );
    my $wiki = $search->wiki;
    $wiki->write_node( "Pub Crawls", "The basic premise of the pub crawl is "
        . "to visit a succession of pubs, rather than spending the entire "
        . "evening or day in a single establishment. London offers an "
        . "excellent choice of themes for your pub crawl.", undef,
        { category => "Pubs" } ) or die "Can't write node";

    my $output = $search->run(
                               return_output => 1,
                               vars          => { search => "pub" }
                             );
    SKIP: {
        skip "TODO: summaries", 1;
        like( $output, qr|<b>pub</b>|i,
              "outputs at least one bolded occurence of 'pub'" );
    } # end of SKIP
}