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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26