--- trunk/t/00-model-Page.t 2006/12/01 23:48:06 1 +++ trunk/t/00-model-Query.t 2006/12/03 14:01:53 15 @@ -2,37 +2,40 @@ use warnings; use strict; +use blib; + =head1 DESCRIPTION -A basic test harness for the Page model. +A basic test harness for the Query model. =cut use Jifty::Test tests => 11; +my $b = 2; # Make sure we can load the model -use_ok('SQLSession::Model::Page'); +use_ok('SQLSession::Model::Query'); # Grab a system user my $system_user = SQLSession::CurrentUser->superuser; ok($system_user, "Found a system user"); # Try testing a create -my $o = SQLSession::Model::Page->new(current_user => $system_user); -my ($id) = $o->create(); -ok($id, "Page create returned success"); -ok($o->id, "New Page has valid id set"); +my $o = SQLSession::Model::Query->new(current_user => $system_user); +my ($id) = $o->create( name => 'foo', sql_query => 'bar', on_database => 1 ); +ok($id, "Query create returned success"); +ok($o->id, "New Query has valid id set"); is($o->id, $id, "Create returned the right id"); # And another -$o->create(); -ok($o->id, "Page create returned another value"); +$o->create( name => 'baz', sql_query => 'baz', on_database => 1 ); +ok($o->id, "Query create returned another value"); isnt($o->id, $id, "And it is different from the previous one"); # Searches in general -my $collection = SQLSession::Model::PageCollection->new(current_user => $system_user); +my $collection = SQLSession::Model::QueryCollection->new(current_user => $system_user); $collection->unlimit; -is($collection->count, 2, "Finds two records"); +is($collection->count, $b + 2, "Finds two records"); # Searches in specific $collection->limit(column => 'id', value => $o->id); @@ -45,5 +48,5 @@ # And the other one is still there $collection->unlimit; -is($collection->count, 1, "Still one left"); +is($collection->count, $b + 1, "Still one left");