Merge branch 'WebGUI8' of github.com:plainblack/webgui into WebGUI8
This commit is contained in:
commit
14b79a671b
25 changed files with 684 additions and 1452 deletions
|
|
@ -410,12 +410,12 @@ Fetches the last post in this thread, otherwise, returns itself.
|
||||||
sub getLastPost {
|
sub getLastPost {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $lastPostId = $self->lastPostId;
|
my $lastPostId = $self->lastPostId;
|
||||||
my $lastPost;
|
return $self unless $lastPostId;
|
||||||
if ($lastPostId) {
|
my $lastPost = eval { WebGUI::Asset->newById($self->session, $lastPostId); };
|
||||||
$lastPost = WebGUI::Asset::Post->newById($self->session, $lastPostId);
|
if (Exception::Class->caught()) {
|
||||||
}
|
return $self;
|
||||||
return $lastPost if (defined $lastPost);
|
}
|
||||||
return $self;
|
return $lastPost;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ use Carp qw( croak );
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
use File::Temp qw{ tempdir };
|
use File::Temp qw{ tempdir };
|
||||||
use JSON ();
|
use JSON qw();
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::HTML;
|
use WebGUI::HTML;
|
||||||
use WebGUI::ProgressBar;
|
use WebGUI::ProgressBar;
|
||||||
|
|
@ -1171,7 +1171,7 @@ sub www_ajax {
|
||||||
my $result;
|
my $result;
|
||||||
|
|
||||||
# Get arguments encoded in json format
|
# Get arguments encoded in json format
|
||||||
my $args = decode_json($form->get("args"));
|
my $args = JSON::from_json($form->get("args"));
|
||||||
|
|
||||||
# Log some debug information
|
# Log some debug information
|
||||||
$session->log->debug("Ajax service called with args=" . $form->get("args"));
|
$session->log->debug("Ajax service called with args=" . $form->get("args"));
|
||||||
|
|
@ -1198,7 +1198,7 @@ sub www_ajax {
|
||||||
$result->{ err } = -1 if $result->{ errMessage };
|
$result->{ err } = -1 if $result->{ errMessage };
|
||||||
|
|
||||||
# Return results encoded in json format
|
# Return results encoded in json format
|
||||||
return encode_json( $result );
|
return JSON::to_json( $result );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1266,10 +1266,10 @@ sub _moveFileAjaxRequest {
|
||||||
|
|
||||||
# Instantiate file with ID in before/after argument
|
# Instantiate file with ID in before/after argument
|
||||||
$destId = $args->{before} ? $args->{before} : $args->{after};
|
$destId = $args->{before} ? $args->{before} : $args->{after};
|
||||||
$dest = WebGUI::Asset->newById( $session, $destId );
|
$dest = eval { WebGUI::Asset->newById( $session, $destId ); };
|
||||||
|
|
||||||
# Return if destination file could not be instantiated
|
# Return if destination file could not be instantiated
|
||||||
if ( Expeption::Class->caught() ) {
|
if ( Exception::Class->caught() ) {
|
||||||
$session->log->error("Couldn't move file '$targetId' before/after file '$destId' because we couldn't instantiate the latter.");
|
$session->log->error("Couldn't move file '$targetId' before/after file '$destId' because we couldn't instantiate the latter.");
|
||||||
$result{ errMessage } = "ID in before/after argument seems to be invalid.";
|
$result{ errMessage } = "ID in before/after argument seems to be invalid.";
|
||||||
return \%result;
|
return \%result;
|
||||||
|
|
|
||||||
|
|
@ -265,8 +265,7 @@ part of the C<groupToAdd> group.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub canEdit {
|
override canEdit => sub {
|
||||||
my $orig = shift;
|
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $userId = shift || $self->session->user->userId;
|
my $userId = shift || $self->session->user->userId;
|
||||||
|
|
||||||
|
|
@ -276,14 +275,8 @@ sub canEdit {
|
||||||
&& $form->get( 'class' )->isa( 'WebGUI::Asset::MatrixListing' ) ) {
|
&& $form->get( 'class' )->isa( 'WebGUI::Asset::MatrixListing' ) ) {
|
||||||
return $self->canAddMatrixListing();
|
return $self->canAddMatrixListing();
|
||||||
}
|
}
|
||||||
else {
|
return super();
|
||||||
if ($userId eq $self->ownerUserId) {
|
};
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
my $user = WebGUI::User->new($self->session, $userId);
|
|
||||||
return $user->isInGroup($self->groupIdEdit);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -217,6 +217,7 @@ sub getRssFeedItems {
|
||||||
author => $item->author,
|
author => $item->author,
|
||||||
guid => $item->guid,
|
guid => $item->guid,
|
||||||
);
|
);
|
||||||
|
push @items, \%feed_item;
|
||||||
}
|
}
|
||||||
return \@items;
|
return \@items;
|
||||||
}
|
}
|
||||||
|
|
@ -294,11 +295,12 @@ See WebGUI::Asset::prepareView() for details.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub prepareView {
|
around prepareView => sub {
|
||||||
|
my $orig = shift;
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->next::method;
|
$self->$orig();
|
||||||
my $template = WebGUI::Asset::Template->newById($self->session, $self->templateId);
|
my $template = eval { WebGUI::Asset->newById($self->session, $self->templateId); };
|
||||||
if (!$template) {
|
if (Exception::Class->caught()) {
|
||||||
WebGUI::Error::ObjectNotFound::Template->throw(
|
WebGUI::Error::ObjectNotFound::Template->throw(
|
||||||
error => qq{Template not found},
|
error => qq{Template not found},
|
||||||
templateId => $self->templateId,
|
templateId => $self->templateId,
|
||||||
|
|
@ -307,7 +309,7 @@ sub prepareView {
|
||||||
}
|
}
|
||||||
$template->prepare($self->getMetaDataAsTemplateVariables);
|
$template->prepare($self->getMetaDataAsTemplateVariables);
|
||||||
$self->{_viewTemplate} = $template;
|
$self->{_viewTemplate} = $template;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
@ -359,63 +361,11 @@ See WebGUI::Asset::Wobject::www_view() for details.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
sub www_view {
|
override www_view => sub {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->session->http->setCacheControl($self->cacheTimeout);
|
$self->session->http->setCacheControl($self->cacheTimeout);
|
||||||
$self->next::method(@_);
|
super();
|
||||||
}
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_viewRSS090 ( )
|
|
||||||
|
|
||||||
Deprecated. Use www_viewRss() instead.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_viewRSS090 {
|
|
||||||
my $self = shift;
|
|
||||||
return $self->www_viewRss;
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_viewRSS091 ( )
|
|
||||||
|
|
||||||
Deprecated. Use www_viewRss() instead.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_viewRSS091 {
|
|
||||||
my $self = shift;
|
|
||||||
return $self->www_viewRss;
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_viewRSS10 ( )
|
|
||||||
|
|
||||||
Deprecated. Use www_viewRdf() instead.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_viewRSS10 {
|
|
||||||
my $self = shift;
|
|
||||||
return $self->www_viewRdf;
|
|
||||||
}
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
|
||||||
|
|
||||||
=head2 www_viewRSS20 ( )
|
|
||||||
|
|
||||||
Deprecated. Use www_viewRss() instead.
|
|
||||||
|
|
||||||
=cut
|
|
||||||
|
|
||||||
sub www_viewRSS20 {
|
|
||||||
my $self = shift;
|
|
||||||
return $self->www_viewRss;
|
|
||||||
}
|
|
||||||
|
|
||||||
__PACKAGE__->meta->make_immutable;
|
__PACKAGE__->meta->make_immutable;
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ sub getFirstChild {
|
||||||
$assetLineage->{firstChild}{$self->getId} = $lineage;
|
$assetLineage->{firstChild}{$self->getId} = $lineage;
|
||||||
$self->session->stow->set("assetLineage", $assetLineage);
|
$self->session->stow->set("assetLineage", $assetLineage);
|
||||||
}
|
}
|
||||||
$child = WebGUI::Asset->newByLineage($self->session,$lineage);
|
$child = eval { WebGUI::Asset->newByLineage($self->session,$lineage); };
|
||||||
$self->cacheChild(first => $child);
|
$self->cacheChild(first => $child);
|
||||||
}
|
}
|
||||||
return $child;
|
return $child;
|
||||||
|
|
@ -301,7 +301,7 @@ sub getLastChild {
|
||||||
$assetLineage->{lastChild}{$self->getId} = $lineage;
|
$assetLineage->{lastChild}{$self->getId} = $lineage;
|
||||||
$self->session->stow->set("assetLineage", $assetLineage);
|
$self->session->stow->set("assetLineage", $assetLineage);
|
||||||
}
|
}
|
||||||
$child = WebGUI::Asset->newByLineage($self->session,$lineage);
|
$child = eval { WebGUI::Asset->newByLineage($self->session,$lineage); };
|
||||||
$self->cacheChild(last => $child);
|
$self->cacheChild(last => $child);
|
||||||
}
|
}
|
||||||
return $child;
|
return $child;
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,20 @@ sub import {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 init_meta ( )
|
||||||
|
|
||||||
|
A custom init_meta, so that if inported into a class, it applies the roles
|
||||||
|
to the class, and applies the meta-role to the meta-class.
|
||||||
|
|
||||||
|
But, if it is applied to a Role, then only the meta-role is applied, since we want
|
||||||
|
the final application to be in the end user of the Role.
|
||||||
|
|
||||||
|
This permits using this to compose Asset Roles with their own database tables.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
sub init_meta {
|
sub init_meta {
|
||||||
my $class = shift;
|
my $class = shift;
|
||||||
my %args = @_;
|
my %args = @_;
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package WebGUI::FilePump::Bundle;
|
||||||
|
|
||||||
use base qw/WebGUI::Crud WebGUI::JSONCollateral/;
|
use base qw/WebGUI::Crud WebGUI::JSONCollateral/;
|
||||||
use strict;
|
use strict;
|
||||||
|
use WebGUI::Asset;
|
||||||
use WebGUI::International;
|
use WebGUI::International;
|
||||||
use WebGUI::Exception;
|
use WebGUI::Exception;
|
||||||
use WebGUI::Utility;
|
use WebGUI::Utility;
|
||||||
|
|
|
||||||
|
|
@ -479,10 +479,11 @@ Extend the master class to insert head links via addHeaderLinks.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
override prepareView => sub {
|
around prepareView => sub {
|
||||||
|
my $orig = shift;
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
$self->addHeaderLinks;
|
$self->addHeaderLinks;
|
||||||
return super();
|
return $self->$orig;
|
||||||
};
|
};
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,8 @@ use strict;
|
||||||
use XML::Simple;
|
use XML::Simple;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
use Tie::IxHash;
|
use Tie::IxHash;
|
||||||
|
use LWP::UserAgent;
|
||||||
|
use HTTP::Request;
|
||||||
|
|
||||||
use base qw/WebGUI::Shop::PayDriver/;
|
use base qw/WebGUI::Shop::PayDriver/;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -134,11 +134,11 @@ sub getSku {
|
||||||
my ($self) = @_;
|
my ($self) = @_;
|
||||||
my $asset = eval { WebGUI::Asset->newById($self->transaction->session, $self->get("assetId")); };
|
my $asset = eval { WebGUI::Asset->newById($self->transaction->session, $self->get("assetId")); };
|
||||||
if (Exception::Class->caught()) {
|
if (Exception::Class->caught()) {
|
||||||
$asset->applyOptions($self->get("options"));
|
WebGUI::Error::ObjectNotFound->throw(error=>'SKU Asset '.$self->get('assetId').' could not be instanciated. Perhaps it no longer exists.', id=>$self->get('assetId'));
|
||||||
return $asset;
|
return undef;
|
||||||
}
|
}
|
||||||
WebGUI::Error::ObjectNotFound->throw(error=>'SKU Asset '.$self->get('assetId').' could not be instanciated. Perhaps it no longer exists.', id=>$self->get('assetId'));
|
$asset->applyOptions($self->get("options"));
|
||||||
return undef;
|
return $asset;
|
||||||
}
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,49 @@
|
||||||
package WebGUI::Types;
|
package WebGUI::Types;
|
||||||
|
|
||||||
|
=head1 LEGAL
|
||||||
|
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
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
|
||||||
|
-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
use Moose;
|
use Moose;
|
||||||
use Moose::Util::TypeConstraints;
|
use Moose::Util::TypeConstraints;
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
Package WebGUI::Types
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
A package to hold all Moose types for WebGUI::Definition based classes.
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
use WebGUI::Types;
|
||||||
|
|
||||||
|
=head1 METHODS
|
||||||
|
|
||||||
|
These types are provided by this class:
|
||||||
|
|
||||||
|
=head2 WebGUI::Type::JSONArray
|
||||||
|
|
||||||
|
The JSONArray is an subtype of ArrayRef, with coercions. If a string is applied to the property
|
||||||
|
with this type, it ties to pass it through JSON::from_json. If that fails, then it returns an
|
||||||
|
empty arrayref.
|
||||||
|
|
||||||
|
Similarly, if an undef value is applied, it is coerced into an empty arrayref.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
subtype 'WebGUI::Type::JSONArray'
|
subtype 'WebGUI::Type::JSONArray'
|
||||||
=> as 'ArrayRef'
|
=> as 'ArrayRef'
|
||||||
;
|
;
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
|
||||||
ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor');
|
ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor');
|
||||||
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
||||||
ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
|
ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
|
||||||
is( $posts->[0]->{'lastReply.url'}, $threads[1]->getUrl.'?pn=1#id'.$threads[1]->getId, 'lastReply url has a query fragment prefixed by "id"');
|
is( $posts->[0]->{'lastReply.url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'lastReply url has a query fragment prefixed by "id"');
|
||||||
is( $posts->[0]->{'url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'url has a query fragment prefixed by "id"');
|
is( $posts->[0]->{'url'}, $threads[1]->getUrl.'#id'.$threads[1]->getId, 'url has a query fragment prefixed by "id"');
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,6 @@ $templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||||
'stateChangedBy' => ignore(),
|
'stateChangedBy' => ignore(),
|
||||||
'lineage' => ignore(),
|
'lineage' => ignore(),
|
||||||
'className' => 'WebGUI::Asset::Wobject::EventManagementSystem',
|
'className' => 'WebGUI::Asset::Wobject::EventManagementSystem',
|
||||||
'groupToApproveEvents' => ignore(),
|
|
||||||
'lastModified' => ignore(),
|
'lastModified' => ignore(),
|
||||||
'title' => 'Test EMS',
|
'title' => 'Test EMS',
|
||||||
'groupIdView' => ignore(),
|
'groupIdView' => ignore(),
|
||||||
|
|
@ -346,6 +345,9 @@ $templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||||
'eventSubmissionQueueTemplateId' => ignore(),
|
'eventSubmissionQueueTemplateId' => ignore(),
|
||||||
'eventSubmissionTemplateId' => ignore(),
|
'eventSubmissionTemplateId' => ignore(),
|
||||||
'submittedLocationsList' => ignore(),
|
'submittedLocationsList' => ignore(),
|
||||||
|
'keywords' => ignore(),
|
||||||
|
'session' => ignore(),
|
||||||
|
'uiLevel' => ignore(),
|
||||||
'tickets_loop' => \@ticketArray,
|
'tickets_loop' => \@ticketArray,
|
||||||
},
|
},
|
||||||
"www_printRemainingTickets: template variables valid"
|
"www_printRemainingTickets: template variables valid"
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,8 @@ my $gallery
|
||||||
});
|
});
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
|
WebGUI::Test->addToCleanup($versionTag);
|
||||||
|
$gallery->cloneFromDb;
|
||||||
|
|
||||||
is(
|
is(
|
||||||
Scalar::Util::blessed($gallery), "WebGUI::Asset::Wobject::Gallery",
|
Scalar::Util::blessed($gallery), "WebGUI::Asset::Wobject::Gallery",
|
||||||
|
|
@ -61,14 +63,5 @@ isa_ok(
|
||||||
my $properties = $gallery->get;
|
my $properties = $gallery->get;
|
||||||
$gallery->purge;
|
$gallery->purge;
|
||||||
|
|
||||||
is(
|
eval { WebGUI::Asset->newById($session, $properties->{assetId}); };
|
||||||
WebGUI::Asset->newById($session, $properties->{assetId}), undef,
|
ok( Exception::Class->caught(), 'Gallery no longer able to be instanciated after purge');
|
||||||
"Gallery no longer able to be instanciated",
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
# Cleanup
|
|
||||||
END {
|
|
||||||
$versionTag->rollback();
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ my $album
|
||||||
});
|
});
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
|
WebGUI::Test->addToCleanup($versionTag);
|
||||||
|
|
||||||
is(
|
is(
|
||||||
Scalar::Util::blessed($album), "WebGUI::Asset::Wobject::GalleryAlbum",
|
Scalar::Util::blessed($album), "WebGUI::Asset::Wobject::GalleryAlbum",
|
||||||
|
|
@ -66,14 +67,5 @@ isa_ok(
|
||||||
my $properties = $album->get;
|
my $properties = $album->get;
|
||||||
$album->purge;
|
$album->purge;
|
||||||
|
|
||||||
is(
|
eval { WebGUI::Asset->newById($session, $properties->{assetId}); };
|
||||||
WebGUI::Asset->newById($session, $properties->{assetId}), undef,
|
ok( Exception::Class->caught(), 'Album no longer able to be instanciated');
|
||||||
"Album no longer able to be instanciated",
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
# Cleanup
|
|
||||||
END {
|
|
||||||
$versionTag->rollback();
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,7 @@ for (my $i = 0; $i < 5; $i++)
|
||||||
|
|
||||||
# Commit all changes
|
# Commit all changes
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
|
WebGUI::Test->addToCleanup($versionTag);
|
||||||
|
|
||||||
# Make album default asset
|
# Make album default asset
|
||||||
$session->asset( $album );
|
$session->asset( $album );
|
||||||
|
|
@ -95,7 +96,7 @@ use_ok("WebGUI::Asset::Wobject::GalleryAlbum");
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test calling without arguments
|
# Test calling without arguments
|
||||||
|
|
||||||
diag("general testing");
|
note("general testing");
|
||||||
|
|
||||||
# Provide no arguments at all
|
# Provide no arguments at all
|
||||||
$result = callAjaxService({ });
|
$result = callAjaxService({ });
|
||||||
|
|
@ -105,7 +106,7 @@ ok( $result->{ err } != 0 && $result->{ errMessage }, "Error after call without
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Test moveFile action with incomplete of invalid arguments
|
# Test moveFile action with incomplete of invalid arguments
|
||||||
|
|
||||||
diag("moveFile action");
|
note("moveFile action");
|
||||||
|
|
||||||
# Omit target
|
# Omit target
|
||||||
$result = callAjaxService({
|
$result = callAjaxService({
|
||||||
|
|
@ -256,9 +257,3 @@ sub callAjaxService {
|
||||||
# Call ajax service function and decode reply
|
# Call ajax service function and decode reply
|
||||||
return decode_json( $album->www_ajax() );
|
return decode_json( $album->www_ajax() );
|
||||||
}
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
# Cleanup
|
|
||||||
END {
|
|
||||||
$versionTag->rollback();
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,10 @@ my $album
|
||||||
});
|
});
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
|
WebGUI::Test->addToCleanup($versionTag);
|
||||||
|
foreach my $asset ($gallery, $album) {
|
||||||
|
$asset = $asset->cloneFromDb;
|
||||||
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
@ -95,15 +99,6 @@ $maker->prepare({
|
||||||
});
|
});
|
||||||
$maker->run;
|
$maker->run;
|
||||||
|
|
||||||
is(
|
eval { WebGUI::Asset->newById( $session, $assetId ); };
|
||||||
WebGUI::Asset->newById( $session, $assetId ),
|
ok (Exception::Class->caught(), "GalleryAlbum cannot be instanciated after www_deleteConfirm");
|
||||||
undef,
|
|
||||||
"GalleryAlbum cannot be instanciated after www_deleteConfirm",
|
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
# Cleanup
|
|
||||||
END {
|
|
||||||
$versionTag->rollback();
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ my $matrixListing = $matrix->addChild({className=>'WebGUI::Asset::MatrixListing'
|
||||||
my $secondVersionTag = WebGUI::VersionTag->new($session,$matrixListing->get("tagId"));
|
my $secondVersionTag = WebGUI::VersionTag->new($session,$matrixListing->get("tagId"));
|
||||||
$secondVersionTag->commit;
|
$secondVersionTag->commit;
|
||||||
WebGUI::Test->tagsToRollback($secondVersionTag);
|
WebGUI::Test->tagsToRollback($secondVersionTag);
|
||||||
|
$matrixListing = $matrixListing->cloneFromDb;
|
||||||
|
|
||||||
# Test for sane object type
|
# Test for sane object type
|
||||||
isa_ok($matrixListing, 'WebGUI::Asset::MatrixListing');
|
isa_ok($matrixListing, 'WebGUI::Asset::MatrixListing');
|
||||||
|
|
@ -155,7 +156,7 @@ cmp_deeply(
|
||||||
|
|
||||||
# Test Listings Caching
|
# Test Listings Caching
|
||||||
|
|
||||||
my $listingsEncoded = WebGUI::Cache->new($session,"matrixListings_".$matrix->getId)->get;
|
my $listingsEncoded = $session->cache->get("matrixListings_".$matrix->getId);
|
||||||
$listings = JSON->new->decode($listingsEncoded);
|
$listings = JSON->new->decode($listingsEncoded);
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
|
|
@ -229,9 +230,9 @@ cmp_deeply(
|
||||||
|
|
||||||
# Test statistics caching by view method
|
# Test statistics caching by view method
|
||||||
|
|
||||||
WebGUI::Cache->new($session,"matrixStatistics_".$matrix->getId)->delete;
|
$session->cache->remove("matrixStatistics_".$matrix->getId);
|
||||||
$matrix->view;
|
$matrix->view;
|
||||||
my $varStatisticsEncoded = WebGUI::Cache->new($session,"matrixStatistics_".$matrix->getId)->get;
|
my $varStatisticsEncoded = $session->cache->get("matrixStatistics_".$matrix->getId);
|
||||||
my $varStatistics = JSON->new->decode($varStatisticsEncoded);
|
my $varStatistics = JSON->new->decode($varStatisticsEncoded);
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
|
|
@ -302,9 +303,9 @@ $matrixListing->setRatings({category1=>'1',category2=>'9'});
|
||||||
$matrixListing->setRatings({category1=>'3',category2=>'5'});
|
$matrixListing->setRatings({category1=>'3',category2=>'5'});
|
||||||
$matrixListing->setRatings({category1=>'1',category2=>'9'});
|
$matrixListing->setRatings({category1=>'1',category2=>'9'});
|
||||||
|
|
||||||
WebGUI::Cache->new($session,"matrixStatistics_".$matrix->getId)->delete;
|
$session->cache->remove("matrixStatistics_".$matrix->getId);
|
||||||
$matrix->view;
|
$matrix->view;
|
||||||
my $varStatisticsEncoded = WebGUI::Cache->new($session,"matrixStatistics_".$matrix->getId)->get;
|
my $varStatisticsEncoded = $session->cache->get("matrixStatistics_".$matrix->getId);
|
||||||
my $varStatistics = JSON->new->decode($varStatisticsEncoded);
|
my $varStatistics = JSON->new->decode($varStatisticsEncoded);
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
|
|
@ -349,10 +350,10 @@ cmp_deeply(
|
||||||
'With only 9 ratings, still no statistics'
|
'With only 9 ratings, still no statistics'
|
||||||
);
|
);
|
||||||
|
|
||||||
WebGUI::Cache->new($session,"matrixStatistics_".$matrix->getId)->delete;
|
$session->cache->remove("matrixStatistics_".$matrix->getId);
|
||||||
$matrixListing->setRatings({category1=>'3'});
|
$matrixListing->setRatings({category1=>'3'});
|
||||||
$matrix->view;
|
$matrix->view;
|
||||||
my $varStatisticsEncoded = WebGUI::Cache->new($session,"matrixStatistics_".$matrix->getId)->get;
|
my $varStatisticsEncoded = $session->cache->get("matrixStatistics_".$matrix->getId);
|
||||||
my $varStatistics = JSON->new->decode($varStatisticsEncoded);
|
my $varStatistics = JSON->new->decode($varStatisticsEncoded);
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
|
|
@ -364,7 +365,7 @@ cmp_deeply(
|
||||||
best_rating_loop => [{
|
best_rating_loop => [{
|
||||||
url => '/'.$matrixListing->get('url'),
|
url => '/'.$matrixListing->get('url'),
|
||||||
category=> 'category1',
|
category=> 'category1',
|
||||||
name => 'untitled',
|
name => 'Untitled',
|
||||||
mean => 2,
|
mean => 2,
|
||||||
median => 3,
|
median => 3,
|
||||||
count => 10,
|
count => 10,
|
||||||
|
|
@ -380,7 +381,7 @@ cmp_deeply(
|
||||||
worst_rating_loop => [{
|
worst_rating_loop => [{
|
||||||
url => '/'.$matrixListing->get('url'),
|
url => '/'.$matrixListing->get('url'),
|
||||||
category=> 'category1',
|
category=> 'category1',
|
||||||
name => 'untitled',
|
name => 'Untitled',
|
||||||
mean => 2,
|
mean => 2,
|
||||||
median => 3,
|
median => 3,
|
||||||
count => 10,
|
count => 10,
|
||||||
|
|
@ -397,10 +398,10 @@ cmp_deeply(
|
||||||
'statistics calculated for the category with 10 ratings'
|
'statistics calculated for the category with 10 ratings'
|
||||||
);
|
);
|
||||||
|
|
||||||
WebGUI::Cache->new($session,"matrixStatistics_".$matrix->getId)->delete;
|
$session->cache->remove("matrixStatistics_".$matrix->getId);
|
||||||
$matrixListing->setRatings({category2=>'5'});
|
$matrixListing->setRatings({category2=>'5'});
|
||||||
$matrix->view;
|
$matrix->view;
|
||||||
my $varStatisticsEncoded = WebGUI::Cache->new($session,"matrixStatistics_".$matrix->getId)->get;
|
my $varStatisticsEncoded = $session->cache->get("matrixStatistics_".$matrix->getId);
|
||||||
my $varStatistics = JSON->new->decode($varStatisticsEncoded);
|
my $varStatistics = JSON->new->decode($varStatisticsEncoded);
|
||||||
|
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
|
|
@ -412,7 +413,7 @@ cmp_deeply(
|
||||||
best_rating_loop => [{
|
best_rating_loop => [{
|
||||||
url => '/'.$matrixListing->get('url'),
|
url => '/'.$matrixListing->get('url'),
|
||||||
category=> 'category1',
|
category=> 'category1',
|
||||||
name => 'untitled',
|
name => 'Untitled',
|
||||||
mean => 2,
|
mean => 2,
|
||||||
median => 3,
|
median => 3,
|
||||||
count => 10,
|
count => 10,
|
||||||
|
|
@ -420,7 +421,7 @@ cmp_deeply(
|
||||||
{
|
{
|
||||||
url => '/'.$matrixListing->get('url'),
|
url => '/'.$matrixListing->get('url'),
|
||||||
category=> 'category2',
|
category=> 'category2',
|
||||||
name => 'untitled',
|
name => 'Untitled',
|
||||||
mean => 7,
|
mean => 7,
|
||||||
median => 9,
|
median => 9,
|
||||||
count => 10,
|
count => 10,
|
||||||
|
|
@ -428,7 +429,7 @@ cmp_deeply(
|
||||||
worst_rating_loop => [{
|
worst_rating_loop => [{
|
||||||
url => '/'.$matrixListing->get('url'),
|
url => '/'.$matrixListing->get('url'),
|
||||||
category=> 'category1',
|
category=> 'category1',
|
||||||
name => 'untitled',
|
name => 'Untitled',
|
||||||
mean => 2,
|
mean => 2,
|
||||||
median => 3,
|
median => 3,
|
||||||
count => 10,
|
count => 10,
|
||||||
|
|
@ -436,7 +437,7 @@ cmp_deeply(
|
||||||
{
|
{
|
||||||
url => '/'.$matrixListing->get('url'),
|
url => '/'.$matrixListing->get('url'),
|
||||||
category=> 'category2',
|
category=> 'category2',
|
||||||
name => 'untitled',
|
name => 'Untitled',
|
||||||
mean => 7,
|
mean => 7,
|
||||||
median => 9,
|
median => 9,
|
||||||
count => 10,
|
count => 10,
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ open my $rssFile, '<', WebGUI::Test->getTestCollateralPath('tbb.rss')
|
||||||
or die "Unable to get RSS file";
|
or die "Unable to get RSS file";
|
||||||
my $rssContent = do { local $/; <$rssFile>; };
|
my $rssContent = do { local $/; <$rssFile>; };
|
||||||
close $rssFile;
|
close $rssFile;
|
||||||
$session->cache->set($tbbUrl.'RSS', $rssContent, 60);
|
$session->cache->set($tbbUrl, $rssContent, 60);
|
||||||
|
|
||||||
my $filteredFeed = $syndicated_content->generateFeed();
|
my $filteredFeed = $syndicated_content->generateFeed();
|
||||||
|
|
||||||
|
|
@ -170,7 +170,7 @@ cmp_deeply(
|
||||||
'generateFeed: filters items based on the terms being in title, or description'
|
'generateFeed: filters items based on the terms being in title, or description'
|
||||||
);
|
);
|
||||||
|
|
||||||
$session->cache->clear;
|
$session->cache->remove($tbbUrl);
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
#
|
#
|
||||||
|
|
@ -191,13 +191,12 @@ open my $rssFile, '<', WebGUI::Test->getTestCollateralPath('oncp.xml')
|
||||||
or die "Unable to get RSS file: oncp.xml";
|
or die "Unable to get RSS file: oncp.xml";
|
||||||
my $rssContent = do { local $/; <$rssFile>; };
|
my $rssContent = do { local $/; <$rssFile>; };
|
||||||
close $rssFile;
|
close $rssFile;
|
||||||
$session->cache->set($oncpUrl.'RSS', $rssContent, 60);
|
$session->cache->set($oncpUrl, $rssContent, 60);
|
||||||
|
|
||||||
my $oddFeed1 = $syndicated_content->generateFeed();
|
my $oddFeed1 = $syndicated_content->generateFeed();
|
||||||
|
|
||||||
my @oddItems = $oddFeed1->get_item();
|
my @oddItems = $oddFeed1->get_item();
|
||||||
is (@oddItems, 13, 'feed has items even without pubDates or links');
|
is (@oddItems, 13, 'feed has items even without pubDates or links');
|
||||||
|
|
||||||
$session->cache->clear;
|
$session->cache->remove($oncpUrl);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,6 @@ use Storable qw/dclone/;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
my @getTitleTests = getTitleTests($session);
|
|
||||||
|
|
||||||
my $rootAsset = WebGUI::Asset->getRoot($session);
|
my $rootAsset = WebGUI::Asset->getRoot($session);
|
||||||
|
|
||||||
##Test users.
|
##Test users.
|
||||||
|
|
@ -151,340 +149,12 @@ $canViewMaker->prepare(
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
plan tests => 114
|
plan tests => $canAddMaker->plan
|
||||||
+ 2*scalar(@getTitleTests) #same tests used for getTitle and getMenuTitle
|
|
||||||
+ $canAddMaker->plan
|
|
||||||
+ $canAddMaker2->plan
|
+ $canAddMaker2->plan
|
||||||
+ $canEditMaker->plan
|
+ $canEditMaker->plan
|
||||||
+ $canViewMaker->plan
|
+ $canViewMaker->plan
|
||||||
;
|
;
|
||||||
|
|
||||||
note "loadModule";
|
|
||||||
{
|
|
||||||
my $className = eval { WebGUI::Asset->loadModule('Moose::Asset'); };
|
|
||||||
my $e = Exception::Class->caught;
|
|
||||||
isa_ok($e, 'WebGUI::Error::InvalidParam', 'loadModule must get a WebGUI::Asset class');
|
|
||||||
cmp_deeply(
|
|
||||||
$e,
|
|
||||||
methods(
|
|
||||||
error => 'Not a WebGUI::Asset class',
|
|
||||||
param => 'Moose::Asset',
|
|
||||||
),
|
|
||||||
'... checking error message',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
# Test the default constructor
|
|
||||||
my $defaultAsset = WebGUI::Asset->getDefault($session);
|
|
||||||
is($defaultAsset, 'WebGUI::Asset::Wobject::Layout');
|
|
||||||
|
|
||||||
# Test the new constructor
|
|
||||||
my $assetId = "PBnav00000000000000001"; # one of the default nav assets
|
|
||||||
|
|
||||||
# - explicit class
|
|
||||||
my $asset = WebGUI::Asset->newById($session, $assetId);
|
|
||||||
isa_ok ($asset, 'WebGUI::Asset::Wobject::Navigation');
|
|
||||||
is ($asset->getId, $assetId, 'new constructor explicit - returns correct asset');
|
|
||||||
|
|
||||||
# - new by hashref properties
|
|
||||||
$asset = undef;
|
|
||||||
$asset = WebGUI::Asset->newByPropertyHashRef($session, {
|
|
||||||
className=>"WebGUI::Asset::Wobject::Navigation",
|
|
||||||
assetId=>$assetId
|
|
||||||
});
|
|
||||||
isa_ok ($asset, 'WebGUI::Asset::Wobject::Navigation');
|
|
||||||
is ($asset->getId, $assetId, 'new constructor newByHashref - returns correct asset');
|
|
||||||
|
|
||||||
# - implicit class
|
|
||||||
$asset = undef;
|
|
||||||
$asset = WebGUI::Asset::Wobject::Navigation->new($session, $assetId);
|
|
||||||
isa_ok ($asset, 'WebGUI::Asset::Wobject::Navigation');
|
|
||||||
is ($asset->getId, $assetId, 'new constructor implicit - returns correct asset');
|
|
||||||
|
|
||||||
# - die gracefully
|
|
||||||
# -- no asset id
|
|
||||||
note "new, constructor fails";
|
|
||||||
{
|
|
||||||
my $deadAsset = eval { WebGUI::Asset->new($session, ''); };
|
|
||||||
my $e = Exception::Class->caught;
|
|
||||||
isa_ok($e, 'WebGUI::Error::InvalidParam', 'new must get an assetId');
|
|
||||||
cmp_deeply(
|
|
||||||
$e,
|
|
||||||
methods(
|
|
||||||
error => 'Asset constructor new() requires an assetId.',
|
|
||||||
),
|
|
||||||
'... checking error message',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
# -- no class
|
|
||||||
my $primevalAsset = WebGUI::Asset->new($session, $assetId);
|
|
||||||
isa_ok ($primevalAsset, 'WebGUI::Asset');
|
|
||||||
|
|
||||||
# Test the newById Constructor
|
|
||||||
$asset = undef;
|
|
||||||
|
|
||||||
note "new";
|
|
||||||
use WebGUI::Asset::Wobject::Navigation;
|
|
||||||
$asset = WebGUI::Asset::Wobject::Navigation->new($session, $assetId);
|
|
||||||
isa_ok ($asset, 'WebGUI::Asset::Wobject::Navigation');
|
|
||||||
is ($asset->getId, $assetId, 'new constructor - returns correct asset when invoked with correct class');
|
|
||||||
|
|
||||||
note "getClassById";
|
|
||||||
{
|
|
||||||
my $deadAsset = eval { WebGUI::Asset->getClassById($session, 'RoysNonExistantAssetId'); };
|
|
||||||
my $e = Exception::Class->caught;
|
|
||||||
isa_ok($e, 'WebGUI::Error::InvalidParam', 'getClassById must have a valid assetId');
|
|
||||||
cmp_deeply(
|
|
||||||
$e,
|
|
||||||
methods(
|
|
||||||
error => "Couldn't lookup classname",
|
|
||||||
param => 'RoysNonExistantAssetId',
|
|
||||||
),
|
|
||||||
'... checking error message',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
note "newById";
|
|
||||||
{
|
|
||||||
my $deadAsset = eval { WebGUI::Asset->newById($session); };
|
|
||||||
my $e = Exception::Class->caught;
|
|
||||||
isa_ok($e, 'WebGUI::Error::InvalidParam', "newById won't work without an assetId");
|
|
||||||
cmp_deeply(
|
|
||||||
$e,
|
|
||||||
methods(
|
|
||||||
error => "newById must get an assetId",
|
|
||||||
),
|
|
||||||
'... checking error message',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
# -- no session
|
|
||||||
# Root Asset
|
|
||||||
isa_ok($rootAsset, 'WebGUI::Asset');
|
|
||||||
is($rootAsset->getId, 'PBasset000000000000001', 'Root Asset ID check');
|
|
||||||
|
|
||||||
# getMedia Constructor
|
|
||||||
|
|
||||||
my $mediaFolder = WebGUI::Asset->getMedia($session);
|
|
||||||
isa_ok($mediaFolder, 'WebGUI::Asset::Wobject::Folder');
|
|
||||||
is($mediaFolder->getId, 'PBasset000000000000003', 'Media Folder Asset ID check');
|
|
||||||
|
|
||||||
# getImportNode Constructor
|
|
||||||
|
|
||||||
my $importNode = WebGUI::Asset->getImportNode($session);
|
|
||||||
isa_ok($importNode, 'WebGUI::Asset::Wobject::Folder');
|
|
||||||
is($importNode->getId, 'PBasset000000000000002', 'Import Node Asset ID check');
|
|
||||||
is($importNode->getParent->getId, $rootAsset->getId, 'Import Nodes parent is Root Asset');
|
|
||||||
|
|
||||||
# tempspace Constructor
|
|
||||||
|
|
||||||
my $tempNode = WebGUI::Asset->getTempspace($session);
|
|
||||||
isa_ok($tempNode, 'WebGUI::Asset::Wobject::Folder');
|
|
||||||
is($tempNode->getId, 'tempspace0000000000000', 'Tempspace Asset ID check');
|
|
||||||
is($tempNode->getParent->getId, $rootAsset->getId, 'Tempspace parent is Root Asset');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# urlExists
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
##We need an asset with a URL for this one.
|
|
||||||
|
|
||||||
my $importUrl = $importNode->get('url');
|
|
||||||
my $importId = $importNode->getId;
|
|
||||||
|
|
||||||
ok( WebGUI::Asset->urlExists($session, $importUrl), 'url for import node exists');
|
|
||||||
ok( WebGUI::Asset->urlExists($session, uc($importUrl)), 'url for import node exists, case insensitive');
|
|
||||||
ok( !WebGUI::Asset->urlExists($session, '/foo/bar/baz'), 'made up url does not exist');
|
|
||||||
|
|
||||||
ok( !WebGUI::Asset->urlExists($session, $importUrl, {assetId => $importId}), 'url for import node only exists at specific id');
|
|
||||||
ok( !WebGUI::Asset->urlExists($session, '/foo/bar/baz', {assetId => $importId}), 'imaginary url does not exist at specific id');
|
|
||||||
ok( WebGUI::Asset->urlExists($session, $importUrl, {assetId => 'notAnWebGUIId'}), 'imaginary url does not exist at wrong id');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# addEditLabel
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my $i18n = WebGUI::International->new($session, 'Asset_Wobject');
|
|
||||||
is($importNode->addEditLabel, $i18n->get('edit').' '.$importNode->getName, 'addEditLabel, default mode is edit mode');
|
|
||||||
|
|
||||||
my $origRequest = $session->{_request};
|
|
||||||
my $newRequest = Test::MockObject->new();
|
|
||||||
my $func;
|
|
||||||
$newRequest->set_bound('body', \$func);
|
|
||||||
$newRequest->set_bound('param', \$func);
|
|
||||||
$session->{_request} = $newRequest;
|
|
||||||
$func = 'add';
|
|
||||||
is($importNode->addEditLabel, $i18n->get('add').' '.$importNode->getName, 'addEditLabel, use add mode');
|
|
||||||
$session->{_request} = $origRequest;
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# fixUrl
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
|
||||||
WebGUI::Test->tagsToRollback($versionTag);
|
|
||||||
$versionTag->set({name=>"Asset tests"});
|
|
||||||
|
|
||||||
$properties = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'fixUrlAsset00000000012',
|
|
||||||
title => 'fixUrl Asset Test',
|
|
||||||
className => 'WebGUI::Asset::Wobject::Folder',
|
|
||||||
url => 'fixUrlFolderURL2',
|
|
||||||
};
|
|
||||||
|
|
||||||
my $fixUrlAsset = $defaultAsset->addChild($properties, $properties->{id});
|
|
||||||
|
|
||||||
# '1234567890123456789012'
|
|
||||||
$properties->{id} = 'fixUrlAsset00000000013';
|
|
||||||
$properties->{url} = 'fixUrlFolderURL9';
|
|
||||||
|
|
||||||
my $fixUrlAsset2 = $defaultAsset->addChild($properties, $properties->{id});
|
|
||||||
|
|
||||||
# '1234567890123456789012'
|
|
||||||
$properties->{id} = 'fixUrlAsset00000000014';
|
|
||||||
$properties->{url} = 'fixUrlFolderURL00';
|
|
||||||
|
|
||||||
my $fixUrlAsset3 = $defaultAsset->addChild($properties, $properties->{id});
|
|
||||||
|
|
||||||
# '1234567890123456789012'
|
|
||||||
$properties->{id} = 'fixUrlAsset00000000015';
|
|
||||||
$properties->{url} = 'fixUrlFolderURL100';
|
|
||||||
|
|
||||||
my $fixUrlAsset4 = $defaultAsset->addChild($properties, $properties->{id});
|
|
||||||
is($fixUrlAsset4->get('url'), 'fixurlfolderurl100', 'asset setup correctly for 100->101 test');
|
|
||||||
|
|
||||||
delete $properties->{url};
|
|
||||||
# '1234567890123456789012'
|
|
||||||
$properties->{id} = 'fixUrlAsset00000000016';
|
|
||||||
$properties->{menuTitle} = 'fix url folder url autogenerated';
|
|
||||||
|
|
||||||
my $fixUrlAsset5 = $defaultAsset->addChild($properties, $properties->{id});
|
|
||||||
|
|
||||||
my $properties2 = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'fixTitleAsset000000010',
|
|
||||||
title => '',
|
|
||||||
className => 'WebGUI::Asset::Snippet',
|
|
||||||
url => 'fixTitleAsset1',
|
|
||||||
};
|
|
||||||
|
|
||||||
my $fixTitleAsset = $defaultAsset->addChild($properties2, $properties2->{id});
|
|
||||||
##Commit this asset right away
|
|
||||||
$fixTitleAsset->commit;
|
|
||||||
|
|
||||||
$properties2 = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'getTitleAsset000000010',
|
|
||||||
title => '',
|
|
||||||
className => 'WebGUI::Asset::Snippet',
|
|
||||||
url => 'getTitleAsset1',
|
|
||||||
};
|
|
||||||
|
|
||||||
my $getTitleAsset = $defaultAsset->addChild($properties2, $properties2->{id});
|
|
||||||
$getTitleAsset->commit;
|
|
||||||
|
|
||||||
$versionTag->commit;
|
|
||||||
|
|
||||||
$session->setting->set('urlExtension', undef);
|
|
||||||
|
|
||||||
is($importNode->fixUrl('1234'.'-'x235 . 'abcdefghij'), '1234'.'-'x235 . 'abcdefghij', 'fixUrl leaves long URLs under 250 characters alone');
|
|
||||||
is($importNode->fixUrl('1234'.'-'x250 . 'abcdefghij'), '1234'.'-'x216, 'fixUrl truncates long URLs over 250 characters to 220 characters');
|
|
||||||
|
|
||||||
WebGUI::Test->originalConfig('extrasURL');
|
|
||||||
WebGUI::Test->originalConfig('uploadsURL');
|
|
||||||
WebGUI::Test->originalConfig('assets');
|
|
||||||
|
|
||||||
$session->config->set('extrasURL', '/extras');
|
|
||||||
$session->config->set('uploadsURL', '/uploads');
|
|
||||||
|
|
||||||
is($importNode->fixUrl('/extras'), '_extras', 'underscore prepended to URLs that match the extrasURL');
|
|
||||||
is($importNode->fixUrl('/uploads'), '_uploads', 'underscore prepended to URLs that match the uploadsURL');
|
|
||||||
|
|
||||||
#Now that we have verified that extrasURL and uploadsURL both work, just test one.
|
|
||||||
$session->config->set('extrasURL', '/extras1/');
|
|
||||||
is($importNode->fixUrl('/extras1'), '_extras1', 'trailing underscore in extrasURL does not defeat the check');
|
|
||||||
|
|
||||||
$session->config->set('extrasURL', 'http://mysite.com/extras2');
|
|
||||||
is($importNode->fixUrl('/extras2'), '_extras2', 'underscore prepended to URLs that match the extrasURL, even with http://');
|
|
||||||
|
|
||||||
##Now, check extension removal
|
|
||||||
|
|
||||||
is($importNode->fixUrl('one.html/two.html'), 'one/two.html', 'extensions are not allowed higher up in the path');
|
|
||||||
is($importNode->fixUrl('one.html/two.html/three.html'), 'one/two/three.html', 'extensions are not allowed anywhere in the path');
|
|
||||||
is($importNode->fixUrl('one.one.html/two.html/three.html'), 'one/two/three.html', 'multiple dot extensions are removed in any path element');
|
|
||||||
is($importNode->fixUrl('.startsWithDot'), '.startswithdot', 'leading dots are okay');
|
|
||||||
|
|
||||||
##Now, check duplicate URLs
|
|
||||||
|
|
||||||
is($importNode->fixUrl('/rootyRootRoot'), 'rootyrootroot', 'URLs are lowercased');
|
|
||||||
is($importNode->fixUrl('/root'), 'root2', 'If a node exists, appends a "2" to it');
|
|
||||||
my $importNodeURL = $importNode->getUrl;
|
|
||||||
$importNodeURL =~ s{ ^ / }{}x;
|
|
||||||
is($importNode->fixUrl($importNodeURL), $importNodeURL, q{fixing an asset's own URL returns it unchanged});
|
|
||||||
|
|
||||||
is($importNode->fixUrl('fixUrlFolderURL2'), 'fixurlfolderurl3', 'if a URL exists, fix it by incrementing any ending digits 2 -> 3');
|
|
||||||
is($importNode->fixUrl('fixUrlFolderURL9'), 'fixurlfolderurl10', 'increments past single digits 9 -> 10');
|
|
||||||
is($importNode->fixUrl('fixUrlFolderURL00'), 'fixurlfolderurl1', 'initial zeroes are not preserved 00 -> 1');
|
|
||||||
is($importNode->fixUrl('fixUrlFolderURL100'), 'fixurlfolderurl101', '100->101');
|
|
||||||
|
|
||||||
is($fixUrlAsset5->fixUrl(), 'home/fix-url-folder-url-autogenerated', 'fixUrl will autogenerate a url if not provided one');
|
|
||||||
|
|
||||||
# Automatic extension adding
|
|
||||||
$session->setting->set('urlExtension', 'html');
|
|
||||||
is($importNode->fixUrl('fixurl'), 'fixurl.html', 'Automatic adding of extensions works');
|
|
||||||
is($importNode->fixUrl('fixurl.css'), 'fixurl.css', 'extensions aren\'t automatically added if there is already and extension');
|
|
||||||
$session->setting->set('urlExtension', undef);
|
|
||||||
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getTitle
|
|
||||||
# getMenuTitle
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my $getTitleAssetName = $getTitleAsset->getName();
|
|
||||||
|
|
||||||
foreach my $test (@getTitleTests) {
|
|
||||||
my $expectedTitle = $test->{assetName} ? $getTitleAssetName : $test->{title};
|
|
||||||
$getTitleAsset->update({
|
|
||||||
title => $test->{title},
|
|
||||||
menuTitle => $test->{title},
|
|
||||||
});
|
|
||||||
is($getTitleAsset->getTitle, $expectedTitle, $test->{comment});
|
|
||||||
is($getTitleAsset->getMenuTitle, $expectedTitle, $test->{comment});
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getIcon
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
like($importNode->getIcon, qr{folder.gif$}, 'getIcon gets correct icon for importNode');
|
|
||||||
like($importNode->getIcon(1), qr{small/folder.gif$}, 'getIcon gets small icon for importNode');
|
|
||||||
|
|
||||||
my $extras = $session->config->get('extrasURL');
|
|
||||||
|
|
||||||
like($importNode->getIcon(), qr{$extras}, 'getIcon returns an icon from the extras URL');
|
|
||||||
|
|
||||||
like($defaultAsset->getIcon, qr{layout.gif$}, 'getIcon gets icon for a layout');
|
|
||||||
like($fixTitleAsset->getIcon, qr{snippet.gif$}, 'getIcon gets icon for a snippet');
|
|
||||||
|
|
||||||
|
|
||||||
TODO: {
|
|
||||||
local $TODO = "Coverage test";
|
|
||||||
ok(0, "Test the default name for the icon, if not given in the definition sub");
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
#
|
#
|
||||||
# canAdd
|
# canAdd
|
||||||
|
|
@ -515,388 +185,4 @@ $canEditMaker->run;
|
||||||
|
|
||||||
$canViewMaker->run;
|
$canViewMaker->run;
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# addMissing
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
$session->user({ userId => 3 });
|
|
||||||
$session->var->switchAdminOff;
|
|
||||||
is($canEditAsset->addMissing('/nowhereMan'), undef, q{addMissing doesn't return anything unless use is in Admin Mode});
|
|
||||||
|
|
||||||
$session->var->switchAdminOn;
|
|
||||||
my $addMissing = $canEditAsset->addMissing('/nowhereMan');
|
|
||||||
ok($addMissing, 'addMissing returns some output when in Admin Mode');
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
my $parser = HTML::TokeParser->new(\$addMissing);
|
|
||||||
my $link = $parser->get_tag('a');
|
|
||||||
my $url = $link->[1]{'href'} || '-';
|
|
||||||
like($url, qr{func=add;class=WebGUI::Asset::Wobject::Layout;url=/nowhereMan$}, 'addMissing: Link will add a new page asset with correct URL');
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getContainer
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
is($rootAsset->getContainer->getId, $rootAsset->getId, 'getContainer: A folder is a container, its container is itself');
|
|
||||||
is($fixTitleAsset->getContainer->getId, $defaultAsset->getId, 'getContainer: A snippet is not a container, its container is its parent');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getName
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
is($fixTitleAsset->getName, $i18n->get('assetName', 'Asset_Snippet'), 'getName: Returns the internationalized name of the Asset, Snippet');
|
|
||||||
is($importNode->getName, $i18n->get('assetName', 'Asset_Folder'), 'getName: Returns the internationalized name of the Asset, Folder');
|
|
||||||
is($canEditAsset->getName, $i18n->get('asset', 'Asset'), 'getName: Returns the internationalized name of the Asset, core Asset');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getToolbarState
|
|
||||||
# toggleToolbar
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
is($getTitleAsset->getToolbarState, undef, 'getToolbarState: default toolbar state is undef');
|
|
||||||
$getTitleAsset->toggleToolbar();
|
|
||||||
is($getTitleAsset->getToolbarState, 1, 'getToolbarState: toggleToolbarState toggled the state to 1');
|
|
||||||
$getTitleAsset->toggleToolbar();
|
|
||||||
is($getTitleAsset->getToolbarState, 0, 'getToolbarState: toggleToolbarState toggled the state to 0');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getUiLevel
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
is($canEditAsset->getUiLevel, 1, 'getUiLevel: WebGUI::Asset uses the default uiLevel of 1');
|
|
||||||
is($fixTitleAsset->getUiLevel, 5, 'getUiLevel: Snippet has an uiLevel of 5');
|
|
||||||
|
|
||||||
my $origAssetUiLevel = $session->config->get('assetUiLevel');
|
|
||||||
$session->config->set('assets/WebGUI::Asset/uiLevel', 8);
|
|
||||||
$session->config->set('assets/WebGUI::Asset::Snippet/uiLevel', 8);
|
|
||||||
|
|
||||||
is($canEditAsset->getUiLevel, 8, 'getUiLevel: WebGUI::Asset has a configured uiLevel of 8');
|
|
||||||
is($fixTitleAsset->getUiLevel, 8, 'getUiLevel: Snippet has a configured uiLevel of 8');
|
|
||||||
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# isValidRssItem
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
is($canViewAsset->isValidRssItem, 1, 'isValidRssItem: By default, all Assets are valid RSS items');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getEditTabs
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my @tabs = $canViewAsset->getEditTabs;
|
|
||||||
is(scalar(@tabs), 4, 'getEditTabs: 4 tabs by default');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getEditForm
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
$session->style->sent(0); ##Prevent extra output from being generated by session->style
|
|
||||||
##At some point, a test will need to tie STDOUT and make sure
|
|
||||||
##that the output is correct.
|
|
||||||
isa_ok($canViewAsset->getEditForm, 'WebGUI::TabForm', 'getEditForm: Returns a tabForm');
|
|
||||||
|
|
||||||
TODO: {
|
|
||||||
local $TODO = 'More getEditForm tests';
|
|
||||||
ok(0, 'Validate form output');
|
|
||||||
}
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# newById
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my $newFixTitleAsset = WebGUI::Asset->newById($session, $fixTitleAsset->getId);
|
|
||||||
isnt($newFixTitleAsset, undef, 'newById did not fail');
|
|
||||||
isa_ok($newFixTitleAsset, 'WebGUI::Asset', 'newById: able to look up an existing asset by id');
|
|
||||||
cmp_deeply($newFixTitleAsset->{_properties}, $fixTitleAsset->{_properties}, 'newById created a duplicate asset');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getNotFound
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my $origNotFoundPage = $session->setting->get('notFoundPage');
|
|
||||||
|
|
||||||
$session->setting->set('notFoundPage', WebGUI::Asset->getDefault($session)->getId);
|
|
||||||
|
|
||||||
isa_ok(WebGUI::Asset->getNotFound($session), 'WebGUI::Asset', 'getNotFound: Returns an asset');
|
|
||||||
is(WebGUI::Asset->getNotFound($session)->getId, WebGUI::Asset->getDefault($session)->getId, 'getNotFound: Returns the correct asset');
|
|
||||||
|
|
||||||
$session->setting->set('notFoundPage', $fixTitleAsset->getId);
|
|
||||||
is(WebGUI::Asset->getNotFound($session)->getId, $fixTitleAsset->getId, 'getNotFound: Returns the correct asset on a different asset');
|
|
||||||
|
|
||||||
$session->setting->set('notFoundPage', $origNotFoundPage);
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# isExportable
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
is($rootAsset->get('isExportable'), 1, 'isExportable exists, defaults to 1');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getSeparator
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
is($rootAsset->getSeparator, '~~~PBasset000000000000001~~~', 'getSeparator, known assetId');
|
|
||||||
is($rootAsset->getSeparator('!'), '!!!PBasset000000000000001!!!', 'getSeparator, given pad character');
|
|
||||||
isnt($rootAsset->getSeparator, $mediaFolder->getSeparator, 'getSeparator: unique string');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# get
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
my $assetProps = $rootAsset->get();
|
|
||||||
my $funkyTitle = q{Miss Annie's Whoopie Emporium and Sasparilla Shop};
|
|
||||||
$assetProps->{title} = $funkyTitle;
|
|
||||||
|
|
||||||
isnt( $rootAsset->get('title'), $funkyTitle, 'get returns a safe copy of the Asset properties');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# getIsa
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
my $node = WebGUI::Asset->getRoot($session);
|
|
||||||
my $product1 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'});
|
|
||||||
my $product2 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'});
|
|
||||||
my $product3 = $node->addChild({ className => 'WebGUI::Asset::Sku::Product'});
|
|
||||||
|
|
||||||
my $getAProduct = WebGUI::Asset::Sku::Product->getIsa($session);
|
|
||||||
isa_ok($getAProduct, 'CODE', 'getIsa returns a sub ref');
|
|
||||||
my $counter = 0;
|
|
||||||
my $productIds = [];
|
|
||||||
while( my $product = $getAProduct->()) {
|
|
||||||
++$counter;
|
|
||||||
push @{ $productIds }, $product->getId;
|
|
||||||
}
|
|
||||||
is($counter, 3, 'getIsa: returned only 3 Products');
|
|
||||||
cmp_bag($productIds, [$product1->getId, $product2->getId, $product3->getId], 'getIsa returned the correct 3 products');
|
|
||||||
|
|
||||||
my $getASku = WebGUI::Asset::Sku->getIsa($session);
|
|
||||||
$counter = 0;
|
|
||||||
my $skuIds = [];
|
|
||||||
while( my $sku = $getASku->()) {
|
|
||||||
++$counter;
|
|
||||||
push @{ $skuIds }, $sku->getId;
|
|
||||||
}
|
|
||||||
is($counter, 3, 'getIsa: returned only 3 Products for a parent class');
|
|
||||||
cmp_bag($skuIds, [$product1->getId, $product2->getId, $product3->getId], 'getIsa returned the correct 3 products for a parent class');
|
|
||||||
|
|
||||||
$product1->purge;
|
|
||||||
$product2->purge;
|
|
||||||
$product3->purge;
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# inheritUrlFromParent
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my $versionTag4 = WebGUI::VersionTag->getWorking($session);
|
|
||||||
WebGUI::Test->tagsToRollback($versionTag4);
|
|
||||||
$versionTag4->set( { name => 'inheritUrlFromParent tests' } );
|
|
||||||
|
|
||||||
$properties = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'inheritUrlFromParent01',
|
|
||||||
title => 'inheritUrlFromParent01',
|
|
||||||
className => 'WebGUI::Asset::Wobject::Layout',
|
|
||||||
url => 'inheriturlfromparent01',
|
|
||||||
};
|
|
||||||
|
|
||||||
my $iufpAsset = $defaultAsset->addChild($properties, $properties->{id});
|
|
||||||
$iufpAsset->commit;
|
|
||||||
|
|
||||||
$properties2 = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'inheritUrlFromParent02',
|
|
||||||
title => 'inheritUrlFromParent02',
|
|
||||||
className => 'WebGUI::Asset::Wobject::Layout',
|
|
||||||
url => 'inheriturlfromparent02',
|
|
||||||
};
|
|
||||||
|
|
||||||
my $iufpAsset2 = $iufpAsset->addChild($properties2, $properties2->{id});
|
|
||||||
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
|
|
||||||
$iufpAsset2->commit;
|
|
||||||
is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', 'inheritUrlFromParent works');
|
|
||||||
|
|
||||||
my $properties2a = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'inheritUrlFromParent2a',
|
|
||||||
title => 'inheritUrlFromParent2a',
|
|
||||||
className => 'WebGUI::Asset::Wobject::Layout',
|
|
||||||
url => 'inheriturlfromparent2a',
|
|
||||||
inheritUrlFromParent => 1,
|
|
||||||
};
|
|
||||||
|
|
||||||
my $iufpAsset2a = $iufpAsset->addChild($properties2a, $properties2a->{id});
|
|
||||||
$iufpAsset2a->commit;
|
|
||||||
is($iufpAsset2a->get('url'), 'inheriturlfromparent01/inheriturlfromparent2a', '... works when created with the property');
|
|
||||||
|
|
||||||
# works for setting, now try disabling. Should not change the URL.
|
|
||||||
$iufpAsset2->update( { inheritUrlFromParent => 0 } );
|
|
||||||
$iufpAsset2->commit;
|
|
||||||
is($iufpAsset2->get('url'), 'inheriturlfromparent01/inheriturlfromparent02', '... setting inheritUrlFromParent to 0 works');
|
|
||||||
|
|
||||||
# also make sure that it is actually disabled
|
|
||||||
is($iufpAsset2->get('inheritUrlFromParent'), 0, "... disabling inheritUrlFromParent actually works");
|
|
||||||
|
|
||||||
# works for setting and disabling, now ensure it recurses
|
|
||||||
|
|
||||||
my $properties3 = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'inheritUrlFromParent03',
|
|
||||||
title => 'inheritUrlFromParent03',
|
|
||||||
className => 'WebGUI::Asset::Wobject::Layout',
|
|
||||||
url => 'inheriturlfromparent03',
|
|
||||||
};
|
|
||||||
my $iufpAsset3 = $iufpAsset2->addChild($properties3, $properties3->{id});
|
|
||||||
$iufpAsset3->commit;
|
|
||||||
$iufpAsset2->update( { inheritUrlFromParent => 1 } );
|
|
||||||
$iufpAsset2->commit;
|
|
||||||
$iufpAsset3->update( { inheritUrlFromParent => 1 } );
|
|
||||||
$iufpAsset3->commit;
|
|
||||||
is($iufpAsset3->get('url'), 'inheriturlfromparent01/inheriturlfromparent02/inheriturlfromparent03', '... recurses properly');
|
|
||||||
|
|
||||||
$iufpAsset2->update({url => 'iufp2'});
|
|
||||||
is($iufpAsset2->get('url'), 'inheriturlfromparent01/iufp2', '... update works propertly when iUFP is not passed');
|
|
||||||
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# requestAutoCommit to move uncommitted child to uncommitted parent
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my $versionTag5 = WebGUI::VersionTag->getWorking($session);
|
|
||||||
WebGUI::Test->tagsToRollback($versionTag5);
|
|
||||||
$versionTag5->set( { name => 'move commit of child to uncommitted parent on requestAutoCommit tests vt1' } );
|
|
||||||
|
|
||||||
$properties = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'moveVersionToParent_01',
|
|
||||||
title => 'moveVersionToParent_01',
|
|
||||||
className => 'WebGUI::Asset::Wobject::Layout',
|
|
||||||
url => 'moveVersionToParent_01',
|
|
||||||
};
|
|
||||||
|
|
||||||
my $parentAsset = $defaultAsset->addChild($properties, $properties->{id});
|
|
||||||
my $parentVersionTag = WebGUI::VersionTag->new($session, $parentAsset->get('tagId'));
|
|
||||||
is($parentVersionTag->get('isCommitted'),0, 'built non-committed parent asset');
|
|
||||||
|
|
||||||
|
|
||||||
my $versionTag6 = WebGUI::VersionTag->create($session, {});
|
|
||||||
WebGUI::Test->tagsToRollback($versionTag6);
|
|
||||||
$versionTag6->set( { name => 'move commit of child to uncommitted parent on requestAutoCommit tests vt2' } );
|
|
||||||
$versionTag6->setWorking;
|
|
||||||
|
|
||||||
$properties2 = {
|
|
||||||
# '1234567890123456789012'
|
|
||||||
id => 'moveVersionToParent_03',
|
|
||||||
title => 'moveVersionToParent_03',
|
|
||||||
className => 'WebGUI::Asset::Wobject::Layout',
|
|
||||||
url => 'moveVersionToParent_03',
|
|
||||||
};
|
|
||||||
|
|
||||||
my $childAsset = $parentAsset->addChild($properties, $properties2->{id});
|
|
||||||
my $testAsset = WebGUI::Asset->newPending($session, $childAsset->get('parentId'));
|
|
||||||
my $testVersionTag = WebGUI::VersionTag->new($session, $testAsset->get('tagId'));
|
|
||||||
|
|
||||||
my $childVersionTag;
|
|
||||||
$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
|
|
||||||
is($childVersionTag->get('isCommitted'),0, 'built non-committed child asset');
|
|
||||||
|
|
||||||
isnt($testAsset->get('tagId'),$childAsset->get('tagId'),'parent asset and child asset have different version tags');
|
|
||||||
isnt($testVersionTag->getId,$childVersionTag->getId,'parent asset and child asset version tags unmatched');
|
|
||||||
|
|
||||||
eval {
|
|
||||||
$childAsset->requestAutoCommit;
|
|
||||||
$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
|
|
||||||
};
|
|
||||||
is($childVersionTag->get('isCommitted'),0, 'confirm non-committed child asset');
|
|
||||||
|
|
||||||
is($testAsset->get('tagId'),$childAsset->get('tagId'),'parent asset and child asset have same version tags');
|
|
||||||
|
|
||||||
eval {
|
|
||||||
$testVersionTag->commit;
|
|
||||||
};
|
|
||||||
|
|
||||||
is($testVersionTag->get('isCommitted'),1,'parent asset is now committed');
|
|
||||||
|
|
||||||
$childVersionTag = WebGUI::VersionTag->new($session, $childAsset->get('tagId'));
|
|
||||||
is($childVersionTag->get('isCommitted'),1,'child asset is now committed');
|
|
||||||
|
|
||||||
################################################################
|
|
||||||
#
|
|
||||||
# cloneFromDb
|
|
||||||
#
|
|
||||||
################################################################
|
|
||||||
|
|
||||||
my $assetToCommit = $defaultAsset->addChild({ className => 'WebGUI::Asset::Snippet', title => 'Snippet to commit and clone from db', });
|
|
||||||
my $cloneTag = WebGUI::VersionTag->getWorking($session);
|
|
||||||
WebGUI::Test->tagsToRollback($cloneTag);
|
|
||||||
$cloneTag->commit;
|
|
||||||
is($assetToCommit->get('status'), 'pending', 'cloneFromDb: local asset is still pending');
|
|
||||||
$assetToCommit = $assetToCommit->cloneFromDb;
|
|
||||||
is($assetToCommit->get('status'), 'approved', '... returns fresh, commited asset from the db');
|
|
||||||
|
|
||||||
##Return an array of hashrefs. Each hashref describes a test
|
|
||||||
|
|
||||||
##Return an array of hashrefs. Each hashref describes a test
|
|
||||||
##for the getTitle and getMenuTitle tests. If "assetName" != 0, they
|
|
||||||
##will return the Asset's internationalized name.
|
|
||||||
|
|
||||||
sub getTitleTests {
|
|
||||||
my $session = shift;
|
|
||||||
return ({
|
|
||||||
title => undef,
|
|
||||||
assetName => 1,
|
|
||||||
comment => "getTitle: undef returns the Asset's name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title => '',
|
|
||||||
assetName => 1,
|
|
||||||
comment => "getTitle: null string returns the Asset's name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title => 'untitled',
|
|
||||||
assetName => 1,
|
|
||||||
comment => "getTitle: 'untitled' returns the Asset's name",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title => 'UnTiTlEd',
|
|
||||||
assetName => 1,
|
|
||||||
comment => "getTitle: 'untitled' in any case returns the Asset's title",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title => 'This is a good Title',
|
|
||||||
assetName => 0,
|
|
||||||
comment => "getTitle: Good titles are passed",
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ use WebGUI::Shop::Ship;
|
||||||
use WebGUI::Shop::Transaction;
|
use WebGUI::Shop::Transaction;
|
||||||
use JSON;
|
use JSON;
|
||||||
use HTML::Form;
|
use HTML::Form;
|
||||||
|
use WebGUI::Shop::PayDriver::ITransact;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Init
|
# Init
|
||||||
|
|
@ -34,26 +35,12 @@ my $session = WebGUI::Test->session;
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $tests = 28;
|
plan tests => 28;
|
||||||
plan tests => 1 + $tests;
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# figure out if the test can actually run
|
# figure out if the test can actually run
|
||||||
|
|
||||||
note('Testing existence');
|
|
||||||
my $loaded = use_ok('WebGUI::Shop::PayDriver::ITransact');
|
|
||||||
|
|
||||||
my $e;
|
my $e;
|
||||||
my $ship = WebGUI::Shop::Ship->new($session);
|
|
||||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
|
||||||
my $shipper = $ship->getShipper('defaultfreeshipping000');
|
|
||||||
my $address = $cart->getAddressBook->addAddress( { firstName => 'Ellis Boyd', lastName => 'Redding'} );
|
|
||||||
$cart->update({
|
|
||||||
shippingAddressId => $address->getId,
|
|
||||||
shipperId => $shipper->getId,
|
|
||||||
});
|
|
||||||
my $transaction;
|
|
||||||
|
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||||
|
|
||||||
my $home = WebGUI::Asset->getDefault($session);
|
my $home = WebGUI::Asset->getDefault($session);
|
||||||
|
|
@ -82,14 +69,22 @@ my $foreignHammer = $rockHammer->setCollateral('variantsJSON', 'variantId', 'new
|
||||||
|
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
WebGUI::Test->tagsToRollback($versionTag);
|
WebGUI::Test->addToCleanup($versionTag);
|
||||||
|
$rockHammer = $rockHammer->cloneFromDb;
|
||||||
|
|
||||||
|
my $ship = WebGUI::Shop::Ship->new($session);
|
||||||
|
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||||
|
WebGUI::Test->addToCleanup($cart);
|
||||||
|
my $shipper = $ship->getShipper('defaultfreeshipping000');
|
||||||
|
my $address = $cart->getAddressBook->addAddress( { firstName => 'Ellis Boyd', lastName => 'Redding'} );
|
||||||
|
$cart->update({
|
||||||
|
shippingAddressId => $address->getId,
|
||||||
|
shipperId => $shipper->getId,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
my $hammerItem = $rockHammer->addToCart($rockHammer->getCollateral('variantsJSON', 'variantId', $smallHammer));
|
my $hammerItem = $rockHammer->addToCart($rockHammer->getCollateral('variantsJSON', 'variantId', $smallHammer));
|
||||||
|
|
||||||
SKIP: {
|
|
||||||
|
|
||||||
skip 'Unable to load module WebGUI::Shop::PayDriver::ITransact', $tests unless $loaded;
|
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
# definition
|
# definition
|
||||||
|
|
@ -272,11 +267,12 @@ $driver->{_billingAddress} = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$transaction = WebGUI::Shop::Transaction->create($session, {
|
my $transaction = WebGUI::Shop::Transaction->create($session, {
|
||||||
paymentMethod => $driver,
|
paymentMethod => $driver,
|
||||||
cart => $cart,
|
cart => $cart,
|
||||||
isRecurring => $cart->requiresRecurringPayment,
|
isRecurring => $cart->requiresRecurringPayment,
|
||||||
});
|
});
|
||||||
|
WebGUI::Test->addToCleanup($transaction);
|
||||||
|
|
||||||
my $xml = $driver->_generatePaymentRequestXML($transaction);
|
my $xml = $driver->_generatePaymentRequestXML($transaction);
|
||||||
|
|
||||||
|
|
@ -292,11 +288,14 @@ TODO: {
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
SKIP: {
|
SKIP: {
|
||||||
skip "Skipping XML requests to ITransact due to lack of userId and password", 2 unless $hasTestAccount;
|
skip "Skipping XML requests to ITransact due to lack of real userId and password", 2 unless $hasTestAccount;
|
||||||
my $response = eval { $driver->doXmlRequest($xml) };
|
|
||||||
note 'doXmlrequest';
|
note 'doXmlrequest';
|
||||||
isa_ok($response, 'HTTP::Response', 'returns a HTTP::Response object');
|
my $response = eval { $driver->doXmlRequest($xml) };
|
||||||
ok( $response->is_success, '... was successful');
|
my $ok_response = isa_ok($response, 'HTTP::Response', 'returns a HTTP::Response object');
|
||||||
|
SKIP: {
|
||||||
|
skip "Skipping response check since we did not get a response", 1 unless $ok_response;
|
||||||
|
ok( $response->is_success, '... was successful');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
my $hammer2 = $rockHammer->addToCart($rockHammer->getCollateral('variantsJSON', 'variantId', $foreignHammer));
|
my $hammer2 = $rockHammer->addToCart($rockHammer->getCollateral('variantsJSON', 'variantId', $foreignHammer));
|
||||||
|
|
@ -313,7 +312,6 @@ SKIP: {
|
||||||
my $response = eval { $driver->doXmlRequest($xml) };
|
my $response = eval { $driver->doXmlRequest($xml) };
|
||||||
isa_ok($response, 'HTTP::Response', 'returns a HTTP::Response object');
|
isa_ok($response, 'HTTP::Response', 'returns a HTTP::Response object');
|
||||||
ok( $response->is_success, '... was successful');
|
ok( $response->is_success, '... was successful');
|
||||||
note $response->content;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
@ -332,13 +330,4 @@ is ($count, 0, 'delete deleted the object');
|
||||||
|
|
||||||
undef $driver;
|
undef $driver;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
|
||||||
# Cleanup
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
END: {
|
|
||||||
$cart->delete;
|
|
||||||
$transaction->delete if defined $transaction;
|
|
||||||
}
|
|
||||||
#vim:ft=perl
|
#vim:ft=perl
|
||||||
|
|
|
||||||
|
|
@ -110,6 +110,9 @@ my $blueFeather = $feather->setCollateral('variantsJSON', 'variantId', 'new',
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
addToCleanup($versionTag);
|
addToCleanup($versionTag);
|
||||||
|
foreach my $asset($rockHammer, $bible, $feather) {
|
||||||
|
$asset = $asset->cloneFromDb;
|
||||||
|
}
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,9 @@ my $gospels = $bible->setCollateral('variantsJSON', 'variantId', 'new',
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
addToCleanup($versionTag);
|
addToCleanup($versionTag);
|
||||||
|
foreach my $asset ($bible, $rockHammer) {
|
||||||
|
$asset = $asset->cloneFromDb;
|
||||||
|
}
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,9 @@ my $singlePage = $bible->setCollateral('variantsJSON', 'variantId', 'new',
|
||||||
|
|
||||||
$versionTag->commit;
|
$versionTag->commit;
|
||||||
addToCleanup($versionTag);
|
addToCleanup($versionTag);
|
||||||
|
foreach my $asset ($rockHammer, $bible) {
|
||||||
|
$asset = $asset->cloneFromDb;
|
||||||
|
}
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
#
|
#
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue