--- Webpacus2/t/00-action-Search.t 2007/10/31 10:34:38 930 +++ Webpacus2/t/00-action-Search.t 2007/11/02 12:59:39 963 @@ -8,8 +8,54 @@ =cut -use Jifty::Test tests => 1; +use Jifty::Test tests => 17; + +my $debug = 1; + +use Data::Dump qw/dump/; # Make sure we can load the action use_ok('Webpacus::Action::Search'); +# Grab a system user +my $system_user = Webpacus::CurrentUser->superuser; +ok($system_user, "Found a system user"); + +{ + use Log::Log4perl::Level; + Jifty->web->log->level( $DEBUG ); +} + +my $search = Jifty::Test->web->new_action( + class => 'Search', + moniker => 'search', + current_user => $system_user, + arguments => {} +); + +isa_ok($search, 'Webpacus::Action::Search'); + +my %args = %{$search->arguments}; + +ok($args{$_}, "arguments has $_") foreach ( 'field', 'query' ); + +$search->argument_values({ feild => '', query => 'a' }); +$search->run; + +my $results = $search->result->content('results'); + +isa_ok($results, 'Webpacus::Search::Results'); +cmp_ok($results->count, '>=', 1, 'count'); + +diag "found ", $results->count, " results"; + +ok( my $ds = $results->next, 'next' ); +isa_ok($ds, 'Webpacus::Action::DS' ); + +foreach my $f ( qw/database input id TitleProper/ ) { + + ok( my $d = $ds->display( $f ), 'display' ); + diag "display: ",dump($d) if $debug; + +} +