| Revision 9 (by dpavlin, 2007/11/29 16:40:10) |
- added capaign to unit
- bootstrap data |
#!/usr/bin/env perl
use warnings;
use strict;
=head1 DESCRIPTION
A basic test harness for the Campaign model.
=cut
use Jifty::Test tests => 12;
# Make sure we can load the model
use_ok('Arh::Model::Campaign');
# Grab a system user
my $system_user = Arh::CurrentUser->superuser;
ok($system_user, "Found a system user");
my $place = Arh::Model::Place->new(current_user => $system_user);
ok( $place->create(
name => 'mjesto iskapanja',
), "Place create returned success");
# Try testing a create
my $o = Arh::Model::Campaign->new(current_user => $system_user);
my ($id) = $o->create(
place => $place,
name => 'prvo iskapanje',
date_from => '2007-11-28',
date_to => '2008-03-15',
);
ok($id, "Campaign create returned success");
ok($o->id, "New Campaign has valid id set");
is($o->id, $id, "Create returned the right id");
# And another
$o->create(
place => $place,
name => 'drugo iskapanje',
date_from => '2000-01-02',
date_to => '2000-01-01',
);
ok($o->id, "Campaign create returned another value");
isnt($o->id, $id, "And it is different from the previous one");
# Searches in general
my $collection = Arh::Model::CampaignCollection->new(current_user => $system_user);
$collection->unlimit;
is($collection->count, 3, "Finds 3 records");
# Searches in specific
$collection->limit(column => 'id', value => $o->id);
is($collection->count, 1, "Finds one record with specific id");
# Delete one of them
$o->delete;
$collection->redo_search;
is($collection->count, 0, "Deleted row is gone");
# And the other one is still there
$collection->unlimit;
is($collection->count, 2, "Still 2 left");