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

Annotation of /trunk/t/00-model-Query.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 15 - (hide annotations)
Sun Dec 3 14:01:53 2006 UTC (17 years, 5 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1403 byte(s)
great rename: Model::Page is now Model::Query (which is more sane), tests pass,
bootstrap fills two records for each model
1 dpavlin 1 #!/usr/bin/env perl
2     use warnings;
3     use strict;
4    
5 dpavlin 15 use blib;
6    
7 dpavlin 1 =head1 DESCRIPTION
8    
9 dpavlin 15 A basic test harness for the Query model.
10 dpavlin 1
11     =cut
12    
13     use Jifty::Test tests => 11;
14 dpavlin 15 my $b = 2;
15 dpavlin 1
16     # Make sure we can load the model
17 dpavlin 15 use_ok('SQLSession::Model::Query');
18 dpavlin 1
19     # Grab a system user
20     my $system_user = SQLSession::CurrentUser->superuser;
21     ok($system_user, "Found a system user");
22    
23     # Try testing a create
24 dpavlin 15 my $o = SQLSession::Model::Query->new(current_user => $system_user);
25     my ($id) = $o->create( name => 'foo', sql_query => 'bar', on_database => 1 );
26     ok($id, "Query create returned success");
27     ok($o->id, "New Query has valid id set");
28 dpavlin 1 is($o->id, $id, "Create returned the right id");
29    
30     # And another
31 dpavlin 15 $o->create( name => 'baz', sql_query => 'baz', on_database => 1 );
32     ok($o->id, "Query create returned another value");
33 dpavlin 1 isnt($o->id, $id, "And it is different from the previous one");
34    
35     # Searches in general
36 dpavlin 15 my $collection = SQLSession::Model::QueryCollection->new(current_user => $system_user);
37 dpavlin 1 $collection->unlimit;
38 dpavlin 15 is($collection->count, $b + 2, "Finds two records");
39 dpavlin 1
40     # Searches in specific
41     $collection->limit(column => 'id', value => $o->id);
42     is($collection->count, 1, "Finds one record with specific id");
43    
44     # Delete one of them
45     $o->delete;
46     $collection->redo_search;
47     is($collection->count, 0, "Deleted row is gone");
48    
49     # And the other one is still there
50     $collection->unlimit;
51 dpavlin 15 is($collection->count, $b + 1, "Still one left");
52 dpavlin 1

  ViewVC Help
Powered by ViewVC 1.1.26