/[Arh]/t/00-model-UnitPicture.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-model-UnitPicture.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 45 - (hide annotations)
Sun Apr 6 14:43:01 2008 UTC (16 years ago) by dpavlin
File MIME type: application/x-troff
File size: 1560 byte(s)
ignore bunch of stuff
1 dpavlin 39 #!/usr/bin/env perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7     A basic test harness for the UnitPicture model.
8    
9     =cut
10    
11     use Jifty::Test tests => 16;
12    
13     # Make sure we can load the model
14     use_ok('Arh::Model::UnitPicture');
15     use_ok('Arh::Test');
16    
17     # Grab a system user
18     my $system_user = Arh::CurrentUser->superuser;
19     ok($system_user, "Found a system user");
20    
21     ok( my $unit = Arh::Test->Unit, 'Unit' );
22     ok( my $picture = Arh::Test->Picture, 'Picture' );
23    
24     # Try testing a create
25     my $o = Arh::Model::UnitPicture->new(current_user => $system_user);
26     my ($id) = $o->create(
27     unit => $unit,
28     picture => $picture,
29     );
30     ok($id, "UnitPicture create returned success");
31     ok($o->id, "New UnitPicture has valid id set");
32     is($o->id, $id, "Create returned the right id");
33    
34     ok( $unit = Arh::Test->Unit, 'Unit' );
35     ok( $picture = Arh::Test->Picture, 'Picture' );
36    
37     # And another
38     $o->create(
39     unit => $unit,
40     picture => $picture,
41     );
42     ok($o->id, "UnitPicture create returned another value");
43     isnt($o->id, $id, "And it is different from the previous one");
44    
45     # Searches in general
46     my $collection = Arh::Model::UnitPictureCollection->new(current_user => $system_user);
47     $collection->unlimit;
48     is($collection->count, 2, "Finds two records");
49    
50     # Searches in specific
51     $collection->limit(column => 'id', value => $o->id);
52     is($collection->count, 1, "Finds one record with specific id");
53    
54     # Delete one of them
55     $o->delete;
56     $collection->redo_search;
57     is($collection->count, 0, "Deleted row is gone");
58    
59     # And the other one is still there
60     $collection->unlimit;
61     is($collection->count, 1, "Still one left");
62    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26