/[Grep]/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 /t/00-action-Search.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 148 - (show annotations)
Sat Jun 9 09:15:14 2007 UTC (16 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1832 byte(s)
turn DEBUG logging in part of test
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 => 15;
12
13 # Make sure we can load the action
14 use_ok('Grep::Action::Search');
15
16 # Make sure we can load the model
17 use_ok('Grep::Model::Item');
18 use_ok('Grep::Model::Feed');
19
20 # Grab a system user
21 my $system_user = Grep::CurrentUser->superuser;
22 ok($system_user, "Found a system user");
23
24 # create test feed
25 my $feed = Grep::Model::Feed->new(current_user => $system_user);
26 my ($id) = $feed->create(
27 uri => 'http://www.example.com/',
28 title => 'example feed',
29 );
30 ok($id, "Feed create returned success");
31 ok($feed->id, "New Feed has valid id set");
32 is($feed->id, $id, "Create returned the right id");
33
34 # Try testing a create
35 my $o = Grep::Model::Item->new(current_user => $system_user);
36 ($id) = $o->create(
37 in_feed => $feed,
38 title => 'example title',
39 link => 'http://www.example.com/item1',
40 content => 'some content',
41 );
42 ok($id, "Item create returned success");
43 ok($o->id, "New Item has valid id set");
44 is($o->id, $id, "Create returned the right id");
45
46 # Searches in general
47 my $collection = Grep::Model::ItemCollection->new(current_user => $system_user);
48 $collection->unlimit;
49 is($collection->count, 1, "Finds one record");
50
51 my $search = Jifty::Test->web->new_action(
52 class => 'Search',
53 moniker => 'search',
54 current_user => $system_user,
55 arguments => {}
56 );
57
58 isa_ok($search, 'Grep::Action::Search');
59
60 {
61 use Log::Log4perl::Level;
62 Jifty->web->log->level( $DEBUG );
63 }
64
65 my %args = %{$search->arguments};
66
67 ok($args{q}, "Can search on q");
68
69 # Search on q
70 $search->argument_values({ q => 'example' });
71 $search->run;
72
73 my $result = $search->result->content('search');
74
75 isa_ok($result, 'Jifty::Collection');
76 is($result->count, 1);
77 is($result->first->name, 'test1');
78

  ViewVC Help
Powered by ViewVC 1.1.26