Updating Workflow/Instance.pm tests

This commit is contained in:
Colin Kuskie 2008-09-11 20:04:39 +00:00
parent d94fb4460b
commit 6c50ed9851

View file

@ -36,7 +36,12 @@ plan tests => 6; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
# create a workflow
###############################################################################3
#
# create a workflow instance
#
###############################################################################3
my $wf = WebGUI::Workflow->create(
$session,
{
@ -45,32 +50,27 @@ my $wf = WebGUI::Workflow->create(
type => 'None'
}
);
ok(defined $wf, 'can create workflow');
isa_ok($wf, 'WebGUI::Workflow', 'workflow');
my $wfId = $wf->getId;
ok(defined $wfId, 'workflow has an ID');
ok(defined WebGUI::Workflow->new($session, $wfId), 'workflow can be retrieved');
isa_ok($wf, 'WebGUI::Workflow', 'workflow created for test');
# create an instance of $wfId
my $properties = {
#workflowId=>$session->setting->get("runOnAdminCreateUser"),
workflowId=>$wfId,
workflowId=>$wf->getId,
methodName=>"new",
className=>"None",
parameters=>'encode me',
priority=>1
};
my $dateUpdated = time();
my $instance = WebGUI::Workflow::Instance->create($session, $properties);
isa_ok($instance, 'WebGUI::Workflow::Instance', 'workflow instance');
# test JSON encoding
my $encoded_text = JSON->new->pretty->encode({parameters => $properties->{parameters}});
ok($encoded_text, 'received encoded text from JSON');
isa_ok($instance, 'WebGUI::Workflow::Instance', 'create: workflow instance');
ok($session->getId, 'getId returns something');
ok($session->id->valid($instance->getId), 'New workflow instance has a valid ID');
is($instance->get('priority'), 2, 'Default instance priority is 2');
cmp_ok(abs ($instance->get('lastUpdate')-$dateUpdated), '<=', 3, 'Date updated field set correctly when instance is created');
diag $instance->get('lastStatus');
#----------------------------------------------------------------------------
# Cleanup
END {
$wf->delete;
$wf->delete; ##Deleting a Workflow deletes its instances, too.
}