/[A3C]/t/00-model-StrixInstance.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-StrixInstance.t

Parent Directory Parent Directory | Revision Log Revision Log


Revision 191 - (hide annotations)
Tue Jun 17 14:28:10 2008 UTC (14 years ago) by dpavlin
File MIME type: application/x-troff
File size: 1773 byte(s)
added has_sites to StrixInstace which returns collection of all StrixSite for that instance
1 dpavlin 139 #!/usr/bin/env perl
2     use warnings;
3     use strict;
4    
5     =head1 DESCRIPTION
6    
7 dpavlin 174 A basic test harness for the StrixInstance model.
8 dpavlin 139
9     =cut
10    
11 dpavlin 191 use Jifty::Test tests => 14;
12 dpavlin 139
13     # Make sure we can load the model
14 dpavlin 174 use_ok('A3C::Model::StrixInstance');
15 dpavlin 139
16     # Grab a system user
17     my $system_user = A3C::CurrentUser->superuser;
18     ok($system_user, "Found a system user");
19    
20     # Try testing a create
21 dpavlin 174 my $o = A3C::Model::StrixInstance->new(current_user => $system_user);
22     my ($id) = $o->create( instance => 'foo', _dbserver => 'localhost', _dbname => 'foo' );
23     ok($id, "StrixInstance create returned success");
24     ok($o->id, "New StrixInstance has valid id set");
25 dpavlin 139 is($o->id, $id, "Create returned the right id");
26    
27     # And another
28 dpavlin 174 $o->create( instance => 'bar', _dbserver => 'localhost', _dbname => 'bar' );
29     ok($o->id, "StrixInstance create returned another value");
30 dpavlin 139 isnt($o->id, $id, "And it is different from the previous one");
31    
32     # Searches in general
33 dpavlin 174 my $collection = A3C::Model::StrixInstanceCollection->new(current_user => $system_user);
34 dpavlin 139 $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    
50 dpavlin 191 my $site = A3C::Model::StrixSite->new(current_user => $system_user);
51     ok($site->create(
52     'instance' => 'bar',
53     'naziv' => "Naziv 42",
54     'admin_mail' => "Admin mail",
55     'id' => 42,
56     ), 'site');
57     ok($site->create(
58     'instance' => 'bar',
59     'naziv' => "Naziv 43",
60     'admin_mail' => "Admin mail",
61     'id' => 43,
62     ), 'site');
63    
64     is( $o->has_sites->count, 2 ,'has_sites' );

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26