/[webpac2]/Webpacus2/t/00-model-Sorted.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 /Webpacus2/t/00-model-Sorted.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 996 - (hide annotations)
Sun Nov 4 16:20:13 2007 UTC (16 years, 6 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1346 byte(s)
 r1532@llin:  dpavlin | 2007-11-04 17:20:11 +0100
 new model Sorted which also gets input from WebPAC

1 dpavlin 996 #!/usr/bin/env perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     A basic test harness for the Sorted model.
8    
9     =cut
10    
11     use Jifty::Test tests => 11;
12    
13     # Make sure we can load the model
14     use_ok('Webpacus::Model::Sorted');
15    
16     # Grab a system user
17     my $system_user = Webpacus::CurrentUser->superuser;
18     ok($system_user, "Found a system user");
19    
20     # Try testing a create
21     my $o = Webpacus::Model::Sorted->new(current_user => $system_user);
22     my ($id) = $o->create( name => 'foo', from_database => 'test1' );
23     ok($id, "Sorted create returned success");
24     ok($o->id, "New Sorted has valid id set");
25     is($o->id, $id, "Create returned the right id");
26    
27     # And another
28     $o->create( name => 'bar', from_database => 'test2' );
29     ok($o->id, "Sorted create returned another value");
30     isnt($o->id, $id, "And it is different from the previous one");
31    
32     # Searches in general
33     my $collection = Webpacus::Model::SortedCollection->new(current_user => $system_user);
34     $collection->unlimit;
35     is($collection->count, 2, "Finds two records");
36    
37     # Searches in specific
38     $collection->limit(column => 'id', value => $o->id);
39     is($collection->count, 1, "Finds one record with specific id");
40    
41     # Delete one of them
42     $o->delete;
43     $collection->redo_search;
44     is($collection->count, 0, "Deleted row is gone");
45    
46     # And the other one is still there
47     $collection->unlimit;
48     is($collection->count, 1, "Still one left");
49    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26