source: trunk/t/39_search_form.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: 5.1 KB
Line 
1use strict;
2use Wiki::Toolkit::Setup::SQLite;
3use OpenGuides::Search;
4use OpenGuides::Test;
5use Test::More;
6
7eval { require DBD::SQLite; };
8if ( $@ ) {
9    plan skip_all => "DBD::SQLite not installed";
10}
11
12eval { require Plucene; };
13if ( $@ ) {
14    plan skip_all => "Plucene not installed";
15}
16
17eval { require Test::HTML::Content; };
18if ( $@ ) {
19    plan skip_all => "Test::HTML::Content not installed";
20    exit 0;
21}
22
23# Strictly speaking we don't need to skip _all_ tests if we don't have
24# the modules below.  Revisit this when not in a hurry.
25# We only actually need the former for the National Grid tests and the
26# latter for the UTM tests.
27eval { require Geography::NationalGrid; };
28if ( $@ ) {
29    plan skip_all => "Geography::NationalGrid not installed";
30}
31
32eval { require Geo::Coordinates::UTM; };
33if ( $@ ) {
34    plan skip_all => "Geo::Coordinates::UTM not installed";
35}
36
37plan tests => 27;
38
39# Clear out the database from any previous runs.
40unlink "t/node.db";
41unlink <t/indexes/*>;
42
43Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
44my $config = OpenGuides::Test->make_basic_config;
45$config->use_plucene( 1 );
46
47# British National Grid guides should have os and latlong search fields.
48my $search = OpenGuides::Search->new( config => $config );
49my $output = $search->run( return_output => 1 );
50# Strip Content-Type header to stop Test::HTML::Content getting confused.
51$output =~ s/^Content-Type.*[\r\n]+//m;
52
53Test::HTML::Content::tag_ok( $output, "input", { name => "os_dist" },
54                             "search page includes os_dist input with BNG" );
55Test::HTML::Content::tag_ok( $output, "input", { name => "os_x" },
56                             "...and os_x" );
57Test::HTML::Content::tag_ok( $output, "input", { name => "os_y" },
58                             "...and os_y" );
59Test::HTML::Content::tag_ok( $output, "input", { name => "latlong_dist" },
60                             "...and latlong_dist" );
61Test::HTML::Content::tag_ok( $output, "input", { name => "latitude" },
62                             "...and latitude" );
63Test::HTML::Content::tag_ok( $output, "input", { name => "longitude" },
64                             "...and longitude" );
65Test::HTML::Content::no_tag( $output, "input", { name => "osie_dist" },
66                             "...but not osie_dist" );
67Test::HTML::Content::no_tag( $output, "input", { name => "osie_x" },
68                             "...nor osie_x" );
69Test::HTML::Content::no_tag( $output, "input", { name => "osie_y" },
70                             "...nor osie_y" );
71
72# Irish National Grid guides should have osie and latlong.
73$config->geo_handler( 2 );
74$search = OpenGuides::Search->new( config => $config );
75$output = $search->run( return_output => 1 );
76$output =~ s/^Content-Type.*[\r\n]+//m;
77
78Test::HTML::Content::tag_ok( $output, "input", { name => "osie_dist" },
79                             "search page includes os_dist input with ING" );
80Test::HTML::Content::tag_ok( $output, "input", { name => "osie_x" },
81                             "...and osie_x" );
82Test::HTML::Content::tag_ok( $output, "input", { name => "osie_y" },
83                             "...and osie_y" );
84Test::HTML::Content::tag_ok( $output, "input", { name => "latlong_dist" },
85                             "...and latlong_dist" );
86Test::HTML::Content::tag_ok( $output, "input", { name => "latitude" },
87                             "...and latitude" );
88Test::HTML::Content::tag_ok( $output, "input", { name => "longitude" },
89                             "...and longitude" );
90Test::HTML::Content::no_tag( $output, "input", { name => "os_dist" },
91                             "...but not os_dist" );
92Test::HTML::Content::no_tag( $output, "input", { name => "os_x" },
93                             "...nor os_x" );
94Test::HTML::Content::no_tag( $output, "input", { name => "os_y" },
95                             "...nor os_y" );
96
97# UTM guides should have latitude/longitude/latlong_dist only.
98$config->geo_handler( 3 );
99$config->ellipsoid( "Airy" );
100$search = OpenGuides::Search->new( config => $config );
101$output = $search->run( return_output => 1 );
102$output =~ s/^Content-Type.*[\r\n]+//m;
103
104Test::HTML::Content::tag_ok( $output, "input", { name => "latlong_dist" },
105                             "includes latlong_dist with UTM" );
106Test::HTML::Content::tag_ok( $output, "input", { name => "latitude" },
107                             "...and latitude" );
108Test::HTML::Content::tag_ok( $output, "input", { name => "longitude" },
109                             "...and longitude" );
110Test::HTML::Content::no_tag( $output, "input", { name => "os_dist" },
111                             "...but not os_dist" );
112Test::HTML::Content::no_tag( $output, "input", { name => "os_x" },
113                             "...nor os_x" );
114Test::HTML::Content::no_tag( $output, "input", { name => "os_y" },
115                             "...nor os_y" );
116Test::HTML::Content::no_tag( $output, "input", { name => "osie_x" },
117                             "...but not osie_x" );
118Test::HTML::Content::no_tag( $output, "input", { name => "osie_y" },
119                             "...nor osie_y" );
120Test::HTML::Content::no_tag( $output, "input", { name => "osie_dist" },
121                             "...nor osie_dist" );
Note: See TracBrowser for help on using the repository browser.