mock asset test package
This commit is contained in:
parent
dfa1a3d7cb
commit
49be76247e
11 changed files with 213 additions and 188 deletions
|
|
@ -22,6 +22,7 @@ BEGIN {
|
|||
}
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Test::MockAsset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Image;
|
||||
use WebGUI::Storage;
|
||||
|
|
@ -53,6 +54,7 @@ cmp_bag($storage->getFiles, ['blue.png'], 'Only 1 file in storage with correct n
|
|||
|
||||
$session->user({userId=>3});
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
WebGUI::Test->addToCleanup($versionTag);
|
||||
$versionTag->set({name=>"Image Asset test"});
|
||||
my $properties = {
|
||||
# '1234567890123456789012'
|
||||
|
|
@ -98,11 +100,12 @@ isnt($sth->hashRef, undef, 'Annotations column is defined');
|
|||
|
||||
#------------------------------------------------------------------------------
|
||||
# Template variables
|
||||
{
|
||||
|
||||
my $templateId = 'FILE_IMAGE_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);
|
||||
$templateMock->set_true('prepare');
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; return ''; } );
|
||||
|
|
@ -112,17 +115,13 @@ $asset->update({
|
|||
templateId => $templateId,
|
||||
});
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$asset->prepareView();
|
||||
$asset->view();
|
||||
like($templateVars->{parameters}, qr{ id="[^"]{22}"}, 'id in parameters is quoted');
|
||||
like($templateVars->{parameters}, qr{alt="alternate"}, 'original parameters included');
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
$versionTag->commit;
|
||||
WebGUI::Test->addToCleanup($versionTag);
|
||||
|
||||
done_testing();
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use strict;
|
|||
use lib "$FindBin::Bin/../../lib";
|
||||
use Test::More;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Test::MockAsset;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::User;
|
||||
use WebGUI::Group;
|
||||
|
|
@ -181,14 +182,12 @@ my $printRemainingTicketsTemplateId = $ems->get('printRemainingTicketsTemplateId
|
|||
is($printRemainingTicketsTemplateId, "hreA_bgxiTX-EzWCSZCZJw", 'Default print remaining tickets template id ok');
|
||||
|
||||
#Make sure printRemainingTickets template returns the right data
|
||||
my $templateMock = Test::MockObject->new({});
|
||||
$templateMock->set_isa('WebGUI::Asset::Template');
|
||||
$templateMock->set_always('getId', $printRemainingTicketsTemplateId);
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($printRemainingTicketsTemplateId, $templateMock);
|
||||
my $templateMock = WebGUI::Test::MockAsset->new('WebGUI::Asset::Template');
|
||||
$templateMock->mock_id($printRemainingTicketsTemplateId);
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
$ems->www_printRemainingTickets();
|
||||
|
||||
my $ticket1 = {
|
||||
|
|
@ -351,8 +350,6 @@ $templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
|||
},
|
||||
"www_printRemainingTickets: template variables valid"
|
||||
);
|
||||
|
||||
WebGUI::Test->unmockAssetId($printRemainingTicketsTemplateId);
|
||||
}
|
||||
|
||||
#Make sure permissions work on pages
|
||||
|
|
|
|||
|
|
@ -17,15 +17,15 @@ use Test::MockObject::Extends;
|
|||
##The goal of this test is to test the creation of Article Wobjects.
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Test::MockAsset;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 8; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
|
||||
my $templateId = 'INOUTBOARD_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('prepare', sub { } );
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
|
@ -57,7 +57,6 @@ my $board = $node->addChild({
|
|||
inOutTemplateId => $templateId,
|
||||
});
|
||||
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$board->prepareView();
|
||||
|
||||
# Test for a sane object type
|
||||
|
|
@ -151,7 +150,6 @@ cmp_bag(
|
|||
'view: returns one entry for each user, entry is correct for user with status'
|
||||
);
|
||||
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
################################################################
|
||||
#
|
||||
# purge
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use lib "$FindBin::Bin/../../lib";
|
|||
##The goal of this test is to test the creation of Search Wobjects.
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Test::MockAsset;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 11; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
|
@ -49,9 +50,8 @@ foreach my $newSetting (keys %{$newSearchSettings}) {
|
|||
#1234567890123456789012#
|
||||
my $templateId = '_FAUX_SEARCH_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);
|
||||
$templateMock->set_true('prepare');
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
|
@ -68,7 +68,6 @@ $search->update({
|
|||
doit => 1,
|
||||
keywords => 'building + applications',
|
||||
});
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$search->prepareView;
|
||||
eval { $search->view; };
|
||||
ok(! $@, 'view did now error out on standalone regexp wildcard')
|
||||
|
|
@ -85,7 +84,6 @@ $search->update({
|
|||
eval { $search->view; };
|
||||
ok(! $@, 'view did now error out on prefix regexp wildcard')
|
||||
or diag $@;
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
$session->request->setup_body({});
|
||||
|
||||
}
|
||||
|
|
@ -115,7 +113,6 @@ $search->update({
|
|||
doit => 1,
|
||||
keywords => 'shale',
|
||||
});
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$search->prepareView;
|
||||
$search->view;
|
||||
$search->update({useContainers => 0});
|
||||
|
|
@ -124,7 +121,6 @@ $search->update({
|
|||
$search->view;
|
||||
like $templateVars->{result_set}->[0]->{url}, qr{\?pn=\d}, 'search returns paginated URL for a Thread when useContainers=1';
|
||||
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
$session->request->setup_body({});
|
||||
$search->update({useContainers => 0});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use lib "$FindBin::Bin/../../lib";
|
|||
##The goal of this test is to test the creation of Thingy Wobjects.
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Test::MockAsset;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 28; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
|
@ -28,9 +29,8 @@ my $session = WebGUI::Test->session;
|
|||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
my $templateId = 'THING_EDIT_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]; } );
|
||||
|
||||
|
|
@ -318,7 +318,6 @@ ok( ! $thingy->hasEnteredMaxPerUser($otherThingId), 'hasEnteredMaxPerUser: retur
|
|||
my @edit_thing_form_fields = qw/form_start form_end form_submit field_loop/;
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$thingy->editThingData($otherThingId);
|
||||
my %miniVars;
|
||||
@miniVars{@edit_thing_form_fields} = @{ $templateVars }{ @edit_thing_form_fields };
|
||||
|
|
@ -338,7 +337,6 @@ $thingy->editThingDataSave($otherThingId, 'new', {"field_".$otherFieldId => 'oth
|
|||
ok( $thingy->hasEnteredMaxPerUser($otherThingId), 'hasEnteredMaxPerUser returns true with one row entered, and maxEntriesPerUser=1');
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$thingy->editThingData($otherThingId);
|
||||
my %miniVars;
|
||||
@miniVars{@edit_thing_form_fields} = @{ $templateVars }{ @edit_thing_form_fields };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue