Add tests for setVersionLock, no more test plans.
This commit is contained in:
parent
636ca8ae86
commit
eeef1a2349
1 changed files with 35 additions and 1 deletions
36
t/Asset.t
36
t/Asset.t
|
|
@ -21,7 +21,6 @@ use Test::Deep;
|
|||
use Test::Exception;
|
||||
use WebGUI::Exception;
|
||||
|
||||
plan tests => 65;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -217,6 +216,32 @@ my $session = WebGUI::Test->session;
|
|||
$session->db->write("delete from assetData where assetId=?", [$testId]);
|
||||
}
|
||||
|
||||
{
|
||||
note "setVersionLock";
|
||||
my $testId1 = 'wg8TestAsset0000000001';
|
||||
my $testId2 = 'wg8TestAsset0000000002';
|
||||
my $now = time();
|
||||
my $baseLineage = $session->db->quickScalar('select lineage from asset where assetId=?',['PBasset000000000000002']);
|
||||
my $testLineage = $baseLineage. '909090';
|
||||
$session->db->write("insert into asset (assetId, className, lineage) VALUES (?,?,?)", [$testId1, 'WebGUI::Asset', $testLineage]);
|
||||
$session->db->write("insert into assetData (assetId, revisionDate, status) VALUES (?,?,?)", [$testId1, $now, 'approved']);
|
||||
my $testLineage2 = $testLineage . '000001';
|
||||
$session->db->write("insert into asset (assetId, className, parentId, lineage) VALUES (?,?,?,?)", [$testId2, 'WebGUI::Asset', $testId1, $testLineage2]);
|
||||
$session->db->write("insert into assetData (assetId, revisionDate) VALUES (?,?)", [$testId2, $now]);
|
||||
|
||||
my $testAsset = WebGUI::Asset->new($session, $testId2, $now);
|
||||
my $originalSessionUser = $session->user->userId;
|
||||
$session->user({userId => 7});
|
||||
$testAsset->setVersionLock;
|
||||
is $testAsset->isLockedBy, 7, 'locked by userId 7';
|
||||
ok $testAsset->isLocked, 'asset is locked';
|
||||
is $session->db->quickScalar('select isLockedBy from asset where assetId=?',[$testId2]), 7, 'userId written to db';
|
||||
|
||||
$session->db->write("delete from asset where assetId like 'wg8TestAsset00000%'");
|
||||
$session->db->write("delete from assetData where assetId like 'wg8TestAsset00000%'");
|
||||
$session->user({userId => $originalSessionUser});
|
||||
}
|
||||
|
||||
{
|
||||
note "getParent";
|
||||
my $testId1 = 'wg8TestAsset0000000001';
|
||||
|
|
@ -254,21 +279,28 @@ my $session = WebGUI::Test->session;
|
|||
$session->db->write("insert into assetData (assetId, revisionDate) VALUES (?,?)", [$testId2, $revisionDate]);
|
||||
|
||||
my $testAsset = WebGUI::Asset->new($session, $testId2, $revisionDate);
|
||||
my $originalSessionUser = $session->user->userId;
|
||||
$session->user({userId => 7});
|
||||
$testAsset->title('test title 43');
|
||||
$testAsset->write();
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
my $revAsset = $testAsset->addRevision({}, $now);
|
||||
my $revAssetDb = $revAsset->cloneFromDb;
|
||||
isa_ok $revAsset, 'WebGUI::Asset';
|
||||
is $revAsset->revisionDate, $now, 'revisionDate set correctly on new revision';
|
||||
is $revAsset->title, 'test title 43', 'data fetch from database correct';
|
||||
is $revAsset->revisedBy, $session->user->userId, 'revisedBy is current session user';
|
||||
is $revAsset->tagId, $tag->getId, 'tagId is current working tagId';
|
||||
ok $revAsset->isLocked, 'new revision is locked';
|
||||
is $revAsset->isLockedBy, '7', 'locked by userId 7';
|
||||
is $revAssetDb->isLockedBy, '7', 'database jives with asset data';
|
||||
my $count = $session->db->quickScalar('SELECT COUNT(*) from assetData where assetId=?',[$testId2]);
|
||||
is $count, 2, 'two records in the database';
|
||||
addToCleanup($tag);
|
||||
|
||||
$session->db->write("delete from asset where assetId like 'wg8TestAsset00000%'");
|
||||
$session->db->write("delete from assetData where assetId like 'wg8TestAsset00000%'");
|
||||
$session->user({userId => $originalSessionUser});
|
||||
}
|
||||
|
||||
{
|
||||
|
|
@ -325,3 +357,5 @@ my $session = WebGUI::Test->session;
|
|||
my $classes = WebGUI::Asset->valid_parent_classes;
|
||||
cmp_deeply($classes, [qw/WebGUI::Asset/], 'Any asset okay');
|
||||
}
|
||||
|
||||
done_testing;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue