Add more tests, and fix the POD documentation for the new method.

This commit is contained in:
Colin Kuskie 2008-09-13 04:30:32 +00:00
parent d43d06ea1a
commit 0c62ee3666
2 changed files with 20 additions and 6 deletions

View file

@ -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<create> method to use, and should not
be used by developers unless your name starts with JT and ends in Smith.
=cut

View file

@ -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