add spectre mocking and getWorkflow tests
This commit is contained in:
parent
afff4c4844
commit
f4c328d555
1 changed files with 26 additions and 3 deletions
|
|
@ -16,12 +16,23 @@ use FindBin;
|
||||||
use strict;
|
use strict;
|
||||||
use lib "$FindBin::Bin/../lib";
|
use lib "$FindBin::Bin/../lib";
|
||||||
use Test::More;
|
use Test::More;
|
||||||
|
use Test::Deep;
|
||||||
|
|
||||||
|
use Test::MockObject;
|
||||||
|
my $mockSpectre = Test::MockObject->new();
|
||||||
|
$mockSpectre->fake_module('WebGUI::Workflow::Spectre');
|
||||||
|
$mockSpectre->fake_new();
|
||||||
|
my @spectreGuts = ();
|
||||||
|
$mockSpectre->mock('notify', sub{
|
||||||
|
my ($message, $data) = @_;
|
||||||
|
push @spectreGuts, [$message, $data];
|
||||||
|
});
|
||||||
|
|
||||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Workflow;
|
use WebGUI::Workflow;
|
||||||
use WebGUI::Workflow::Instance;
|
use WebGUI::Workflow::Instance;
|
||||||
use JSON;
|
use JSON;
|
||||||
use Data::Dumper;
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Init
|
# Init
|
||||||
|
|
@ -31,7 +42,7 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
plan tests => 6; # Increment this number for each test you create
|
plan tests => 8; # Increment this number for each test you create
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# put your tests here
|
# put your tests here
|
||||||
|
|
@ -66,7 +77,19 @@ ok($session->getId, 'getId returns something');
|
||||||
ok($session->id->valid($instance->getId), 'New workflow instance has a valid ID');
|
ok($session->id->valid($instance->getId), 'New workflow instance has a valid ID');
|
||||||
is($instance->get('priority'), 2, 'Default instance priority is 2');
|
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');
|
cmp_ok(abs ($instance->get('lastUpdate')-$dateUpdated), '<=', 3, 'Date updated field set correctly when instance is created');
|
||||||
diag $instance->get('lastStatus');
|
|
||||||
|
##Singleton checks
|
||||||
|
|
||||||
|
###############################################################################3
|
||||||
|
#
|
||||||
|
# getWorkflow
|
||||||
|
#
|
||||||
|
###############################################################################3
|
||||||
|
|
||||||
|
my $instanceWorkflow = $instance->getWorkflow;
|
||||||
|
is($instanceWorkflow->getId, $wf->getId, 'getWorkflow returns a copy of the workflow for the instance');
|
||||||
|
is($instanceWorkflow->getId, $wf->getId, 'getWorkflow, caching check');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue