Large batch of test fixes, most for newByDynamicClass -> newById

This commit is contained in:
Colin Kuskie 2010-05-13 20:02:26 -07:00
parent c74894321d
commit 5140ece731
17 changed files with 41 additions and 39 deletions

View file

@ -354,7 +354,7 @@ is($approveSubmissions->run, 'done', 'approval done');
$sub1 = $sub1->cloneFromDb; $sub1 = $sub1->cloneFromDb;
is( $sub1->get('submissionStatus'),'created','approval successfull'); is( $sub1->get('submissionStatus'),'created','approval successfull');
my $ticket = WebGUI::Asset->newByDynamicClass($session, $sub1->get('ticketId')); my $ticket = WebGUI::Asset->newById($session, $sub1->get('ticketId'));
WebGUI::Test->assetsToPurge( $ticket ) if $ticket ; WebGUI::Test->assetsToPurge( $ticket ) if $ticket ;
SKIP: { SKIP: {
skip 'no ticket created', 1 unless isa_ok( $ticket, 'WebGUI::Asset::Sku::EMSTicket', 'approval created a ticket'); skip 'no ticket created', 1 unless isa_ok( $ticket, 'WebGUI::Asset::Sku::EMSTicket', 'approval created a ticket');
@ -373,7 +373,7 @@ $cleanupSubmissions->reset;
is($cleanupSubmissions->run, 'complete', 'cleanup complete'); is($cleanupSubmissions->run, 'complete', 'cleanup complete');
is($cleanupSubmissions->run, 'done', 'cleanup done'); is($cleanupSubmissions->run, 'done', 'cleanup done');
$sub2 = WebGUI::Asset->newByDynamicClass($session, $sub2Id); $sub2 = WebGUI::Asset->newById($session, $sub2Id);
is( $sub2, undef, 'submission deleted'); is( $sub2, undef, 'submission deleted');
} # end of workflow skip } # end of workflow skip

View file

@ -120,11 +120,11 @@ SKIP: {
}; };
# Make sure properties were saved # Make sure properties were saved
my $photo = WebGUI::Asset->newByDynamicClass( $session, $album->getFileIds->[0] ); my $photo = WebGUI::Asset->newById( $session, $album->getFileIds->[0] );
cmp_deeply( $photo->get, superhashof( $properties ), "Photo properties saved correctly" ); cmp_deeply( $photo->get, superhashof( $properties ), "Photo properties saved correctly" );
# First File in an album should update assetIdThumbnail # First File in an album should update assetIdThumbnail
my $album = WebGUI::Asset->newByDynamicClass( $session, $album->getId ); my $album = WebGUI::Asset->newById( $session, $album->getId );
is( is(
$album->get('assetIdThumbnail'), $photo->getId, $album->get('assetIdThumbnail'), $photo->getId,
"Album assetIdThumbnail gets set by first File added", "Album assetIdThumbnail gets set by first File added",

View file

@ -84,6 +84,7 @@ my $post = $collab->addChild($props, @addArgs);
$versionTag->commit(); $versionTag->commit();
WebGUI::Test->tagsToRollback($versionTag); WebGUI::Test->tagsToRollback($versionTag);
$post = $post->cloneFromDb;
# Test for a sane object type # Test for a sane object type
isa_ok($post, 'WebGUI::Asset::Post::Thread'); isa_ok($post, 'WebGUI::Asset::Post::Thread');
@ -120,7 +121,7 @@ $post->update({synopsis => $synopsis});
##There is a bug in DBD::mysql with not properly encoding 8-bit characters. Also, HTML::Entities produces ##There is a bug in DBD::mysql with not properly encoding 8-bit characters. Also, HTML::Entities produces
##8-bit utf8 (not strict) characters. So we write a quick test to make sure our patch in splitTag works correctly. ##8-bit utf8 (not strict) characters. So we write a quick test to make sure our patch in splitTag works correctly.
my $dbPost = WebGUI::Asset->newByDynamicClass($session, $post->getId); my $dbPost = WebGUI::Asset->newById($session, $post->getId);
like($dbPost->get('synopsis'), qr/Brandhei.e Neuigkeiten rund um's Klettern f.r euch aus der Region /, 'patch test for DBD::Mysql and HTML::Entities'); like($dbPost->get('synopsis'), qr/Brandhei.e Neuigkeiten rund um's Klettern f.r euch aus der Region /, 'patch test for DBD::Mysql and HTML::Entities');
($synopsis, $content) = $post->getSynopsisAndContent('', q|less than < greater than >|); ($synopsis, $content) = $post->getSynopsisAndContent('', q|less than < greater than >|);

View file

@ -49,6 +49,8 @@ my $props = {
my $thread = $collab->addChild($props, @addArgs); my $thread = $collab->addChild($props, @addArgs);
$versionTag->commit(); $versionTag->commit();
$collab = $collab->cloneFromDb;
$thread = $thread->cloneFromDb;
my $uncommittedThread = $collab->addChild($props, @addArgs); my $uncommittedThread = $collab->addChild($props, @addArgs);

View file

@ -61,6 +61,10 @@ my @threads = (
$_->setSkipNotification for @threads; $_->setSkipNotification for @threads;
$versionTags[-1]->commit; $versionTags[-1]->commit;
WebGUI::Test->addToCleanup($versionTags[-1]);
foreach my $asset(@threads, $collab) {
$asset = $asset->cloneFromDb;
}
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests
@ -133,6 +137,7 @@ $collab->update({
sortOrder => 'desc', sortOrder => 'desc',
}); });
push @versionTags, WebGUI::VersionTag->getWorking( $session ); push @versionTags, WebGUI::VersionTag->getWorking( $session );
WebGUI::Test->addToCleanup($versionTags[-1]);
push @threads, $collab->addChild( { push @threads, $collab->addChild( {
className => 'WebGUI::Asset::Post::Thread', className => 'WebGUI::Asset::Post::Thread',
title => "Abababa", title => "Abababa",
@ -146,12 +151,6 @@ testGetAdjacentThread( "sort by default from asset with version tag", $sort, [ q
$session->scratch->delete($collab->getId.'_sortBy'); $session->scratch->delete($collab->getId.'_sortBy');
$session->scratch->delete($collab->getId.'_sortDir'); $session->scratch->delete($collab->getId.'_sortDir');
#----------------------------------------------------------------------------
# Cleanup
END {
$_->rollback for @versionTags;
}
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# testGetAdjacentThread ( label, sort, order, @threads ) # testGetAdjacentThread ( label, sort, order, @threads )
# Performs two tests for each thread in [order] # Performs two tests for each thread in [order]

View file

@ -62,8 +62,8 @@ my $thread
$versionTag->commit( { timeout => 1_000_000 } ); $versionTag->commit( { timeout => 1_000_000 } );
# Re-load the collab to get the newly committed properties # Re-load the collab to get the newly committed properties
$collab = WebGUI::Asset->newByDynamicClass( $session, $collab->getId ); $collab = WebGUI::Asset->newById( $session, $collab->getId );
$thread = WebGUI::Asset->newByDynamicClass( $session, $thread->getId ); $thread = WebGUI::Asset->newById( $session, $thread->getId );
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests
@ -104,7 +104,7 @@ $maker->prepare( {
# Reply with allowReplies = 0 # Reply with allowReplies = 0
$collab->update({ allowReplies => 0 }); $collab->update({ allowReplies => 0 });
$thread = WebGUI::Asset->newByDynamicClass( $session, $thread->getId ); $thread = WebGUI::Asset->newById( $session, $thread->getId );
$maker->prepare( { $maker->prepare( {
object => $thread, object => $thread,
method => 'canReply', method => 'canReply',

View file

@ -67,9 +67,9 @@ my $post
$versionTag->commit( { timeout => 1_000_000 } ); $versionTag->commit( { timeout => 1_000_000 } );
# Re-load the collab to get the newly committed properties # Re-load the collab to get the newly committed properties
$collab = WebGUI::Asset->newByDynamicClass( $session, $collab->getId ); $collab = WebGUI::Asset->newById( $session, $collab->getId );
$thread = WebGUI::Asset->newByDynamicClass( $session, $thread->getId ); $thread = WebGUI::Asset->newById( $session, $thread->getId );
$post = WebGUI::Asset->newByDynamicClass( $session, $post->getId ); $post = WebGUI::Asset->newById( $session, $post->getId );
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests

View file

@ -302,7 +302,7 @@ my $product6 = $root->addChild({
$newVid = $product6->setCollateral('variantsJSON', 'vid', 'new', { wideChar => qq!on 16\x{201d} hand-crocheted Cord! $newVid = $product6->setCollateral('variantsJSON', 'vid', 'new', { wideChar => qq!on 16\x{201d} hand-crocheted Cord!
, vid => 'new' }); , vid => 'new' });
my $product6a = WebGUI::Asset->newByDynamicClass($session, $product6->getId); my $product6a = WebGUI::Asset->newById($session, $product6->getId);
lives_ok { $product6a->getAllCollateral('variantsJSON', 'vid', $newVid); }, 'Product collateral handles wide-character encodings okay'; lives_ok { $product6a->getAllCollateral('variantsJSON', 'vid', $newVid); }, 'Product collateral handles wide-character encodings okay';
$product6->purge; $product6->purge;

View file

@ -51,7 +51,7 @@ my $collab
$versionTag->commit( { timeout => 1_000_000 } ); $versionTag->commit( { timeout => 1_000_000 } );
# Re-load the collab to get the newly committed properties # Re-load the collab to get the newly committed properties
$collab = WebGUI::Asset->newByDynamicClass( $session, $collab->getId ); $collab = WebGUI::Asset->newById( $session, $collab->getId );
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# Tests # Tests

View file

@ -50,7 +50,7 @@ plan tests => 1; # Increment this number for each test you create
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------
# www_unarchiveAll sets all threads to approved # www_unarchiveAll sets all threads to approved
$collab->www_unarchiveAll; $collab->www_unarchiveAll;
$threads[0] = WebGUI::Asset->newByDynamicClass( $session, $threads[0]->getId ); $threads[0] = WebGUI::Asset->newById( $session, $threads[0]->getId );
is( $threads[0]->get('status'), 'approved', "unarchiveAll sets thread to approved" ); is( $threads[0]->get('status'), 'approved', "unarchiveAll sets thread to approved" );
#vim:ft=perl #vim:ft=perl

View file

@ -62,7 +62,7 @@ my $properties = $gallery->get;
$gallery->purge; $gallery->purge;
is( is(
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef, WebGUI::Asset->newById($session, $properties->{assetId}), undef,
"Gallery no longer able to be instanciated", "Gallery no longer able to be instanciated",
); );

View file

@ -67,7 +67,7 @@ my $properties = $album->get;
$album->purge; $album->purge;
is( is(
WebGUI::Asset->newByDynamicClass($session, $properties->{assetId}), undef, WebGUI::Asset->newById($session, $properties->{assetId}), undef,
"Album no longer able to be instanciated", "Album no longer able to be instanciated",
); );

View file

@ -96,7 +96,7 @@ $maker->prepare({
$maker->run; $maker->run;
is( is(
WebGUI::Asset->newByDynamicClass( $session, $assetId ), WebGUI::Asset->newById( $session, $assetId ),
undef, undef,
"GalleryAlbum cannot be instanciated after www_deleteConfirm", "GalleryAlbum cannot be instanciated after www_deleteConfirm",
); );

View file

@ -109,7 +109,7 @@ $mech->content_contains(
); );
# Creates the album with the appropriate properties # Creates the album with the appropriate properties
my $album = WebGUI::Asset->newByDynamicClass( $session, $gallery->getAlbumIds->[0] ); my $album = WebGUI::Asset->newById( $session, $gallery->getAlbumIds->[0] );
cmp_deeply( $properties, subhashof( $album->get ), "Properties from edit form are set correctly" ); cmp_deeply( $properties, subhashof( $album->get ), "Properties from edit form are set correctly" );
#---------------------------------------------------------------------------- #----------------------------------------------------------------------------

View file

@ -622,14 +622,14 @@ TODO: {
################################################################ ################################################################
# #
# newByDynamicClass # newById
# #
################################################################ ################################################################
my $newFixTitleAsset = WebGUI::Asset->newByDynamicClass($session, $fixTitleAsset->getId); my $newFixTitleAsset = WebGUI::Asset->newById($session, $fixTitleAsset->getId);
isnt($newFixTitleAsset, undef, 'newByDynamicClass did not fail'); isnt($newFixTitleAsset, undef, 'newById did not fail');
isa_ok($newFixTitleAsset, 'WebGUI::Asset', 'newByDynamicClass: able to look up an existing asset by id'); isa_ok($newFixTitleAsset, 'WebGUI::Asset', 'newById: able to look up an existing asset by id');
cmp_deeply($newFixTitleAsset->{_properties}, $fixTitleAsset->{_properties}, 'newByDynamicClass created a duplicate asset'); cmp_deeply($newFixTitleAsset->{_properties}, $fixTitleAsset->{_properties}, 'newById created a duplicate asset');
################################################################ ################################################################
# #

View file

@ -107,7 +107,7 @@ is($userActivity->get('groupId'), $activityGroup->getId, 'group in Workflow Acti
$assetGroup->delete; $assetGroup->delete;
my $newSnippet1 = WebGUI::Asset->newByDynamicClass($session, $snippet1->getId); my $newSnippet1 = WebGUI::Asset->newById($session, $snippet1->getId);
cmp_deeply( cmp_deeply(
$newSnippet1->get, $newSnippet1->get,
@ -118,7 +118,7 @@ cmp_deeply(
'groupIdEdit updated on test snippet' 'groupIdEdit updated on test snippet'
); );
my $newSnippet2 = WebGUI::Asset->newByDynamicClass($session, $snippet2->getId); my $newSnippet2 = WebGUI::Asset->newById($session, $snippet2->getId);
cmp_deeply( cmp_deeply(
$newSnippet2->get, $newSnippet2->get,
@ -129,7 +129,7 @@ cmp_deeply(
'other snippet not touched' 'other snippet not touched'
); );
my $newSnippet3 = WebGUI::Asset->newByDynamicClass($session, $snippet3->getId); my $newSnippet3 = WebGUI::Asset->newById($session, $snippet3->getId);
cmp_deeply( cmp_deeply(
$newSnippet3->get, $newSnippet3->get,
@ -140,7 +140,7 @@ cmp_deeply(
'multiple fields updated' 'multiple fields updated'
); );
my $newGallery1 = WebGUI::Asset->newByDynamicClass($session, $gallery1->getId); my $newGallery1 = WebGUI::Asset->newById($session, $gallery1->getId);
cmp_deeply( cmp_deeply(
$newGallery1->get, $newGallery1->get,

View file

@ -247,13 +247,13 @@ sub _mockAssetInits {
# } # }
# goto $original_new; # goto $original_new;
# }; # };
my $original_newByDynamicClass = \&WebGUI::Asset::newById; my $original_newById = \&WebGUI::Asset::newById;
*WebGUI::Asset::newById = sub { *WebGUI::Asset::newById = sub {
my ($class, $session, $assetId, $revisionDate) = @_; my ($class, $session, $assetId, $revisionDate) = @_;
if ($mockedAssetIds{$assetId}) { if ($mockedAssetIds{$assetId}) {
return $mockedAssetIds{$assetId}; return $mockedAssetIds{$assetId};
} }
goto $original_newByDynamicClass; goto $original_newById;
}; };
my $original_newPending = \&WebGUI::Asset::newPending; my $original_newPending = \&WebGUI::Asset::newPending;
*WebGUI::Asset::newPending = sub { *WebGUI::Asset::newPending = sub {