From 6c50ed985179d621678d825946661b6232a8e326 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Thu, 11 Sep 2008 20:04:39 +0000 Subject: [PATCH] Updating Workflow/Instance.pm tests --- t/Workflow/Instance.t | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/t/Workflow/Instance.t b/t/Workflow/Instance.t index 3f7bb8e13..88213d6f6 100644 --- a/t/Workflow/Instance.t +++ b/t/Workflow/Instance.t @@ -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. }