Replaced Matrix with newer version
This commit is contained in:
commit
79bfa826e0
8 changed files with 2592 additions and 1580 deletions
63
t/Asset/MatrixListing.t
Normal file
63
t/Asset/MatrixListing.t
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2008 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 lib "$FindBin::Bin/../lib";
|
||||
|
||||
##The goal of this test is to test the creation of a MatrixListing Asset.
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 2; # increment this value for each test you create
|
||||
use WebGUI::Asset::Wobject::Matrix;
|
||||
use WebGUI::Asset::MatrixListing;
|
||||
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my ($matrix, $matrixListing);
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Matrix Listing Test"});
|
||||
|
||||
$matrix = $node->addChild({className=>'WebGUI::Asset::Wobject::Matrix'});
|
||||
$versionTag->commit;
|
||||
$matrixListing = $matrix->addChild({className=>'WebGUI::Asset::MatrixListing'});
|
||||
|
||||
# Wikis create and autocommit a version tag when a child is added. Lets get the name so we can roll it back.
|
||||
my $secondVersionTag = WebGUI::VersionTag->new($session,$matrixListing->get("tagId"));
|
||||
|
||||
# Test for sane object types
|
||||
isa_ok($matrix, 'WebGUI::Asset::Wobject::Matrix');
|
||||
isa_ok($matrixListing, 'WebGUI::Asset::MatrixListing');
|
||||
|
||||
# Try to add content under a MatrixListing asset
|
||||
#my $article = $matrixListing->addChild({className=>'WebGUI::Asset::Wobject::Article'});
|
||||
#is($article, undef, "Can't add an Article wobject as a child to a Matrix Listing.");
|
||||
|
||||
# See if the duplicate method works
|
||||
#my $wikiPageCopy = $wikipage->duplicate();
|
||||
#isa_ok($wikiPageCopy, 'WebGUI::Asset::WikiPage');
|
||||
#my $thirdVersionTag = WebGUI::VersionTag->new($session,$wikiPageCopy->get("tagId"));
|
||||
|
||||
|
||||
#TODO: {
|
||||
# local $TODO = "Tests to make later";
|
||||
# ok(0, 'Lots and lots to do');
|
||||
#}
|
||||
|
||||
END {
|
||||
# Clean up after thy self
|
||||
$versionTag->rollback();
|
||||
$secondVersionTag->rollback();
|
||||
#$thirdVersionTag->rollback();
|
||||
}
|
||||
|
||||
98
t/Asset/Wobject/Matrix.t
Normal file
98
t/Asset/Wobject/Matrix.t
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2008 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 File::Spec;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
|
||||
##The goal of this test is to test the creation of UserList Wobjects.
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 10; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use WebGUI::Asset::Wobject::Matrix;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
# Do our work in the import node
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Matrix Test"});
|
||||
my $matrix = $node->addChild({className=>'WebGUI::Asset::Wobject::Matrix'});
|
||||
|
||||
# Test for a sane object type
|
||||
isa_ok($matrix, 'WebGUI::Asset::Wobject::Matrix');
|
||||
|
||||
# Test to see if we can set new values
|
||||
my $newMatrixSettings = {
|
||||
maxComparisons => 20,
|
||||
defaultSort => 'assetRank',
|
||||
compareColorNo => '#aaffaa',
|
||||
submissionApprovalWorkflowId => 'pbworkflow000000000005',
|
||||
categories => "category1\ncategory2",
|
||||
};
|
||||
$matrix->update($newMatrixSettings);
|
||||
|
||||
foreach my $newSetting (keys %{$newMatrixSettings}) {
|
||||
unless ($newSetting eq 'categories'){
|
||||
is ($matrix->get($newSetting), $newMatrixSettings->{$newSetting}, "updated $newSetting is ".$newMatrixSettings->{$newSetting});
|
||||
}
|
||||
}
|
||||
|
||||
cmp_deeply (
|
||||
$matrix->getCategories,
|
||||
{
|
||||
category1=>'category1',
|
||||
category2=>'category2'
|
||||
},
|
||||
'getCategories method returned correct hashref'
|
||||
);
|
||||
|
||||
|
||||
# add a new attribute
|
||||
|
||||
$session->user({userId => 3});
|
||||
|
||||
my $attributeProperties = {
|
||||
name =>'test attribute',
|
||||
description =>'description of the test attribute',
|
||||
category =>'category1',
|
||||
};
|
||||
|
||||
my $newAttributeId = $matrix->editAttributeSave($attributeProperties);
|
||||
|
||||
my $newAttribute = $matrix->getAttribute($newAttributeId);
|
||||
|
||||
my $isValidId = $session->id->valid($newAttributeId);
|
||||
|
||||
is($isValidId,1,"editAttributeSave returnes a valid guid");
|
||||
|
||||
is($newAttribute->{name},'test attribute',"Adding a new attribute, attribute name was set correctly");
|
||||
is($newAttribute->{fieldType},'MatrixCompare',"Adding a new attribute, undefined fieldType was set correctly to
|
||||
default value");
|
||||
|
||||
# delete new attribute
|
||||
|
||||
$matrix->deleteAttribute($newAttributeId);
|
||||
|
||||
my $newAttribute = $matrix->getAttribute($newAttributeId);
|
||||
|
||||
is($newAttribute->{attributeId},undef,"The new attribute was successfully deleted.");
|
||||
|
||||
# TODO: test deleting of listing data for attribute
|
||||
|
||||
END {
|
||||
# Clean up after thy self
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue