From 0c62ee3666122f832c63e9c04a4f660d0f37764a Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 13 Sep 2008 04:30:32 +0000 Subject: [PATCH] Add more tests, and fix the POD documentation for the new method. --- lib/WebGUI/Workflow/Instance.pm | 6 ++++-- t/Workflow/Instance.t | 20 ++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/WebGUI/Workflow/Instance.pm b/lib/WebGUI/Workflow/Instance.pm index ef440f635..f28a96a39 100644 --- a/lib/WebGUI/Workflow/Instance.pm +++ b/lib/WebGUI/Workflow/Instance.pm @@ -257,7 +257,7 @@ sub getWorkflow { #------------------------------------------------------------------- -=head2 new ( session, instanceId ) +=head2 new ( session, instanceId, [isNew] ) Constructor. @@ -271,7 +271,9 @@ A unique id refering to a workflow instance. =head3 isNew -A boolean, that, if true, sets that the instance is ready to run. +A boolean, that, if true, sets that the instance is new and hasn't been started +yet. This option is really for the L method to use, and should not +be used by developers unless your name starts with JT and ends in Smith. =cut diff --git a/t/Workflow/Instance.t b/t/Workflow/Instance.t index 08ff245bc..a01ea3fc0 100644 --- a/t/Workflow/Instance.t +++ b/t/Workflow/Instance.t @@ -20,13 +20,17 @@ use Test::Deep; use Test::MockObject; my $mockSpectre = Test::MockObject->new(); -$mockSpectre->fake_module('WebGUI::Workflow::Spectre'); -$mockSpectre->fake_new('WebGUI::Workflow::Spectre'); my @spectreGuts = (); +$mockSpectre->fake_module('WebGUI::Workflow::Spectre', +'notify', sub{ + my ($message, $data) = @_; + push @spectreGuts, [$message, $data]; +}); $mockSpectre->mock('notify', sub{ my ($message, $data) = @_; push @spectreGuts, [$message, $data]; }); +$mockSpectre->fake_new('WebGUI::Workflow::Spectre'); use WebGUI::Test; # Must use this before any other WebGUI modules use WebGUI::Session; @@ -42,7 +46,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -plan tests => 12; # Increment this number for each test you create +plan tests => 17; # Increment this number for each test you create #---------------------------------------------------------------------------- # put your tests here @@ -103,10 +107,18 @@ is($instanceWorkflow->getId, $wf->getId, 'getWorkflow, caching check'); ############################################################################### # -# set +# new # ############################################################################### +$otherInstance = WebGUI::Workflow::Instance->new($session, 'neverAWebGUIId'); +is($otherInstance, undef, 'new: non-existant id returns undef'); +$otherInstance = WebGUI::Workflow::Instance->new($session, $instance->getId); +isa_ok($otherInstance, 'WebGUI::Workflow::Instance', 'new with a valid id returns an Instance object'); +is($otherInstance->getId, $instance->getId, 'new returned the correct instance'); +is($otherInstance->{_started}, 1, 'By default, _started = 0'); +$otherInstance = WebGUI::Workflow::Instance->new($session, $instance->getId, 1); +is($otherInstance->{_started}, 0, 'By default, _started = 1'); #---------------------------------------------------------------------------- # Cleanup