/[SQLSession]/trunk/t/00-model-Query.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 /trunk/t/00-model-Query.t

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

trunk/t/00-model-Page.t revision 1 by dpavlin, Fri Dec 1 23:48:06 2006 UTC trunk/t/00-model-Query.t revision 15 by dpavlin, Sun Dec 3 14:01:53 2006 UTC
# Line 2  Line 2 
2  use warnings;  use warnings;
3  use strict;  use strict;
4    
5    use blib;
6    
7  =head1 DESCRIPTION  =head1 DESCRIPTION
8    
9  A basic test harness for the Page model.  A basic test harness for the Query model.
10    
11  =cut  =cut
12    
13  use Jifty::Test tests => 11;  use Jifty::Test tests => 11;
14    my $b = 2;
15    
16  # Make sure we can load the model  # Make sure we can load the model
17  use_ok('SQLSession::Model::Page');  use_ok('SQLSession::Model::Query');
18    
19  # Grab a system user  # Grab a system user
20  my $system_user = SQLSession::CurrentUser->superuser;  my $system_user = SQLSession::CurrentUser->superuser;
21  ok($system_user, "Found a system user");  ok($system_user, "Found a system user");
22    
23  # Try testing a create  # Try testing a create
24  my $o = SQLSession::Model::Page->new(current_user => $system_user);  my $o = SQLSession::Model::Query->new(current_user => $system_user);
25  my ($id) = $o->create();  my ($id) = $o->create( name => 'foo', sql_query => 'bar', on_database => 1 );
26  ok($id, "Page create returned success");  ok($id, "Query create returned success");
27  ok($o->id, "New Page has valid id set");  ok($o->id, "New Query has valid id set");
28  is($o->id, $id, "Create returned the right id");  is($o->id, $id, "Create returned the right id");
29    
30  # And another  # And another
31  $o->create();  $o->create( name => 'baz', sql_query => 'baz', on_database => 1 );
32  ok($o->id, "Page create returned another value");  ok($o->id, "Query create returned another value");
33  isnt($o->id, $id, "And it is different from the previous one");  isnt($o->id, $id, "And it is different from the previous one");
34    
35  # Searches in general  # Searches in general
36  my $collection =  SQLSession::Model::PageCollection->new(current_user => $system_user);  my $collection =  SQLSession::Model::QueryCollection->new(current_user => $system_user);
37  $collection->unlimit;  $collection->unlimit;
38  is($collection->count, 2, "Finds two records");  is($collection->count, $b + 2, "Finds two records");
39    
40  # Searches in specific  # Searches in specific
41  $collection->limit(column => 'id', value => $o->id);  $collection->limit(column => 'id', value => $o->id);
# Line 45  is($collection->count, 0, "Deleted row i Line 48  is($collection->count, 0, "Deleted row i
48    
49  # And the other one is still there  # And the other one is still there
50  $collection->unlimit;  $collection->unlimit;
51  is($collection->count, 1, "Still one left");  is($collection->count, $b + 1, "Still one left");
52    

Legend:
Removed from v.1  
changed lines
  Added in v.15

  ViewVC Help
Powered by ViewVC 1.1.26