/[webpac2]/Webpacus2/t/00-action-Search.t
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /Webpacus2/t/00-action-Search.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 954 - (show annotations)
Thu Nov 1 00:17:53 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1269 byte(s)
 r1444@llin:  dpavlin | 2007-11-01 00:23:41 +0100
 return coderef to Template::Declare to create somewhat nice calling
 syntax in form of:
 
 $row->( 'Field Name' )
 
 allowing spaces and such characters in names...

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 use Data::Dump qw/dump/;
14
15 # Make sure we can load the action
16 use_ok('Webpacus::Action::Search');
17
18 # Grab a system user
19 my $system_user = Webpacus::CurrentUser->superuser;
20 ok($system_user, "Found a system user");
21
22 {
23 use Log::Log4perl::Level;
24 Jifty->web->log->level( $DEBUG );
25 }
26
27 my $search = Jifty::Test->web->new_action(
28 class => 'Search',
29 moniker => 'search',
30 current_user => $system_user,
31 arguments => {}
32 );
33
34 isa_ok($search, 'Webpacus::Action::Search');
35
36 my %args = %{$search->arguments};
37
38 ok($args{$_}, "arguments has $_") foreach ( 'field', 'query' );
39
40 $search->argument_values({ feild => '', query => 'a' });
41 $search->run;
42
43 my $results = $search->result->content('results');
44
45 isa_ok($results, 'Webpacus::Search::Results');
46 cmp_ok($results->count, '>=', 1, 'count');
47
48 diag "found ", $results->count, " results";
49
50 ok( my $result = $results->next, 'next' );
51 isa_ok($result, 'CODE' );
52
53 foreach my $f ( qw/database input id TitleProper/ ) {
54
55 my $s = $result->( $f );
56 ok( ! ref($s), 'SCALAR' );
57
58 my @a = $result->( $f );
59 isa_ok( \@a, 'ARRAY' );
60
61 diag "$f = '$s' ",dump(@a);
62 }
63

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26