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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 29 by dpavlin, Mon Feb 19 18:25:12 2007 UTC revision 148 by dpavlin, Sat Jun 9 09:15:14 2007 UTC
# Line 8  A (very) basic test harness for the Sear Line 8  A (very) basic test harness for the Sear
8    
9  =cut  =cut
10    
11  use Jifty::Test tests => 1;  use Jifty::Test tests => 15;
12    
13  # Make sure we can load the action  # Make sure we can load the action
14  use_ok('Grep::Action::Search');  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    

Legend:
Removed from v.29  
changed lines
  Added in v.148

  ViewVC Help
Powered by ViewVC 1.1.26