cope with extra fields returned and fix apparent errors in the t/Admin.t tests to make them pass

This commit is contained in:
Scott Walters 2011-05-03 18:11:56 -04:00
parent 74b8e36552
commit d6ad0852e8

View file

@ -86,8 +86,8 @@ $mech->session->user({ userId => '3' });
$mech->get_ok( '/?op=admin;method=processAssetHelper;helperId=cut;assetId=' . $snip->getId ); $mech->get_ok( '/?op=admin;method=processAssetHelper;helperId=cut;assetId=' . $snip->getId );
cmp_deeply( cmp_deeply(
map( { delete $_->{forkId}; $_ } JSON->new->decode( $mech->content )), JSON->new->decode( $mech->content ),
map( { delete $_->{forkId}; $_ } WebGUI::AssetHelper::Cut->new( id => 'cut', session => $session, asset => $snip )->process( )), map( { $_->{forkId} = ignore(); $_ } WebGUI::AssetHelper::Cut->new( id => 'cut', session => $session, asset => $snip )->process( )),
'www_processAssetHelper', 'www_processAssetHelper',
); );
@ -118,8 +118,8 @@ $snip->cut;
$mech->get_ok( '/?op=admin;method=getClipboard' ); $mech->get_ok( '/?op=admin;method=getClipboard' );
$output = $mech->content; $output = $mech->content;
cmp_deeply( cmp_deeply(
JSON->new->decode( $output ), JSON->new->decode( $output )->[0],
superbagof({ superhashof({
assetId => $snip->getId, assetId => $snip->getId,
url => $snip->getUrl, url => $snip->getUrl,
title => $snip->menuTitle, title => $snip->menuTitle,
@ -178,12 +178,12 @@ $mech->get_ok( '/?op=admin;method=getTreeData;assetUrl=' . $import->url );
$output = $mech->content; $output = $mech->content;
cmp_deeply( cmp_deeply(
JSON->new->decode( $output ), JSON->new->decode( $output ),
{ superhashof({
totalAssets => $import->getChildCount, totalAssets => $import->getChildCount,
sort => ignore(), sort => ignore(),
dir => ignore(), dir => ignore(),
assets => [ assets => [
map { { map { superhashof({
assetId => $_->getId, assetId => $_->getId,
url => $_->getUrl, url => $_->getUrl,
lineage => $_->lineage, lineage => $_->lineage,
@ -195,25 +195,26 @@ cmp_deeply(
canEdit => $_->canEdit && $_->canEditIfLocked, canEdit => $_->canEdit && $_->canEditIfLocked,
helpers => $_->getHelpers, helpers => $_->getHelpers,
icon => $_->getIcon("small"), icon => $_->getIcon("small"),
className => $_->getName, className => $_->get('className'),
} } @{ $import->getLineage( ['children'], { returnObjects => 1, maxAssets => 25 } ) } }) } @{ $import->getLineage( ['children'], { returnObjects => 1, maxAssets => 25 } ) }
], ],
currentAsset => { currentAsset => superhashof({
assetId => $import->getId, assetId => $import->getId,
url => $import->getUrl, url => $import->getUrl,
title => $import->getTitle, title => $import->get('menuTitle'), # "Import" vs "Import Node"
icon => $import->getIcon("small"), icon => $import->getIcon("small"),
helpers => $import->getHelpers, helpers => $import->getHelpers,
}, }),
crumbtrail => [ crumbtrail => [
map { { title => $_->getTitle, url => $_->getUrl } } map { superhashof({ title => $_->getTitle, url => $_->getUrl }) }
@{ $import->getLineage( ['ancestors'], { returnObjects => 1 } ) } @{ $import->getLineage( ['ancestors'], { returnObjects => 1 } ) }
], ],
}, }),
'www_getTreeData', 'www_getTreeData',
); );
# www_searchAssets # www_searchAssets
$mech->get_ok( '/?op=admin;method=searchAssets;query=aReallyLongWordToGetIndexed' ); $mech->get_ok( '/?op=admin;method=searchAssets;query=aReallyLongWordToGetIndexed' );
$output = $mech->content; $output = $mech->content;
cmp_deeply( cmp_deeply(
@ -235,7 +236,9 @@ cmp_deeply(
canEdit => $snip->canEdit && $snip->canEditIfLocked, canEdit => $snip->canEdit && $snip->canEditIfLocked,
helpers => $snip->getHelpers, helpers => $snip->getHelpers,
icon => $snip->getIcon('small'), icon => $snip->getIcon('small'),
className => $snip->getName, className => $snip->get('className'), # getName is 'Snippet', className is 'WebGUI::Asset::Snippet'
revisions => ignore(),
type => ignore(),
} }
], ],
}, },