initial release of Asset Report asset allowing reports to be created using asset properties.

This commit is contained in:
khenn 2010-08-10 18:53:22 -05:00
parent cb2bb75d23
commit 22da7c4114
10 changed files with 1405 additions and 0 deletions

View file

@ -0,0 +1,127 @@
# vim:syntax=perl
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------
# This tests the AssetReport asset
#
#
use FindBin;
use strict;
use lib "$FindBin::Bin/../../lib";
use Test::More;
use Test::Deep;
use JSON;
use WebGUI::Test; # Must use this before any other WebGUI modules
use WebGUI::Session;
#----------------------------------------------------------------------------
# Init
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode( $session );
#----------------------------------------------------------------------------
# Tests
plan tests => 3; # Increment this number for each test you create
#----------------------------------------------------------------------------
# Asset Report creation
use_ok( "WebGUI::Asset::Wobject::AssetReport" );
my $ar = $node->addChild( {
className => 'WebGUI::Asset::Wobject::AssetReport',
} );
isa_ok( $ar, 'WebGUI::Asset::Wobject::AssetReport' );
WebGUI::Test->addToCleanup($ar);
my $f = $node->addChild({
className => 'WebGUI::Asset::Wobject::Folder',
title => 'Asset Report Test',
});
WebGUI::Test->addToCleanup($f);
my $sn = $f->addChild({
className => 'WebGUI::Asset::Snippet',
title => 'Shawshank',
});
#----------------------------------------------------------------------------
# Value and variables
my $value = {
isNew => "false",
className => "WebGUI::Asset::Snippet",
startNode => $f->getId,
anySelect => "or",
where => {
1 => {
opSelect => "=",
propSelect => "assetData.title",
valText => "'Shawshank'"
},
},
whereCount => "2",
order => {
1 => {
dirSelect => "desc",
orderSelect => "assetData.title"
},
},
orderCount => "2",
limit => "0",
};
my $settings = JSON->new->encode( $value );
$ar->update( {
settings => $settings,
paginateAfter => 50,
} );
#----------------------------------------------------------------------------
# getTemplateVars
cmp_deeply(
$ar->getTemplateVars,
hash( {
%{ $ar->get },
'settings' => $settings,
'paginateAfter' => 50,
'templateId' => 'sJtcUCfn0CVbKdb4QM61Yw',
'pagination.firstPageUrl' => ignore(),
'pagination.isLastPage' => ignore(),
'pagination.nextPage' => ignore(),
'pagination.previousPageUrl' => ignore(),
'pagination.lastPageText' => ignore(),
'pagination.pageCount' => ignore(),
'pagination.firstPageText' => ignore(),
'pagination.previousPage' => ignore(),
'pagination.pageLoop' => ignore(),
'pagination.lastPage' => ignore(),
'pagination.lastPageUrl' => ignore(),
'pagination.pageNumber' => ignore(),
'pagination.pageList.upTo10' => ignore(),
'pagination.pageCount.isMultiple' => ignore(),
'pagination.pageList' => ignore(),
'pagination.previousPageText' => ignore(),
'pagination.nextPageUrl' => ignore(),
'pagination.pageLoop.upTo10' => ignore(),
'pagination.pageList.upTo20' => ignore(),
'pagination.pageLoop.upTo20' => ignore(),
'pagination.isFirstPage' => ignore(),
'pagination.nextPageText' => ignore(),
'pagination.firstPage' => ignore(),
'asset_loop' => [{ %{ $sn->get } }],
} ),
"getTemplateVars returns complete and correct data structure",
);
#vim:ft=perl

59
t/Form/AssetReportQuery.t Normal file
View file

@ -0,0 +1,59 @@
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use FindBin;
use strict;
use lib "$FindBin::Bin/../lib";
use WebGUI::Test;
use WebGUI::Form;
use WebGUI::Form::AssetReportQuery;
use WebGUI::Session;
use HTML::Form;
use WebGUI::Form_Checking;
#The goal of this test is to verify that Radio form elements work
use Test::More; # increment this value for each test you create
my $session = WebGUI::Test->session;
my $node = WebGUI::Asset->getImportNode( $session );
my $nodeId = $node->getId;
#----------------------------------------------------------------------------
# Tests
plan tests => 1; # Increment this number for each test you create
#----------------------------------------------------------------------------
# put your tests here
$session->request->setup_body({
className => "WebGUI::Asset",
propCount => 2,
orderCount => 2,
startNode => $nodeId,
startNode_display => "Import Node",
anySelect => "or",
propSelect_1 => "asset.createdBy",
opSelect_1 => "=",
valText_1 => "3",
orderSelect_1 => "assetData.title",
dirSelect_1 => "desc",
limit => "25",
});
my $arq = WebGUI::Form::AssetReportQuery->new($session);
my $expected = qq|{"anySelect":"or","className":"WebGUI::Asset","isNew":"false","limit":"25","order":{"1":{"dirSelect":"desc","orderSelect":"assetData.title"}},"orderCount":2,"startNode":"$nodeId","where":{"1":{"opSelect":"=","propSelect":"asset.createdBy","valText":"3"}},"whereCount":2}|;
is($arq->getValue, $expected, 'getValue');
#my $value = $session->form->process("settings","AssetReportQuery");