/[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 4 - (hide annotations)
Thu Nov 29 11:20:24 2007 UTC (16 years, 4 months ago) by dpavlin
File MIME type: application/x-troff
File size: 1921 byte(s)
added bunch of models and script to resize tif pictures
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    
16     # Grab a system user
17     my $system_user = Arh::CurrentUser->superuser;
18     ok($system_user, "Found a system user");
19    
20     my $place = Arh::Model::Place->new(current_user => $system_user);
21     ok( $place->create(
22     name => 'mjesto iskapanja',
23     ), "Place create returned success");
24    
25     my $campaign = Arh::Model::Campaign->new(current_user => $system_user);
26     ok( $campaign->create(
27     name => 'prvo iskapanje',
28     date_from => '2007-11-28',
29     date_to => '2008-03-15',
30     place => $place,
31     ), "Campaign create returned success");
32    
33     my $type = Arh::Model::PictureType->new(current_user => $system_user);
34     ok( $type->create(
35     name => 'slika',
36     ), "PictureType create returned success");
37    
38     # Try testing a create
39     my $o = Arh::Model::Picture->new(current_user => $system_user);
40     my ($id) = $o->create(
41     filename => 'foo.jpg',
42     campaign => $campaign,
43     type => $type,
44     );
45     ok($id, "Picture create returned success");
46     ok($o->id, "New Picture has valid id set");
47     is($o->id, $id, "Create returned the right id");
48    
49     # And another
50     $o->create(
51     filename => 'bar.jpg',
52     campaign => $campaign,
53     type => $type,
54     );
55     ok($o->id, "Picture create returned another value");
56     isnt($o->id, $id, "And it is different from the previous one");
57    
58     # Searches in general
59     my $collection = Arh::Model::PictureCollection->new(current_user => $system_user);
60     $collection->unlimit;
61     is($collection->count, 2, "Finds two records");
62    
63     # Searches in specific
64     $collection->limit(column => 'id', value => $o->id);
65     is($collection->count, 1, "Finds one record with specific id");
66    
67     # Delete one of them
68     $o->delete;
69     $collection->redo_search;
70     is($collection->count, 0, "Deleted row is gone");
71    
72     # And the other one is still there
73     $collection->unlimit;
74     is($collection->count, 1, "Still one left");
75    

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26