mock asset test package
This commit is contained in:
parent
dfa1a3d7cb
commit
49be76247e
11 changed files with 213 additions and 188 deletions
|
|
@ -20,6 +20,7 @@ use Test::More; # increment this value for each test you create
|
|||
use Test::Deep;
|
||||
use Test::MockObject;
|
||||
use Test::MockObject::Extends;
|
||||
use WebGUI::Test::MockAsset;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -35,15 +36,13 @@ $macroMock->set_true('process');
|
|||
|
||||
my $templateId = 'PICKLANGUAGE_TEMPLATE_';
|
||||
|
||||
my $templateMock = Test::MockObject->new({});
|
||||
$templateMock->set_isa('WebGUI::Asset::Template');
|
||||
$templateMock->set_always('getId', $templateId);
|
||||
my $templateMock = WebGUI::Test::MockAsset->new('WebGUI::Asset::Template');
|
||||
$templateMock->mock_id($templateId);
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||
|
||||
cmp_deeply(
|
||||
|
|
@ -62,19 +61,16 @@ $templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
|||
},
|
||||
'some template variables are created'
|
||||
);
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
#test when template Id is left empty
|
||||
|
||||
$templateId = '';
|
||||
my $templateNoId = $templateMock->mock('process','');
|
||||
$templateMock->set_always('getId', $templateId);
|
||||
$templateMock->mock_id($templateId);
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
{
|
||||
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||
|
||||
cmp_deeply(
|
||||
|
|
@ -93,19 +89,9 @@ $templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
|||
},
|
||||
'some template variables are created, when no templateId is passed on with the macro'
|
||||
);
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
|
||||
#{
|
||||
# WebGUI::Test->mockAssetId($templateNoId, $templateMock);
|
||||
# $error = WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||
#
|
||||
# is($error,'Could not instanciate template with id []',"Empty template Id should return error");
|
||||
#
|
||||
# WebGUI::Test->unmockAssetId($templateNoId);
|
||||
#}
|
||||
|
||||
#test for an incorrect template Id
|
||||
|
||||
$templateId = '1234567890123456789012';
|
||||
|
|
@ -116,10 +102,8 @@ my $error;
|
|||
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateWrongId, $templateMock);
|
||||
$error = WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||
|
||||
is($error,'Could not instanciate template with id [1234567890123456789012]',"Template from the wrong namespace should not be initiated");
|
||||
WebGUI::Test->unmockAssetId($templateWrongId);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue