Merge branch 'master' of git@github.com:plainblack/webgui
Conflicts: lib/WebGUI/i18n/English/Asset_EMSSubmission.pm
This commit is contained in:
commit
60b04ff928
71 changed files with 686 additions and 176 deletions
|
|
@ -16,14 +16,14 @@ use lib "$FindBin::Bin/../lib";
|
|||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 16; # increment this value for each test you create
|
||||
use Test::More tests => 18; # increment this value for each test you create
|
||||
use WebGUI::Asset::Snippet;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Snippet Test"});
|
||||
WebGUI::Test->tagsToRollback($versionTag);
|
||||
addToCleanup($versionTag);
|
||||
my $snippet = $node->addChild({className=>'WebGUI::Asset::Snippet'});
|
||||
|
||||
# Test for a sane object type
|
||||
|
|
@ -86,6 +86,21 @@ is($snippet->view(), 'WebGUI', 'Interpolating macros in works with template in t
|
|||
my $empty = $node->addChild( { className => 'WebGUI::Asset::Snippet', } );
|
||||
is($empty->www_view, 'empty', 'www_view: snippet with no content returns "empty"');
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
#Check caching
|
||||
|
||||
##Set up the snippet to do caching
|
||||
$snippet->update({
|
||||
cacheTimeout => 100,
|
||||
snippet => 'Cache test: ^#;',
|
||||
});
|
||||
|
||||
$versionTag->commit;
|
||||
|
||||
is $snippet->view, 'Cache test: 1', 'validate snippet content and set cache';
|
||||
$session->user({userId => 3});
|
||||
is $snippet->view(1), 'Cache test: 3', 'receive uncached content since view was passed the webMethod flag';
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to make later";
|
||||
ok(0, 'Test indexContent method');
|
||||
|
|
|
|||
|
|
@ -8,19 +8,6 @@
|
|||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
# XXX I (chrisn) started this file to test the features I added to the
|
||||
# Collaboration / Post system for 7.5, but didn't have the time available to me
|
||||
# to do a full test suite for the Collaboration Wobject. This means that this
|
||||
# test suite is *largely incomplete* and should be finished. What is here *is*
|
||||
# the following:
|
||||
#
|
||||
#
|
||||
# 1. The basic framework for a test suite for the Collaboration Wobject.
|
||||
# Includes setup, cleanup, boilerplate, etc. Basically the really boring,
|
||||
# repetitive parts of the test that you don't want to write yourself.
|
||||
# 2. The tests for the features I've implemented; namely, the groupToEditPost
|
||||
# functionality.
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../lib";
|
||||
|
|
@ -32,7 +19,7 @@ use WebGUI::Asset::Wobject::Collaboration;
|
|||
use WebGUI::Asset::Post;
|
||||
use WebGUI::Asset::Wobject::Layout;
|
||||
use Data::Dumper;
|
||||
use Test::More tests => 10; # increment this value for each test you create
|
||||
use Test::More tests => 13; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -41,6 +28,7 @@ my $node = WebGUI::Asset->getImportNode($session);
|
|||
|
||||
# grab a named version tag
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
addToCleanup($versionTag);
|
||||
$versionTag->set({name => 'Collaboration => groupToEditPost test'});
|
||||
|
||||
# place the collab system under a layout to ensure we're using the inherited groupIdEdit value
|
||||
|
|
@ -55,6 +43,10 @@ my $collab = $layout->addChild({
|
|||
url => 'collab',
|
||||
});
|
||||
|
||||
$versionTag->commit;
|
||||
$collab = $collab->cloneFromDb;
|
||||
ok($session->id->valid($collab->get('getMailCronId')), 'commited CS has a cron job created for it');
|
||||
|
||||
# Test for a sane object type
|
||||
isa_ok($collab, 'WebGUI::Asset::Wobject::Collaboration');
|
||||
|
||||
|
|
@ -99,12 +91,13 @@ is($collab->getRssFeedUrl, '/collab?func=viewRss', 'getRssFeedUrl');
|
|||
is($collab->getRdfFeedUrl, '/collab?func=viewRdf', 'getRdfFeedUrl');
|
||||
is($collab->getAtomFeedUrl, '/collab?func=viewAtom', 'getAtomFeedUrl');
|
||||
|
||||
note "Mail Cron job tests";
|
||||
my $dupedCollab = $collab->duplicate();
|
||||
addToCleanup(WebGUI::VersionTag->new($session, $dupedCollab->get('tagId')));
|
||||
ok($dupedCollab->get('getMailCronId'), 'Duplicated CS has a cron job');
|
||||
isnt($dupedCollab->get('getMailCronId'), $collab->get('getMailCronId'), '... and it is different from its source asset');
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to make later";
|
||||
ok(0, 'A whole lot more work to do here');
|
||||
}
|
||||
|
||||
END {
|
||||
# Clean up after thyself
|
||||
$versionTag->rollback();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -298,6 +298,7 @@ $templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
|||
'ownerUserId' => ignore(),
|
||||
'extraHeadTags' => ignore(),
|
||||
'assetId' => ignore(),
|
||||
'assetIdHex' => ignore(),
|
||||
'url' => 'test-ems',
|
||||
'isHidden' => ignore(),
|
||||
'isPrototype' => ignore(),
|
||||
|
|
|
|||
24
t/Macro/BackToSite.t
Normal file
24
t/Macro/BackToSite.t
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Macro::BackToSite;
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
plan tests => 1;
|
||||
|
||||
my $output = WebGUI::Macro::BackToSite::process($session);
|
||||
is($output, $session->url->getBackToSiteURL, 'fetching current url');
|
||||
66
t/Macro/DeactivateAccount.t
Normal file
66
t/Macro/DeactivateAccount.t
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2008 Plain Black Corporation.
|
||||
#-------------------------------------------------------------------
|
||||
# Please read the legal notices (docs/legal.txt) and the license
|
||||
# (docs/license.txt) that came with this distribution before using
|
||||
# this software.
|
||||
#-------------------------------------------------------------------
|
||||
# http://www.plainblack.com info@plainblack.com
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Macro::DeactivateAccount;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
plan tests => 7;
|
||||
|
||||
my $defaultText = 'Please deactivate my account permanently.';
|
||||
my $testText = 'Deactivate account';
|
||||
|
||||
# Test 1: User is admin: return nothing
|
||||
$session->user({userId => 3});
|
||||
my $out1 = WebGUI::Macro::DeactivateAccount::process($session);
|
||||
is( $out1, '', "User is admin: return nothing" );
|
||||
|
||||
# Test 2: User is not admin, but can't self-deactivate: return nothing
|
||||
$session->user({userId => 1});
|
||||
$session->setting->set("selfDeactivation", 0);
|
||||
my $out2 = WebGUI::Macro::DeactivateAccount::process($session);
|
||||
is( $out2, '', "User can't self-deactivate: return nothing" );
|
||||
|
||||
# Test 3: linkonly
|
||||
$session->setting->set("selfDeactivation", 1);
|
||||
my $out3 = WebGUI::Macro::DeactivateAccount::process($session, $testText, 1);
|
||||
# my ($url3, $text3) = simpleHTMLParser($out3);
|
||||
is( $out3, '/?op=auth;method=deactivateAccount', 'Link only - URL check');
|
||||
|
||||
# Test 4: full deactivation link with default text
|
||||
my $out4 = WebGUI::Macro::DeactivateAccount::process($session);
|
||||
my ($url4, $text4) = simpleHTMLParser($out4);
|
||||
is( $url4, '/?op=auth;method=deactivateAccount', 'Full test - URL check');
|
||||
is( $text4, $defaultText, 'Full test - text check');
|
||||
|
||||
# Test 5: full deactivation link with custom text
|
||||
my $out5 = WebGUI::Macro::DeactivateAccount::process($session, $testText);
|
||||
my ($url5, $text5) = simpleHTMLParser($out5);
|
||||
is( $url5, '/?op=auth;method=deactivateAccount', 'Full test with custom text - URL check');
|
||||
is( $text5, $testText, 'Full test with custom text - text check');
|
||||
|
||||
sub simpleHTMLParser {
|
||||
my ($text) = @_;
|
||||
my $p = HTML::TokeParser->new(\$text);
|
||||
|
||||
my $token = $p->get_tag("a");
|
||||
my $url = $token->[1]{href} || "-";
|
||||
my $label = $p->get_trimmed_text("/a");
|
||||
|
||||
return ($url, $label);
|
||||
}
|
||||
|
||||
|
|
@ -41,6 +41,11 @@ my @testSets = (
|
|||
output => 'application/octet-stream',
|
||||
comment => q|Null path returns application/octet-stream|,
|
||||
},
|
||||
{
|
||||
input => 'foo.rtf',
|
||||
output => 'application/rtf',
|
||||
comment => q|RTF file|, ##Added test due to a bug on some operating systems.
|
||||
},
|
||||
{
|
||||
input => undef,
|
||||
output => undef,
|
||||
|
|
|
|||
44
t/Macro/SpectreCheck.t
Normal file
44
t/Macro/SpectreCheck.t
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Operation::Spectre;
|
||||
|
||||
my $original_spectreCheck = \&WebGUI::Operation::Spectre::spectreTest;
|
||||
my $spectreStatus;
|
||||
*WebGUI::Operation::Spectre::spectreTest = sub {
|
||||
return $spectreStatus;
|
||||
};
|
||||
|
||||
use WebGUI::Macro::SpectreCheck;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
plan tests => 4;
|
||||
|
||||
my $i18n = WebGUI::International->new($session, 'Macro_SpectreCheck');
|
||||
|
||||
is WebGUI::Macro::SpectreCheck::process($session), $i18n->get('spectre'), 'with no status, get an i18n message for a bad spectre';
|
||||
|
||||
$spectreStatus = 'success';
|
||||
is WebGUI::Macro::SpectreCheck::process($session), $i18n->get('success'), 'good status';
|
||||
$spectreStatus = 'subnet';
|
||||
is WebGUI::Macro::SpectreCheck::process($session), $i18n->get('subnet'), 'bad subnet';
|
||||
$spectreStatus = 'spectre';
|
||||
is WebGUI::Macro::SpectreCheck::process($session), $i18n->get('spectre'), 'bad spectre';
|
||||
|
||||
*WebGUI::Operation::Spectre::spectreTest = $original_spectreCheck;
|
||||
|
|
@ -23,9 +23,7 @@ use Data::Dumper;
|
|||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
my $num_tests = 53;
|
||||
|
||||
plan tests => $num_tests;
|
||||
plan tests => 57;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
|
|
@ -401,6 +399,22 @@ is_deeply(
|
|||
|
||||
$session->user({userId => 1});
|
||||
|
||||
####################################################
|
||||
#
|
||||
# ifModifiedSince
|
||||
#
|
||||
####################################################
|
||||
##Clear request object to run a new set of requests
|
||||
$request = WebGUI::PseudoRequest->new();
|
||||
$session->{_request} = $request;
|
||||
$request->headers_in->{'If-Modified-Since'} = '';
|
||||
ok $session->http->ifModifiedSince(0), 'ifModifiedSince: empty header always returns true';
|
||||
|
||||
$request->headers_in->{'If-Modified-Since'} = $session->datetime->epochToHttp(WebGUI::Test->webguiBirthday);
|
||||
ok $session->http->ifModifiedSince(WebGUI::Test->webguiBirthday + 5), '... epoch check, true';
|
||||
ok !$session->http->ifModifiedSince(WebGUI::Test->webguiBirthday - 5), '... epoch check, false';
|
||||
ok $session->http->ifModifiedSince(WebGUI::Test->webguiBirthday - 5, 3600), '... epoch check, made true by maxCacheTimeout';
|
||||
|
||||
####################################################
|
||||
#
|
||||
# Utility functions
|
||||
|
|
@ -428,7 +442,3 @@ sub deltaHttpTimes {
|
|||
my $dt2 = $httpParser->parse_datetime($http2);
|
||||
my $delta_time = $dt1-$dt2;
|
||||
}
|
||||
|
||||
|
||||
END {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ use WebGUI::Test; # Must use this before any other WebGUI modules
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Shop::ShipDriver::USPS;
|
||||
|
||||
plan tests => 66;
|
||||
plan tests => 69;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
|
|
@ -232,6 +232,13 @@ my $wucAddress = $addressBook->addAddress({
|
|||
city => 'Madison', state => 'WI', code => '53703',
|
||||
country => 'United States',
|
||||
});
|
||||
my $zip4Address = $addressBook->addAddress({
|
||||
label => 'work-zip4',
|
||||
organization => 'Plain Black Corporation',
|
||||
address1 => '1360 Regent St. #145',
|
||||
city => 'Madison', state => 'WI', code => '53715-1255',
|
||||
country => 'United States',
|
||||
});
|
||||
$cart->update({shippingAddressId => $workAddress->getId});
|
||||
|
||||
cmp_deeply(
|
||||
|
|
@ -826,6 +833,48 @@ SKIP: {
|
|||
|
||||
}
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# Test ZIP+4 format domestic code
|
||||
#
|
||||
#######################################################################
|
||||
$cart->update({shippingAddressId => $zip4Address->getId});
|
||||
|
||||
my $xmlData = XMLin($driver->buildXML($cart, @shippableUnits),
|
||||
KeepRoot => 1,
|
||||
ForceArray => ['Package'],
|
||||
);
|
||||
cmp_deeply(
|
||||
$xmlData,
|
||||
{
|
||||
RateV3Request => {
|
||||
USERID => $userId,
|
||||
Package => [
|
||||
{
|
||||
ID => 0,
|
||||
ZipDestination => '53715', ZipOrigination => '97123',
|
||||
Pounds => '1', Ounces => '8.0',
|
||||
Size => 'REGULAR', Service => 'PRIORITY',
|
||||
Machinable => 'true',# Container => 'VARIABLE',
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
'buildXML: removed plus4 part of zipcode'
|
||||
);
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip 'No userId for testing', 2 unless $hasRealUserId;
|
||||
|
||||
my $cost = eval { $driver->calculate($cart); };
|
||||
my $e = Exception::Class->caught();
|
||||
ok( ! ref $e, 'no exception thrown for zip+4 address');
|
||||
cmp_deeply($cost, num(10,9.99), 'zip+4 address returns a valid cost');
|
||||
|
||||
}
|
||||
|
||||
$cart->update({shippingAddressId => $workAddress->getId});
|
||||
#######################################################################
|
||||
#
|
||||
# Check for throwing an exception
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ is_deeply($wf->getCrons, [], 'workflow has no crons');
|
|||
isa_ok(WebGUI::Workflow->getList($session), 'HASH', 'getList returns a hashref');
|
||||
|
||||
ok(!isIn($wfId, keys %{WebGUI::Workflow->getList($session)}), 'workflow not in enabled list');
|
||||
is(scalar keys %{WebGUI::Workflow->getList($session)}, 12, 'There are twelve default workflows, of all types, shipped with WebGUI');
|
||||
is(scalar keys %{WebGUI::Workflow->getList($session)}, 11, 'There are eleven enabled, default workflows, of all types, shipped with WebGUI');
|
||||
|
||||
$wf->set({enabled => 1});
|
||||
ok($wf->get('enabled'), 'workflow is enabled');
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue