Add tests for most other wobjects. Block broken code in Role/Asset/Comments. Refactor run_asset.t

This commit is contained in:
Colin Kuskie 2010-03-12 08:41:04 -08:00
parent e0e71a5925
commit 8209de7978
23 changed files with 648 additions and 78 deletions

View file

@ -187,23 +187,23 @@ sub deleteComment {
} }
} }
#------------------------------------------------------------------- ##-------------------------------------------------------------------
#
=head2 get () #=head2 get ()
#
See SUPER::get(). Extends the get() method to automatically decode the comments field into a Perl hash structure. #See SUPER::get(). Extends the get() method to automatically decode the comments field into a Perl hash structure.
#
=cut #=cut
#
sub get { #sub get {
my $self = shift; # my $self = shift;
my $param = shift; # my $param = shift;
if ($param eq 'comments') { # if ($param eq 'comments') {
return JSON->new->decode($self->next::method('comments')||'[]'); # return JSON->new->decode($self->next::method('comments')||'[]');
} # }
return $self->next::method($param, @_); # return $self->next::method($param, @_);
} #}
#
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 getAverageCommentRatingIcon () =head2 getAverageCommentRatingIcon ()
@ -279,30 +279,30 @@ sub getKarmaAmountPerComment {
} }
#------------------------------------------------------------------- ##-------------------------------------------------------------------
#
=head2 update () #=head2 update ()
#
See SUPER::update(). Extends the update() method to encode the comments field into something storable in the database. #See SUPER::update(). Extends the update() method to encode the comments field into something storable in the database.
#
=cut #=cut
#
sub update { #sub update {
my $self = shift; # my $self = shift;
my $properties = shift; # my $properties = shift;
if (exists $properties->{comments}) { # if (exists $properties->{comments}) {
my $comments = $properties->{comments}; # my $comments = $properties->{comments};
if (ref $comments ne 'ARRAY') { # if (ref $comments ne 'ARRAY') {
$comments = eval{JSON->new->decode($comments)}; # $comments = eval{JSON->new->decode($comments)};
if (WebGUI::Error->caught || ref $comments ne 'ARRAY') { # if (WebGUI::Error->caught || ref $comments ne 'ARRAY') {
$comments = []; # $comments = [];
} # }
} # }
$properties->{comments} = JSON->new->encode($comments); # $properties->{comments} = JSON->new->encode($comments);
} # }
$self->next::method($properties, @_); # $self->next::method($properties, @_);
} #}
#
#------------------------------------------------------------------- #-------------------------------------------------------------------
=head2 www_addComment () =head2 www_addComment ()

View file

@ -8,39 +8,5 @@
# http://www.plainblack.com info@plainblack.com # http://www.plainblack.com info@plainblack.com
#------------------------------------------------------------------- #-------------------------------------------------------------------
use lib 'tests'; use Test::Class::Load qw/tests/;
use Test::AssetBase;
use Test::Asset::File;
use Test::Asset::File::Image;
use Test::Asset::File::ZipArchive;
use Test::Asset::File::GalleryFile;
use Test::Asset::Redirect;
use Test::Asset::RichEdit;
use Test::Asset::Shortcut;
use Test::Asset::Sku;
use Test::Asset::Snippet;
use Test::Asset::Template;
use Test::Asset::Wobject;
use Test::Asset::Wobject::Article;
use Test::Asset::Wobject::Calendar;
use Test::Asset::Wobject::Carousel;
use Test::Asset::Wobject::Collaboration;
use Test::Asset::Wobject::DataForm;
use Test::Asset::Wobject::DataTable;
use Test::Asset::Wobject::EventManagementSystem;
use Test::Asset::Wobject::Folder;
use Test::Asset::Wobject::Gallery;
use Test::Asset::Wobject::GalleryAlbum;
use Test::Asset::Wobject::HttpProxy;
use Test::Asset::Wobject::InOutBoard;
use Test::Asset::Wobject::Layout;
use Test::Asset::Wobject::Map;
use Test::Asset::Wobject::Matrix;
use Test::Asset::Wobject::MessageBoard;
use Test::Asset::Wobject::MultiSearch;
use Test::Asset::Wobject::Navigation;
use Test::Asset::Wobject::Poll;
use Test::Asset::Wobject::ProjectManager;
Test::Class->runtests; Test::Class->runtests;

View file

@ -0,0 +1,33 @@
package Test::Asset::Wobject::HttpProxy;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::HttpProxy/;
}
sub assetUiLevel {
return 5;
}
sub list_of_tables {
return [qw/assetData wobject HttpProxy/];
}
1;

View file

@ -0,0 +1,33 @@
package Test::Asset::Wobject::HttpProxy;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::HttpProxy/;
}
sub assetUiLevel {
return 5;
}
sub list_of_tables {
return [qw/assetData wobject HttpProxy/];
}
1;

View file

@ -0,0 +1,33 @@
package Test::Asset::Wobject::HttpProxy;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::HttpProxy/;
}
sub assetUiLevel {
return 5;
}
sub list_of_tables {
return [qw/assetData wobject HttpProxy/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::Navigation;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::Navigation/;
}
sub list_of_tables {
return [qw/assetData wobject Navigation/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::Poll;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::Poll/;
}
sub list_of_tables {
return [qw/assetData wobject Poll/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::ProjectManager;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::ProjectManager/;
}
sub list_of_tables {
return [qw/assetData wobject PM_wobject/];
}
1;

View file

@ -0,0 +1,33 @@
package Test::Asset::Wobject::SQLReport;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::SQLReport/;
}
sub assetUiLevel {
return 5;
}
sub list_of_tables {
return [qw/assetData wobject SQLReport/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::Search;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::Search/;
}
sub list_of_tables {
return [qw/assetData wobject search/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::Shelf;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::Shelf/;
}
sub list_of_tables {
return [qw/assetData wobject Shelf/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::StockData;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::StockData/;
}
sub list_of_tables {
return [qw/assetData wobject StockData/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::StoryArchive;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::StoryArchive/;
}
sub list_of_tables {
return [qw/assetData wobject StoryArchive assetAspectRssFeed/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::StoryTopic;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::StoryTopic/;
}
sub list_of_tables {
return [qw/assetData wobject StoryTopic assetAspectRssFeed/];
}
1;

View file

@ -0,0 +1,33 @@
package Test::Asset::Wobject::HttpProxy;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::HttpProxy/;
}
sub assetUiLevel {
return 5;
}
sub list_of_tables {
return [qw/assetData wobject HttpProxy/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::Survey;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::Survey/;
}
sub list_of_tables {
return [qw/assetData wobject Survey/];
}
1;

View file

@ -0,0 +1,33 @@
package Test::Asset::Wobject::SyndicatedContent;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::SyndicatedContent/;
}
sub assetUiLevel {
return 6;
}
sub list_of_tables {
return [qw/assetData wobject SyndicatedContent assetAspectRssFeed/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::Thingy;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::Thingy/;
}
sub list_of_tables {
return [qw/assetData wobject Thingy/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::TimeTracking;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::TimeTracking/;
}
sub list_of_tables {
return [qw/assetData wobject TT_wobject/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::UserList;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::UserList/;
}
sub list_of_tables {
return [qw/assetData wobject UserList/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::WeatherData;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::WeatherData/;
}
sub list_of_tables {
return [qw/assetData wobject WeatherData/];
}
1;

View file

@ -0,0 +1,29 @@
package Test::Asset::Wobject::WikiMaster;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 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 lib "$FindBin::Bin/lib";
use base qw/Test::AssetBase/;
use Test::More;
use Test::Deep;
use Test::Exception;
sub class {
return qw/WebGUI::Asset::Wobject::WikiMaster/;
}
sub list_of_tables {
return [qw/assetData wobject WikiMaster assetAspectRssFeed assetAspectComments assetAspect_Subscribable/];
}
1;

View file

@ -206,11 +206,11 @@ sub keywords : Test(3) {
is $asset->get('keywords'), 'chess set', 'via get method'; is $asset->get('keywords'), 'chess set', 'via get method';
} }
sub keywords : Test(1) { sub get_tables : Test(1) {
my $test = shift; my $test = shift;
note "get_tables"; note "get_tables";
my @tables = $test->class->meta->get_tables; my @tables = $test->class->meta->get_tables;
cmp_deeply( cmp_bag(
\@tables, \@tables,
$test->list_of_tables, $test->list_of_tables,
'Set of tables for properties is correct' 'Set of tables for properties is correct'