1 |
#!/usr/bin/env perl |
2 |
use warnings; |
3 |
use strict; |
4 |
|
5 |
=head1 DESCRIPTION |
6 |
|
7 |
A (very) basic test harness for the Search action. |
8 |
|
9 |
=cut |
10 |
|
11 |
use Jifty::Test tests => 17; |
12 |
|
13 |
my $debug = 1; |
14 |
|
15 |
use Data::Dump qw/dump/; |
16 |
|
17 |
# Make sure we can load the action |
18 |
use_ok('Webpacus::Action::Search'); |
19 |
|
20 |
# Grab a system user |
21 |
my $system_user = Webpacus::CurrentUser->superuser; |
22 |
ok($system_user, "Found a system user"); |
23 |
|
24 |
{ |
25 |
use Log::Log4perl::Level; |
26 |
Jifty->web->log->level( $DEBUG ); |
27 |
} |
28 |
|
29 |
my $search = Jifty::Test->web->new_action( |
30 |
class => 'Search', |
31 |
moniker => 'search', |
32 |
current_user => $system_user, |
33 |
arguments => {} |
34 |
); |
35 |
|
36 |
isa_ok($search, 'Webpacus::Action::Search'); |
37 |
|
38 |
my %args = %{$search->arguments}; |
39 |
|
40 |
ok($args{$_}, "arguments has $_") foreach ( 'field', 'query' ); |
41 |
|
42 |
$search->argument_values({ feild => '', query => 'a' }); |
43 |
$search->run; |
44 |
|
45 |
my $results = $search->result->content('results'); |
46 |
|
47 |
isa_ok($results, 'Webpacus::Search::Results'); |
48 |
cmp_ok($results->count, '>=', 1, 'count'); |
49 |
|
50 |
diag "found ", $results->count, " results"; |
51 |
|
52 |
ok( my $ds = $results->next, 'next' ); |
53 |
isa_ok($ds, 'Webpacus::Action::DS' ); |
54 |
|
55 |
foreach my $f ( qw/database input id TitleProper/ ) { |
56 |
|
57 |
ok( my $d = $ds->display( $f ), 'display' ); |
58 |
diag "display: ",dump($d) if $debug; |
59 |
|
60 |
} |
61 |
|