Added Matrix tests, fixed some bugs
This commit is contained in:
parent
31dec565b7
commit
ee2e0ad48d
2 changed files with 42 additions and 6 deletions
|
|
@ -415,8 +415,8 @@ purges it's data.
|
||||||
|
|
||||||
sub purge {
|
sub purge {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
#purge your wobject-specific data here. This does not include fields
|
|
||||||
# you create for your Matrix asset/wobject table.
|
$self->session->db->write("delete from Matrix_attribute where assetId=?",[$self->getId]);
|
||||||
return $self->SUPER::purge;
|
return $self->SUPER::purge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -894,7 +894,7 @@ sub www_getCompareFormData {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $session = $self->session;
|
my $session = $self->session;
|
||||||
my $form = $session->form;
|
my $form = $session->form;
|
||||||
my $sort = $session->scratch->get('sort') || $self->get('defaultSort');
|
my $sort = shift || $session->scratch->get('matrixSort') || $self->get('defaultSort');
|
||||||
my $sortDirection = ' asc';
|
my $sortDirection = ' asc';
|
||||||
|
|
||||||
if ( WebGUI::Utility::isIn($sort, qw(revisionDate score)) ) {
|
if ( WebGUI::Utility::isIn($sort, qw(revisionDate score)) ) {
|
||||||
|
|
@ -1179,7 +1179,7 @@ sub www_setSort {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
|
||||||
if(my $sort = $self->session->form->process("sort")){
|
if(my $sort = $self->session->form->process("sort")){
|
||||||
$self->session->scratch->set('sort',$sort);
|
$self->session->scratch->set('matrixSort',$sort);
|
||||||
}
|
}
|
||||||
return undef;
|
return undef;
|
||||||
}
|
}
|
||||||
|
|
@ -1188,7 +1188,7 @@ sub www_setSort {
|
||||||
|
|
||||||
=head2 www_setStickied ( )
|
=head2 www_setStickied ( )
|
||||||
|
|
||||||
Sets the sort scratch variable.
|
Sets the stickied scratch variable.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,9 @@ use lib "$FindBin::Bin/../../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use Test::More tests => 10; # increment this value for each test you create
|
use Test::More tests => 12; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
|
use JSON;
|
||||||
use WebGUI::Asset::Wobject::Matrix;
|
use WebGUI::Asset::Wobject::Matrix;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
@ -91,8 +92,43 @@ is($newAttribute->{attributeId},undef,"The new attribute was successfully delete
|
||||||
|
|
||||||
# TODO: test deleting of listing data for attribute
|
# TODO: test deleting of listing data for attribute
|
||||||
|
|
||||||
|
# add a listing
|
||||||
|
|
||||||
|
my $matrixListing = $matrix->addChild({className=>'WebGUI::Asset::MatrixListing'});
|
||||||
|
|
||||||
|
my $secondVersionTag = WebGUI::VersionTag->new($session,$matrixListing->get("tagId"));
|
||||||
|
$secondVersionTag->commit;
|
||||||
|
|
||||||
|
# Test for sane object type
|
||||||
|
isa_ok($matrixListing, 'WebGUI::Asset::MatrixListing');
|
||||||
|
|
||||||
|
# Test getting compareFormData including the newly added listing
|
||||||
|
|
||||||
|
$session->user({userId => 3});
|
||||||
|
my $json = $matrix->www_getCompareFormData('score');
|
||||||
|
|
||||||
|
my $compareFormData = JSON->new->utf8->decode($json);
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$compareFormData,
|
||||||
|
{ResultSet=>{
|
||||||
|
Result=>[{
|
||||||
|
views=>"0",
|
||||||
|
lastUpdated=>$matrixListing->get('revisionDate'),
|
||||||
|
clicks=>"0",
|
||||||
|
compares=>"0",
|
||||||
|
assetId=>$matrixListing->getId,
|
||||||
|
url=>'/'.$matrixListing->get('url'),
|
||||||
|
title=>$matrixListing->get('title')
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'Getting compareFormData as JSON: www_getCompareFormData returns correct data as JSON.'
|
||||||
|
);
|
||||||
|
|
||||||
END {
|
END {
|
||||||
# Clean up after thy self
|
# Clean up after thy self
|
||||||
$versionTag->rollback();
|
$versionTag->rollback();
|
||||||
|
$secondVersionTag->rollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue