prevent Workflow from trying to run an activity if it didn't get an object
This commit is contained in:
parent
f6be0746f3
commit
9f2db435ba
2 changed files with 45 additions and 3 deletions
|
|
@ -395,8 +395,8 @@ sub getObject {
|
|||
push @params, $self->session;
|
||||
}
|
||||
push @params, $self->get("parameters");
|
||||
WebGUI::Pluggable::load($class);
|
||||
return $self->{_object} = $class->$method(@params);
|
||||
my $object = WebGUI::Pluggable::instanciate( $class, $method, \@params );
|
||||
return $self->{_object} = $object;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ use strict;
|
|||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Test::Exception;
|
||||
use Scope::Guard;
|
||||
|
||||
use Test::MockObject;
|
||||
my $mockSpectre = Test::MockObject->new();
|
||||
|
|
@ -46,7 +48,7 @@ my $session = WebGUI::Test->session;
|
|||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 32; # Increment this number for each test you create
|
||||
plan tests => 34; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# put your tests here
|
||||
|
|
@ -181,6 +183,46 @@ my $wf2 = WebGUI::Workflow->create(
|
|||
my $wf2Instance = WebGUI::Workflow::Instance->create($session, {workflowId => $wf2->getId});
|
||||
cmp_deeply($wf2Instance->get('parameters'), {}, 'get returns {} for parameters when there are no parameters stored');
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
# getObject
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
{
|
||||
my $return;
|
||||
Test::MockObject->fake_module('WebGUI::Test::Workflow::Instance::TestObject',
|
||||
new => sub {
|
||||
return $return;
|
||||
},
|
||||
);
|
||||
|
||||
my $wf3 = WebGUI::Workflow->create(
|
||||
$session,
|
||||
{
|
||||
title => 'WebGUI::Workflow::Instance Test',
|
||||
description => 'getObject test',
|
||||
type => 'WebGUI::Test::Workflow::Instance::TestObject',
|
||||
}
|
||||
);
|
||||
my $wf3guard = Scope::Guard->new(sub {
|
||||
$wf3->delete;
|
||||
});
|
||||
|
||||
my $wf3Instance = WebGUI::Workflow::Instance->create( $session, {
|
||||
workflowId => $wf3->getId,
|
||||
className => 'WebGUI::Test::Workflow::Instance::TestObject',
|
||||
methodName => 'new',
|
||||
});
|
||||
|
||||
dies_ok { $wf3Instance->getObject } 'getObject throws when instanciation returns undef';
|
||||
|
||||
$return = Test::MockObject->new;
|
||||
lives_and {
|
||||
is $wf3Instance->getObject, $return;
|
||||
} 'getObject is able to retrieve correct object';
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue