#!/usr/bin/env perl
use_ok(
'TestApp::Plugin::AppPluginHasModels::Plugin::MyAppPlugin::Model::Color'
);
my
$system_user
= TestApp::Plugin::AppPluginHasModels::CurrentUser->superuser;
ok(
$system_user
,
"Found a system user"
);
my
$o
= TestApp::Plugin::AppPluginHasModels::Plugin::MyAppPlugin::Model::Color->new(
current_user
=>
$system_user
);
my
(
$id
) =
$o
->create();
ok(
$id
,
"Color create returned success"
);
ok(
$o
->id,
"New Color has valid id set"
);
is(
$o
->id,
$id
,
"Create returned the right id"
);
is(
$o
->table,
'myappplugin_colors'
,
'custom plugin table name'
);
$o
->create();
ok(
$o
->id,
"Color create returned another value"
);
isnt(
$o
->id,
$id
,
"And it is different from the previous one"
);
my
$collection
= TestApp::Plugin::AppPluginHasModels::Plugin::MyAppPlugin::Model::ColorCollection->new(
current_user
=>
$system_user
);
$collection
->unlimit;
is(
$collection
->count, 2,
"Finds two records"
);
$collection
->limit(
column
=>
'id'
,
value
=>
$o
->id);
is(
$collection
->count, 1,
"Finds one record with specific id"
);
$o
->
delete
;
$collection
->redo_search;
is(
$collection
->count, 0,
"Deleted row is gone"
);
$collection
->unlimit;
is(
$collection
->count, 1,
"Still one left"
);