/[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

Annotation of /t/00-action-Search.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 147 - (hide annotations)
Sat Jun 9 09:00:59 2007 UTC (16 years, 11 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1765 byte(s)
failing test for search action
1 dpavlin 29 #!/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 dpavlin 147 use Jifty::Test tests => 15;
12 dpavlin 29
13     # Make sure we can load the action
14     use_ok('Grep::Action::Search');
15    
16 dpavlin 147 # 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     my %args = %{$search->arguments};
61    
62     ok($args{q}, "Can search on q");
63    
64     # Search on q
65     $search->argument_values({ q => 'example' });
66     $search->run;
67    
68     my $result = $search->result->content('search');
69    
70     isa_ok($result, 'Jifty::Collection');
71     is($result->count, 1);
72     is($result->first->name, 'test1');
73    

  ViewVC Help
Powered by ViewVC 1.1.26