add more classy tests

This commit is contained in:
Doug Bell 2010-11-09 16:50:08 -06:00
parent 5cab2c1639
commit 17c540f041

View file

@ -461,21 +461,27 @@ sub t_10_addRevision : Tests {
my $newRevision = $asset->addRevision( my $newRevision = $asset->addRevision(
{ title => "Newly Revised Title" }, { title => "Newly Revised Title" },
$asset->revisionDate+2, $asset->revisionDate+2,
{
skipAutoCommitWorkflows => 1,
}
); );
isa_ok( $newRevision, Scalar::Util::blessed( $asset ), "addRevision returns new revision of asset object" ); isa_ok( $newRevision, Scalar::Util::blessed( $asset ), "addRevision returns new revision of asset object" );
is( $newRevision->title, "Newly Revised Title", "properties set correctly" ); is( $newRevision->title, "Newly Revised Title", "properties set correctly" );
is( $newRevision->revisionDate, $asset->revisionDate+2, 'revisionDate set correctly' ); is( $newRevision->revisionDate, $asset->revisionDate+2, 'revisionDate set correctly' );
is( $newRevision->tagId, $tag->getId, "Added to existing working tag" );
# is( $newRevision->tagId, $tag->getId, "Added to existing working tag" ); # XXX failing for WebGUI::Asset::MapPoint
# copied this code
SKIP: {
no strict 'refs';
skip 'Added to existing working tag / class does something magical to tagId using a custom getAutoCommitWorkflowId method', 1, if exists ${$test->class . '::'}{getAutoCommitWorkflowId};
is( $newRevision->tagId, $tag->getId, 'Added to existing working tag' );
};
$newRevision->purgeRevision; $newRevision->purgeRevision;
# Test autocommit
if ( $asset->getAutoCommitWorkflowId ) {
$tag->commit;
$newRevision = $asset->addRevision( { title => 'Auto Committed 2!' }, $asset->revisionDate + 8 );
is( $newRevision->title, 'Auto Committed 2!', 'properties set correctly' );
isnt( $newRevision->tagId, $tag->getId, 'Not Added to existing working tag because parent committed' );
ok( my $newTag = WebGUI::VersionTag->new( $session, $newRevision->tagId ), 'tag exists' );
$newRevision->purgeRevision;
$newTag->rollback;
}
debug($@); debug($@);
undef $@; undef $@;
} }
@ -540,13 +546,13 @@ sub t_11_getEditForm : Tests {
note "label ``$label'' not in form" if ! grep { $_ eq $label } @form; note "label ``$label'' not in form" if ! grep { $_ eq $label } @form;
} }
warn "properties: " . join ', ', sort { $a cmp $b } map { $_ } @properties; note "properties: " . join ', ', sort { $a cmp $b } map { $_ } @properties;
warn "form: " . join ', ', sort { $a cmp $b } map { $_ } @form; note "form: " . join ', ', sort { $a cmp $b } map { $_ } @form;
cmp_deeply( cmp_deeply(
[ sort { $a cmp $b } map { $_ } @form ], \@properties,
[ sort { $a cmp $b } map { $_ } @properties ], subbagof( @form ),
'getProperties agrees with getEditForm->getFieldsRecursive', 'getProperties are all in getEditForm->getFieldsRecursive',
); );
debug($@); debug($@);
@ -564,8 +570,8 @@ sub t_20_www_editSave : Tests {
my $oldGroupId = $asset->groupIdEdit; my $oldGroupId = $asset->groupIdEdit;
$asset->groupIdEdit( 7 ); # Everybody! Everybody! $asset->groupIdEdit( 7 ); # Everybody! Everybody!
$asset->commmit;
$tag->setWorking; $tag->setWorking;
sleep 2; # XXXX Todo -- investigate whether this is actually fixing duplicate commit problems sleep 2; # XXXX Todo -- investigate whether this is actually fixing duplicate commit problems
my %mergedProperties = ( my %mergedProperties = (
@ -580,6 +586,7 @@ sleep 2; # XXXX Todo -- investigate whether this is actually fixing duplicate co
$session->request->setup_body( \%mergedProperties ); $session->request->setup_body( \%mergedProperties );
my $content;
ok(eval { $asset->www_editSave; }, 'www_editSave returns true'); ok(eval { $asset->www_editSave; }, 'www_editSave returns true');
debug($@); debug($@);
undef $@; undef $@;
@ -590,17 +597,14 @@ sleep 2; # XXXX Todo -- investigate whether this is actually fixing duplicate co
undef $@; undef $@;
ok( $newRevision->tagId, 'new revision has a tag' ); ok( $newRevision->tagId, 'new revision has a tag' );
if ( $asset->getAutoCommitWorkflowId ) {
SKIP: { isnt( $newRevision->tagId, $tag->getId, 'Not added to existing working tag' );
no strict 'refs'; ok( my $newTag = WebGUI::VersionTag->new( $session, $newRevision->tagId ), 'tag exists' );
skip 'class does something magical to tagId using a custom getAutoCommitWorkflowId method', 1, if exists ${$test->class . '::'}{getAutoCommitWorkflowId}; }
is( $newRevision->tagId, $tag->getId, 'new revision tagId is current working tag' ); else {
}; is( $newRevision->tagId, $tag->getId, "Added to existing working tag" );
}
SKIP: { is( $newRevision->title, $mergedProperties{title}, 'new revision has the corret title' );
skip 'no templateId in object to inspect', 1, unless $mergedProperties{templateId};
is( $newRevision->templateId, $mergedProperties{templateId}, 'new revision has the corret templateId' );
};
# Alter permissions so it does not work # Alter permissions so it does not work
# XXX todo? # XXX todo?
@ -614,6 +618,23 @@ sleep 2; # XXXX Todo -- investigate whether this is actually fixing duplicate co
undef $@; undef $@;
} }
sub t_20_addSave : Tests {
note "www_addSave";
my ( $test ) = @_;
my $session = $test->session;
my ( $tag, $asset, @parents ) = $test->getAnchoredAsset();
# Alter permissions so www_addSave works
my $oldGroupId = $asset->groupIdEdit;
$asset->groupIdEdit( 7 ); # Everybody! Everybody!
$tag->setWorking;
debug( $@ );
undef $@;
}
#sub asserts : Test(shutdown) { #sub asserts : Test(shutdown) {
# # XXX Todo these should be moved into the appropriate Test::Class subclasses and be made more explicit, if they are to be kept # # XXX Todo these should be moved into the appropriate Test::Class subclasses and be made more explicit, if they are to be kept
# # XXX debugging garbage to track down corruption of the asset tree # # XXX debugging garbage to track down corruption of the asset tree