Ready for 7.10.29 development.
This commit is contained in:
commit
c806f99b7b
4236 changed files with 1217679 additions and 0 deletions
97
t/Asset/Wobject/Search/addRecord.t
Normal file
97
t/Asset/Wobject/Search/addRecord.t
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 JSON qw/from_json/;
|
||||
use lib "$FindBin::Bin/../../../lib";
|
||||
|
||||
##The goal of this test is to test the searching for and returning data about
|
||||
##records created with WebGUI::Search::Index::addRecord;
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 6; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use WebGUI::Asset::Wobject::Search;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
|
||||
# Do our work in the import node
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
|
||||
my $default = WebGUI::Asset->getDefault($session);
|
||||
my $importArticle = $node->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
description => 'rockhound',
|
||||
});
|
||||
|
||||
my $templateId = 'SEARCH_ASSET_TEMPLATE_';
|
||||
my $templateMock = Test::MockObject->new({});
|
||||
$templateMock->set_isa('WebGUI::Asset::Template');
|
||||
$templateMock->set_always('getId', $templateId);
|
||||
$templateMock->set_always('prepare', 1);
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
my $defaultArticle = $default->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
description => 'shawshank prison',
|
||||
url => 'introduction'
|
||||
});
|
||||
my $search = $default->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Search',
|
||||
searchRoot => $default->getId,
|
||||
templateId => $templateId,
|
||||
});
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
$tag->commit;
|
||||
WebGUI::Test->addToCleanup($tag);
|
||||
my $indexer = WebGUI::Search::Index->new($defaultArticle);
|
||||
$indexer->addRecord(url => 'brochure', keywords => 'roomy spacious prison');
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$search->prepareView();
|
||||
$session->request->setup_body({doit => 1, keywords => 'shawshank'});
|
||||
$search->view();
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
is scalar @{ $templateVars->{result_set} }, 1, 'search for shawshank, returns 1 record';
|
||||
is $templateVars->{result_set}->[0]->{url}, 'introduction', '... url is correct';
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$search->prepareView();
|
||||
$session->request->setup_body({doit => 1, keywords => 'prison'});
|
||||
$search->view();
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
is scalar @{ $templateVars->{result_set} }, 2, 'search for prison, returns 2 records';
|
||||
cmp_bag(
|
||||
[ map { $_->{url} } @{ $templateVars->{result_set} } ],
|
||||
[qw/ introduction brochure/ ],
|
||||
'... urls are correct'
|
||||
);
|
||||
cmp_bag(
|
||||
[ map { $_->{groupIdView} } @{ $templateVars->{result_set} } ],
|
||||
[ 7, 7 ],
|
||||
' groupIdViews are correct (2nd record inherits from the parent)'
|
||||
);
|
||||
cmp_bag(
|
||||
[ map { $_->{title_nohighlight} } @{ $templateVars->{result_set} } ],
|
||||
[ ($defaultArticle->get('title'))x2 ],
|
||||
' titles are correct (2nd record inherits from the parent)'
|
||||
);
|
||||
|
||||
75
t/Asset/Wobject/Search/searchroot.t
Normal file
75
t/Asset/Wobject/Search/searchroot.t
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 JSON qw/from_json/;
|
||||
use lib "$FindBin::Bin/../../../lib";
|
||||
|
||||
##The goal of this test is to test the creation of Search Wobjects.
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 2; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use WebGUI::Asset::Wobject::Search;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
$session->user({userId => 3});
|
||||
|
||||
# Do our work in the import node
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
|
||||
my $default = WebGUI::Asset->getDefault($session);
|
||||
my $importArticle = $node->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
description => 'rockhound',
|
||||
});
|
||||
my $defaultArticle = $default->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Article',
|
||||
description => 'rockhound',
|
||||
});
|
||||
my $template = $node->addChild({
|
||||
className => 'WebGUI::Asset::Template',
|
||||
parser => 'WebGUI::Asset::Template::HTMLTemplate',
|
||||
template => qq{[<tmpl_loop result_set>"<tmpl_var assetId>"<tmpl_unless __LAST__>,</tmpl_unless></tmpl_loop>]},
|
||||
});
|
||||
my $search = $default->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Search',
|
||||
searchRoot => $default->getId,
|
||||
templateId => $template->getId,
|
||||
});
|
||||
my $tag2 = WebGUI::VersionTag->getWorking($session);
|
||||
$tag2->commit;
|
||||
|
||||
$search->prepareView();
|
||||
$session->request->setup_body({doit => 1, keywords => 'rockhound'});
|
||||
my $json = $search->view();
|
||||
my $assetIds = from_json($json);
|
||||
cmp_deeply(
|
||||
$assetIds,
|
||||
[ $defaultArticle->getId ],
|
||||
'search with no override returns asset from default asset'
|
||||
);
|
||||
|
||||
$session->request->setup_body({doit => 1, keywords => 'rockhound', searchroot => $node->getId,});
|
||||
$json = $search->view();
|
||||
$assetIds = from_json($json);
|
||||
cmp_deeply(
|
||||
$assetIds,
|
||||
[ $importArticle->getId ],
|
||||
'search with override returns asset from import node'
|
||||
);
|
||||
|
||||
|
||||
$session->request->setup_body({});
|
||||
$tag2->rollback;
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue