Merge branch 'master' of github.com:plainblack/webgui
This commit is contained in:
commit
fb864a4620
20 changed files with 578 additions and 90 deletions
|
|
@ -21,6 +21,9 @@
|
||||||
- added: Manage System Clipboard group setting
|
- added: Manage System Clipboard group setting
|
||||||
- added: Manage System Trash group setting
|
- added: Manage System Trash group setting
|
||||||
- fixed #11069: "More" options menu in asset manager
|
- fixed #11069: "More" options menu in asset manager
|
||||||
|
- rfe #10755: Adding SetLanguage bazaar item
|
||||||
|
- fixed #11176: New upgrade error in 7.6.35 to 7.7.17
|
||||||
|
- fixed #11181: ableToBeFriend label not i18n
|
||||||
|
|
||||||
7.8.2
|
7.8.2
|
||||||
- Added scheduled vendor payout workflow activity. (Special thanks to Martin @ Oqapi)
|
- Added scheduled vendor payout workflow activity. (Special thanks to Martin @ Oqapi)
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -22,6 +22,8 @@ use Getopt::Long;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Storage;
|
use WebGUI::Storage;
|
||||||
use WebGUI::Asset;
|
use WebGUI::Asset;
|
||||||
|
use WebGUI::Utility;
|
||||||
|
use WebGUI::ProfileField;
|
||||||
|
|
||||||
|
|
||||||
my $toVersion = '7.8.3';
|
my $toVersion = '7.8.3';
|
||||||
|
|
@ -35,9 +37,25 @@ reKeyTemplateAttachments($session);
|
||||||
addSelectPaymentGatewayTemplateToSettings($session);
|
addSelectPaymentGatewayTemplateToSettings($session);
|
||||||
addClipboardAdminSetting($session);
|
addClipboardAdminSetting($session);
|
||||||
addTrashAdminSetting($session);
|
addTrashAdminSetting($session);
|
||||||
|
addPickLanguageMacro($session);
|
||||||
|
installSetLanguage($session);
|
||||||
|
i18nAbleToBeFriend($session);
|
||||||
|
|
||||||
finish($session); # this line required
|
finish($session); # this line required
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
sub i18nAbleToBeFriend {
|
||||||
|
my $session = shift;
|
||||||
|
print "\tInternationalize the Able To Be Friend profile field... " unless $quiet;
|
||||||
|
my $field = WebGUI::ProfileField->new($session, 'ableToBeFriend');
|
||||||
|
if ($field) {
|
||||||
|
my $props = $field->get();
|
||||||
|
$props->{label} = q{WebGUI::International::get('user profile field friend availability','WebGUI')};
|
||||||
|
$field->set($props);
|
||||||
|
}
|
||||||
|
print "Done.\n" unless $quiet;
|
||||||
|
}
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
sub addClipboardAdminSetting {
|
sub addClipboardAdminSetting {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
|
|
@ -60,17 +78,20 @@ sub addTrashAdminSetting {
|
||||||
sub reKeyTemplateAttachments {
|
sub reKeyTemplateAttachments {
|
||||||
my $session = shift;
|
my $session = shift;
|
||||||
print "\tChanging the key structure for the template attachments table... " unless $quiet;
|
print "\tChanging the key structure for the template attachments table... " unless $quiet;
|
||||||
# and here's our code
|
my $columnExists = $session->db->dbh->column_info(undef, undef, 'template_attachments', 'attachId')->fetchrow_hashref;
|
||||||
$session->db->write('ALTER TABLE template_attachments ADD COLUMN attachId CHAR(22) BINARY NOT NULL');
|
if (! $columnExists) {
|
||||||
my $rh = $session->db->read('select url, templateId, revisionDate from template_attachments');
|
# and here's our code
|
||||||
my $wh = $session->db->prepare('update template_attachments set attachId=? where url=? and templateId=? and revisionDate=?');
|
$session->db->write('ALTER TABLE template_attachments ADD COLUMN attachId CHAR(22) BINARY NOT NULL');
|
||||||
while (my @key = $rh->array) {
|
my $rh = $session->db->read('select url, templateId, revisionDate from template_attachments');
|
||||||
$wh->execute([$session->id->generate, @key ]);
|
my $wh = $session->db->prepare('update template_attachments set attachId=? where url=? and templateId=? and revisionDate=?');
|
||||||
|
while (my @key = $rh->array) {
|
||||||
|
$wh->execute([$session->id->generate, @key ]);
|
||||||
|
}
|
||||||
|
$rh->finish;
|
||||||
|
$wh->finish;
|
||||||
|
$session->db->write('ALTER TABLE template_attachments DROP PRIMARY KEY');
|
||||||
|
$session->db->write('ALTER TABLE template_attachments ADD PRIMARY KEY (attachId)');
|
||||||
}
|
}
|
||||||
$rh->finish;
|
|
||||||
$wh->finish;
|
|
||||||
$session->db->write('ALTER TABLE template_attachments DROP PRIMARY KEY');
|
|
||||||
$session->db->write('ALTER TABLE template_attachments ADD PRIMARY KEY (attachId)');
|
|
||||||
print "DONE!\n" unless $quiet;
|
print "DONE!\n" unless $quiet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,6 +111,30 @@ sub addSelectPaymentGatewayTemplateToSettings {
|
||||||
# print "DONE!\n" unless $quiet;
|
# print "DONE!\n" unless $quiet;
|
||||||
#}
|
#}
|
||||||
|
|
||||||
|
#------------------------------------------------------------------------
|
||||||
|
sub addPickLanguageMacro {
|
||||||
|
my $session = shift;
|
||||||
|
print "\tAdding Pick Language macro... " unless $quiet;
|
||||||
|
$session->config->set('macros/PickLanguage', 'PickLanguage');
|
||||||
|
print "Done.\n" unless $quiet;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub installSetLanguage {
|
||||||
|
my $session = shift;
|
||||||
|
print "\tAdding SetLanguage content handler... " unless $quiet;
|
||||||
|
##Content Handler
|
||||||
|
my $contentHandlers = $session->config->get('contentHandlers');
|
||||||
|
if (!isIn('WebGUI::Content::SetLanguage', @{ $contentHandlers }) ) {
|
||||||
|
my @newHandlers = ();
|
||||||
|
foreach my $handler (@{ $contentHandlers }) {
|
||||||
|
push @newHandlers, $handler;
|
||||||
|
push @newHandlers, 'WebGUI::Content::SetLanguage' if
|
||||||
|
$handler eq 'WebGUI::Content::PassiveAnalytics';
|
||||||
|
}
|
||||||
|
$session->config->set('contentHandlers', \@newHandlers);
|
||||||
|
}
|
||||||
|
print "Done.\n" unless $quiet;
|
||||||
|
}
|
||||||
|
|
||||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -811,6 +811,7 @@
|
||||||
"Page" : "Page",
|
"Page" : "Page",
|
||||||
"PageTitle" : "PageTitle",
|
"PageTitle" : "PageTitle",
|
||||||
"PageUrl" : "PageUrl",
|
"PageUrl" : "PageUrl",
|
||||||
|
"PickLanguage" : "PickLanguage",
|
||||||
"RandomAssetProxy" : "RandomAssetProxy",
|
"RandomAssetProxy" : "RandomAssetProxy",
|
||||||
"RandomThread" : "RandomThread",
|
"RandomThread" : "RandomThread",
|
||||||
"RootTitle" : "RootTitle",
|
"RootTitle" : "RootTitle",
|
||||||
|
|
@ -968,6 +969,7 @@
|
||||||
"WebGUI::Content::AssetManager",
|
"WebGUI::Content::AssetManager",
|
||||||
"WebGUI::Content::AssetDiscovery",
|
"WebGUI::Content::AssetDiscovery",
|
||||||
"WebGUI::Content::PassiveAnalytics",
|
"WebGUI::Content::PassiveAnalytics",
|
||||||
|
"WebGUI::Content::SetLanguage",
|
||||||
"WebGUI::Content::AjaxI18N",
|
"WebGUI::Content::AjaxI18N",
|
||||||
"WebGUI::Content::Account",
|
"WebGUI::Content::Account",
|
||||||
"WebGUI::Content::AssetHistory",
|
"WebGUI::Content::AssetHistory",
|
||||||
|
|
|
||||||
83
lib/WebGUI/Content/SetLanguage.pm
Normal file
83
lib/WebGUI/Content/SetLanguage.pm
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
package WebGUI::Content::SetLanguage;
|
||||||
|
|
||||||
|
=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 strict;
|
||||||
|
use WebGUI::Session;
|
||||||
|
use WebGUI::International;
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
Package WebGUI::Content::SetLanguage
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
Sets or delete an scratch variable that overrides the profile field language
|
||||||
|
|
||||||
|
=head1 SYNOPSIS
|
||||||
|
|
||||||
|
use WebGUI::Content::SetLanguage;
|
||||||
|
WebGUI::Content::SetLanguage::handler();
|
||||||
|
|
||||||
|
=head1 SUBROUTINES
|
||||||
|
|
||||||
|
These subroutines are available from this package:
|
||||||
|
|
||||||
|
handler
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
#-------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 handler ( session, op, setLanguage )
|
||||||
|
|
||||||
|
sets or delete scratch variable in a session and returns undef
|
||||||
|
|
||||||
|
=head3 session
|
||||||
|
|
||||||
|
The current WebGUI::Session object.
|
||||||
|
|
||||||
|
=head3 op
|
||||||
|
|
||||||
|
op should be setLanguage to call the handler
|
||||||
|
|
||||||
|
=head3 language
|
||||||
|
|
||||||
|
language should be an installed language or delete
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
sub handler {
|
||||||
|
my ($session) = @_;
|
||||||
|
return undef unless $session->form->get('op') eq 'setLanguage';
|
||||||
|
my $language = $session->form->get('language');
|
||||||
|
#check whether a language has been given in the url
|
||||||
|
if (!$language) {
|
||||||
|
$session->log->error('There is no language given to this method');
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
#make it possible to delete the language scratch variable from the session
|
||||||
|
if ($language eq 'delete' ) {
|
||||||
|
$session->scratch->removeLanguageOverride;
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
#set a scratch variable language or throw error if language is not installed
|
||||||
|
else {
|
||||||
|
return $session->scratch->setLanguageOverride($language);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1;
|
||||||
37
lib/WebGUI/Help/Macro_PickLanguage.pm
Normal file
37
lib/WebGUI/Help/Macro_PickLanguage.pm
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
package WebGUI::Help::Macro_PickLanguage;
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
|
||||||
|
|
||||||
|
our $HELP = {
|
||||||
|
'template variables' => {
|
||||||
|
title => 'picklanguage title',
|
||||||
|
body => '',
|
||||||
|
fields =>[],
|
||||||
|
'variables' => [
|
||||||
|
{
|
||||||
|
name => "lang_loop",
|
||||||
|
variables => [
|
||||||
|
{
|
||||||
|
name => "language_lang",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => "language_langAbbr",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => "language_langAbbrLoc",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name => "language_langEng",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
related => [
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
1; ##All perl modules must return true
|
||||||
|
#vim:ft=perl
|
||||||
|
|
@ -284,7 +284,7 @@ Specify a default language. Defaults to user preference or "English".
|
||||||
sub new {
|
sub new {
|
||||||
my ($class, $session, $namespace, $language) = @_;
|
my ($class, $session, $namespace, $language) = @_;
|
||||||
$namespace ||= 'WebGUI';
|
$namespace ||= 'WebGUI';
|
||||||
$language ||= $session->user->profileField('language');
|
$language ||= $session->scratch->getLanguageOverride() || $session->user->profileField('language');
|
||||||
my $self =
|
my $self =
|
||||||
bless {
|
bless {
|
||||||
_session => $session,
|
_session => $session,
|
||||||
|
|
|
||||||
65
lib/WebGUI/Macro/PickLanguage.pm
Normal file
65
lib/WebGUI/Macro/PickLanguage.pm
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
package WebGUI::Macro::PickLanguage; # edit this line to match your own macro name
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# 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 strict;
|
||||||
|
|
||||||
|
=head1 NAME
|
||||||
|
|
||||||
|
Package WebGUI::Macro::PickLanguage
|
||||||
|
|
||||||
|
=head1 DESCRIPTION
|
||||||
|
|
||||||
|
This macro makes a link for each installed language so when clicked the SetLanguage contetntHandler is called and sets the language in the scratch. The link text is the label from the language.
|
||||||
|
|
||||||
|
=head2 process( $session )
|
||||||
|
|
||||||
|
The main macro class, Macro.pm, will call this subroutine and pass it
|
||||||
|
|
||||||
|
=over 4
|
||||||
|
|
||||||
|
=item *
|
||||||
|
|
||||||
|
A session variable
|
||||||
|
|
||||||
|
=item templateId
|
||||||
|
|
||||||
|
This macro takes a templateId to show the links
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
sub process {
|
||||||
|
my $session = shift;
|
||||||
|
my $templateId = shift || "_aE16Rr1-bXBf8SIaLZjCg";
|
||||||
|
my $template = WebGUI::Asset::Template->new($session, $templateId);
|
||||||
|
return "Could not instanciate template with id [$templateId]" unless $template;
|
||||||
|
my $i18n = WebGUI::International->new($session);
|
||||||
|
my $languages = $i18n->getLanguages();
|
||||||
|
my $vars = {'lang_loop' => []};
|
||||||
|
foreach my $language ( keys %$languages ) {
|
||||||
|
my $langVars = {};
|
||||||
|
$langVars->{ 'language_url' } = '?op=setLanguage;language=' . $language ;
|
||||||
|
$langVars->{ 'language_lang' } = $i18n->getLanguage($language , 'label');
|
||||||
|
$langVars->{ 'language_langAbbr' } = $i18n->getLanguage($language, 'languageAbbreviation');
|
||||||
|
$langVars->{ 'language_langAbbrLoc' } = $i18n->getLanguage($language, 'locale');
|
||||||
|
$langVars->{ 'language_langEng' } = $language;
|
||||||
|
push(@{$vars->{lang_loop}}, $langVars);
|
||||||
|
}
|
||||||
|
return $template->process($vars);
|
||||||
|
}
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
||||||
|
#vim:ft=perl
|
||||||
|
|
@ -15,6 +15,7 @@ package WebGUI::Session::Scratch;
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use WebGUI::International;
|
||||||
|
|
||||||
=head1 NAME
|
=head1 NAME
|
||||||
|
|
||||||
|
|
@ -160,6 +161,19 @@ sub get {
|
||||||
return $self->{_data}{$var};
|
return $self->{_data}{$var};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 getLanguageOverride ()
|
||||||
|
|
||||||
|
Retrieves the language of the session scratch
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getLanguageOverride {
|
||||||
|
my $self = shift;
|
||||||
|
my $languageOverride = $self->session->scratch->get('language');
|
||||||
|
return $languageOverride;
|
||||||
|
}
|
||||||
|
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
@ -180,7 +194,18 @@ sub new {
|
||||||
bless {_session=>$session, _data=>$data}, $class;
|
bless {_session=>$session, _data=>$data}, $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 removeLanguageOverride()
|
||||||
|
|
||||||
|
Removes the language scratch variable from the session
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub removeLanguageOverride {
|
||||||
|
my $self = shift;
|
||||||
|
$self->session->scratch->delete('language');
|
||||||
|
}
|
||||||
#-------------------------------------------------------------------
|
#-------------------------------------------------------------------
|
||||||
|
|
||||||
=head2 session ( )
|
=head2 session ( )
|
||||||
|
|
@ -220,5 +245,30 @@ sub set {
|
||||||
$self->session->db->write("insert into userSessionScratch (sessionId, name, value) values (?,?,?) on duplicate key update value=VALUES(value)", [$self->session->getId, $name, $value]);
|
$self->session->db->write("insert into userSessionScratch (sessionId, name, value) values (?,?,?) on duplicate key update value=VALUES(value)", [$self->session->getId, $name, $value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------
|
||||||
|
|
||||||
|
=head2 setLanguageOverride ( language )
|
||||||
|
|
||||||
|
Sets a scratch variable language in the session if the language is installed
|
||||||
|
|
||||||
|
=head3 language
|
||||||
|
|
||||||
|
The language that should be set into the session
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub setLanguageOverride {
|
||||||
|
my $self = shift;
|
||||||
|
my $language = shift;
|
||||||
|
my $i18n = WebGUI::International->new($self->session);
|
||||||
|
if($i18n->getLanguages()->{$language}) {
|
||||||
|
$self->session->scratch->set("language",$language);
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$self->session->log->error("Language $language is not installed in this site");
|
||||||
|
return undef;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
48
lib/WebGUI/i18n/English/Macro_PickLanguage.pm
Normal file
48
lib/WebGUI/i18n/English/Macro_PickLanguage.pm
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
package WebGUI::i18n::English::Macro_PickLanguage; ##Be sure to change the package name to match the filename
|
||||||
|
|
||||||
|
use strict; ##Required for all good Perl::Critic compliant code
|
||||||
|
|
||||||
|
our $I18N = { ##hashref of hashes
|
||||||
|
'picklanguage title' => {
|
||||||
|
message => q|PickLanguage macro template variables|,
|
||||||
|
lastUpdated => 1131394070,
|
||||||
|
context => q|Title of the help object|
|
||||||
|
},
|
||||||
|
'lang_loop' => { ##key that will be used to reference this entry. Do not translate this.
|
||||||
|
message => q|A loop that contains all installed languages|,
|
||||||
|
lastUpdated => 1131394070, #seconds from the epoch
|
||||||
|
context => q|A template loop|
|
||||||
|
},
|
||||||
|
|
||||||
|
'language_lang' => {
|
||||||
|
message => q|The name of the language in that language.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|A template variable to show the name of the language|
|
||||||
|
},
|
||||||
|
|
||||||
|
'language_langAbbr' => {
|
||||||
|
message => q|An standard code for the language, for instance "en".|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|A label of the language to use in the template|
|
||||||
|
},
|
||||||
|
'language_langAbbrLoc' => {
|
||||||
|
message => q|An standard abbreviated label for the language, for instance "US".|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|A label of the language to use in the template|
|
||||||
|
},
|
||||||
|
'language_langEng' => {
|
||||||
|
message => q|The English name of the language.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|A label of the language to use in the template|
|
||||||
|
},
|
||||||
|
'language_url' => {
|
||||||
|
message => q|The url that sets the WebGUI language to the selected language.|,
|
||||||
|
lastUpdated => 1131394072,
|
||||||
|
context => q|The url to change languages|
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
1;
|
||||||
|
#vim:ft=perl
|
||||||
55
t/Content/SetLanguage.t
Normal file
55
t/Content/SetLanguage.t
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# 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::Content::SetLanguage;
|
||||||
|
|
||||||
|
# load your modules here
|
||||||
|
|
||||||
|
use Test::More tests => 5; # increment this value for each test you create
|
||||||
|
|
||||||
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
# put your tests here
|
||||||
|
my $formvariables = {
|
||||||
|
'op' =>'setLanguage',
|
||||||
|
'language' => 'English'
|
||||||
|
};
|
||||||
|
#test 1
|
||||||
|
$session->request->setup_body($formvariables);
|
||||||
|
WebGUI::Content::SetLanguage::handler($session);
|
||||||
|
is($session->scratch->getLanguageOverride, 'English', 'the language was not set');
|
||||||
|
#test2
|
||||||
|
$formvariables->{'language'} = 'delete';
|
||||||
|
$session->request->setup_body($formvariables);
|
||||||
|
WebGUI::Content::SetLanguage::handler($session);
|
||||||
|
is($session->scratch->getLanguageOverride, undef, 'language delete should remove the scratch variable');
|
||||||
|
#test3
|
||||||
|
$formvariables->{'op'} = 'SetLanguage';
|
||||||
|
$formvariables->{'language'} = 'English';
|
||||||
|
$session->request->setup_body($formvariables);
|
||||||
|
WebGUI::Content::SetLanguage::handler($session);
|
||||||
|
is($session->scratch->getLanguageOverride, undef, 'Naming the method wrongly should not change anything');
|
||||||
|
#test4
|
||||||
|
$formvariables->{'op'} = 'setLanguage';
|
||||||
|
$formvariables->{'language'} = 'MyImaginaryLanguageThatIsNotInstalled';
|
||||||
|
$session->request->setup_body($formvariables);
|
||||||
|
WebGUI::Content::SetLanguage::handler($session);
|
||||||
|
is($session->scratch->getLanguageOverride, undef, 'Giving a non installed language should not change anything');
|
||||||
|
#test5
|
||||||
|
$formvariables->{'language'} = undef;
|
||||||
|
$session->request->setup_body($formvariables);
|
||||||
|
WebGUI::Content::SetLanguage::handler($session);
|
||||||
|
is($session->scratch->getLanguageOverride, undef, 'Passing an empty language variable should return undef');
|
||||||
|
|
||||||
|
|
@ -16,12 +16,13 @@ use WebGUI::Session;
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
use File::Copy;
|
use File::Copy;
|
||||||
use File::Spec;
|
use File::Spec;
|
||||||
|
use WebGUI::Content::SetLanguage;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
my $numTests = 1; ##For conditional load check
|
my $numTests = 1; ##For conditional load check
|
||||||
my $langTests = 4; ##For language look-up tests
|
my $langTests = 4; ##For language look-up tests
|
||||||
$numTests += 12 + $langTests;
|
$numTests += 20 + $langTests;
|
||||||
|
|
||||||
plan tests => $numTests;
|
plan tests => $numTests;
|
||||||
|
|
||||||
|
|
@ -50,6 +51,16 @@ is($i18n->get('topicName', 'WebGUI'), 'WebGUI', 'get: test manual namespace over
|
||||||
|
|
||||||
installPigLatin();
|
installPigLatin();
|
||||||
|
|
||||||
|
#tests for sub new
|
||||||
|
my $i18nNew1 = WebGUI::International->new($session);
|
||||||
|
is($i18nNew1->{_language}, 'English', 'Calling new without parameters should return object with language English');
|
||||||
|
is($i18nNew1->{_namespace}, 'WebGUI', 'Calling without parameters should give namespace WebgUI');
|
||||||
|
my $i18nNew2 = WebGUI::International->new($session, 'WebGUI::Asset');
|
||||||
|
is($i18nNew2->{_language}, 'English', 'Calling new with only namespace parameter should return object with language English');
|
||||||
|
is($i18nNew2->{_namespace}, 'WebGUI::Asset', 'Calling with only parameter namespace should give requested namespace');
|
||||||
|
my $i18nNew3 = WebGUI::International->new($session, undef , 'PigLatin');
|
||||||
|
is($i18nNew3->{_language}, 'PigLatin', 'Calling new with only language parameter should return object with language PigLatin');
|
||||||
|
is($i18nNew3->{_namespace}, 'WebGUI', 'Calling with only parameter namespace should give WebGUI ');
|
||||||
my $languages = $i18n->getLanguages();
|
my $languages = $i18n->getLanguages();
|
||||||
|
|
||||||
my $gotPigLatin = exists $languages->{PigLatin};
|
my $gotPigLatin = exists $languages->{PigLatin};
|
||||||
|
|
@ -102,6 +113,24 @@ sub installPigLatin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#test for sub new with language overridden by scratch
|
||||||
|
my $formvariables = {
|
||||||
|
'op' =>'setLanguage',
|
||||||
|
'language' => 'PigLatin'
|
||||||
|
};
|
||||||
|
$session->request->setup_body($formvariables);
|
||||||
|
WebGUI::Content::SetLanguage::handler($session);
|
||||||
|
my $newi18n = WebGUI::International->new($session);
|
||||||
|
is(
|
||||||
|
$newi18n->get('webgui','WebGUI','PigLatin'),
|
||||||
|
'ebGUIWay',
|
||||||
|
'if the piglatin language is in the scratch that messages should be retrieved'
|
||||||
|
);
|
||||||
|
is(
|
||||||
|
$newi18n->get('104','Asset','PigLatin'),
|
||||||
|
$newi18n->get('104', 'WebGUI', 'English'),
|
||||||
|
'Language check after SetLanguage contentHandler : key from missing file return English key'
|
||||||
|
);
|
||||||
END {
|
END {
|
||||||
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/);
|
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/);
|
||||||
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/);
|
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/);
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
use WebGUI::Macro::CanEditText;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
@ -61,17 +62,10 @@ my @testSets = (
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
my $numTests = scalar @testSets + 2;
|
my $numTests = scalar @testSets + 1;
|
||||||
|
|
||||||
plan tests => $numTests;
|
plan tests => $numTests;
|
||||||
|
|
||||||
my $macro = 'WebGUI::Macro::CanEditText';
|
|
||||||
my $loaded = use_ok($macro);
|
|
||||||
|
|
||||||
SKIP: {
|
|
||||||
|
|
||||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
|
||||||
|
|
||||||
is(
|
is(
|
||||||
WebGUI::Macro::CanEditText::process($session,''),
|
WebGUI::Macro::CanEditText::process($session,''),
|
||||||
'',
|
'',
|
||||||
|
|
@ -85,8 +79,6 @@ foreach my $testSet (@testSets) {
|
||||||
is($output, $testSet->{output}, $testSet->{comment});
|
is($output, $testSet->{output}, $testSet->{comment});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sub setupTest {
|
sub setupTest {
|
||||||
my ($session, $defaultNode) = @_;
|
my ($session, $defaultNode) = @_;
|
||||||
$session->user({userId=>3});
|
$session->user({userId=>3});
|
||||||
|
|
|
||||||
|
|
@ -15,12 +15,13 @@ use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
use WebGUI::Macro::D_date;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
# ---- END DO NOT EDIT ----
|
# ---- END DO NOT EDIT ----
|
||||||
|
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
my $wgbday = 997966800;
|
my $wgbday = WebGUI::Test->webguiBirthday;
|
||||||
|
|
||||||
my @testSets = (
|
my @testSets = (
|
||||||
{
|
{
|
||||||
|
|
@ -33,17 +34,10 @@ my @testSets = (
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
my $numTests = scalar @testSets + 1 + 1;
|
my $numTests = scalar @testSets + 1;
|
||||||
|
|
||||||
plan tests => $numTests;
|
plan tests => $numTests;
|
||||||
|
|
||||||
my $macro = 'WebGUI::Macro::D_date';
|
|
||||||
my $loaded = use_ok($macro);
|
|
||||||
|
|
||||||
SKIP: {
|
|
||||||
|
|
||||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
foreach my $testSet (@testSets) {
|
foreach my $testSet (@testSets) {
|
||||||
|
|
@ -65,5 +59,3 @@ while ($time1 != $time2) {
|
||||||
}
|
}
|
||||||
|
|
||||||
is($output, $session->datetime->epochToHuman($time1), 'checking default time and format');
|
is($output, $session->datetime->epochToHuman($time1), 'checking default time and format');
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ use lib "$FindBin::Bin/../lib";
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use HTML::TokeParser;
|
use HTML::TokeParser;
|
||||||
|
use WebGUI::Macro::EditableToggle;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
@ -184,17 +185,10 @@ foreach my $testSet (@testSets) {
|
||||||
$numTests += 1 + (ref $testSet->{output} eq 'CODE');
|
$numTests += 1 + (ref $testSet->{output} eq 'CODE');
|
||||||
}
|
}
|
||||||
|
|
||||||
$numTests += 1 + 1; ##Empty session Asset plus use_ok
|
$numTests += 1; ##Empty session Asset plus use_ok
|
||||||
|
|
||||||
plan tests => $numTests;
|
plan tests => $numTests;
|
||||||
|
|
||||||
my $macro = 'WebGUI::Macro::EditableToggle';
|
|
||||||
my $loaded = use_ok($macro);
|
|
||||||
|
|
||||||
SKIP: {
|
|
||||||
|
|
||||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
|
||||||
|
|
||||||
is(
|
is(
|
||||||
WebGUI::Macro::EditableToggle::process($session,'on','off',''),
|
WebGUI::Macro::EditableToggle::process($session,'on','off',''),
|
||||||
'',
|
'',
|
||||||
|
|
@ -229,8 +223,6 @@ foreach my $testSet (@testSets) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
sub simpleHTMLParser {
|
sub simpleHTMLParser {
|
||||||
my ($text) = @_;
|
my ($text) = @_;
|
||||||
my $p = HTML::TokeParser->new(\$text);
|
my $p = HTML::TokeParser->new(\$text);
|
||||||
|
|
@ -255,7 +247,6 @@ sub setupTest {
|
||||||
my ($session, $defaultNode) = @_;
|
my ($session, $defaultNode) = @_;
|
||||||
$session->user({userId=>3});
|
$session->user({userId=>3});
|
||||||
my $editGroup = WebGUI::Group->new($session, "new");
|
my $editGroup = WebGUI::Group->new($session, "new");
|
||||||
WebGUI::Test->groupsToDelete($editGroup);
|
|
||||||
my $tao = WebGUI::Group->find($session, "Turn Admin On");
|
my $tao = WebGUI::Group->find($session, "Turn Admin On");
|
||||||
##Create an asset with specific editing privileges
|
##Create an asset with specific editing privileges
|
||||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||||
|
|
@ -278,12 +269,6 @@ sub setupTest {
|
||||||
$users[1]->addToGroups([$editGroup->getId]);
|
$users[1]->addToGroups([$editGroup->getId]);
|
||||||
##User 2 is an editor AND can turn on Admin
|
##User 2 is an editor AND can turn on Admin
|
||||||
$users[2]->addToGroups([$editGroup->getId, $tao->getId]);
|
$users[2]->addToGroups([$editGroup->getId, $tao->getId]);
|
||||||
WebGUI::Test->usersToDelete(@users);
|
addToCleanup($versionTag, $editGroup, @users);
|
||||||
return ($versionTag, $asset, @users);
|
return ($versionTag, $asset, @users);
|
||||||
}
|
}
|
||||||
|
|
||||||
END { ##Clean-up after yourself, always
|
|
||||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
|
||||||
$versionTag->rollback;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
use WebGUI::Macro::Extras;
|
||||||
|
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
|
|
@ -49,20 +50,11 @@ my @testSets = (
|
||||||
|
|
||||||
my $numTests = scalar @testSets;
|
my $numTests = scalar @testSets;
|
||||||
|
|
||||||
$numTests += 1;
|
|
||||||
|
|
||||||
plan tests => $numTests;
|
plan tests => $numTests;
|
||||||
|
|
||||||
my $macro = 'WebGUI::Macro::Extras';
|
my $macro = 'WebGUI::Macro::Extras';
|
||||||
my $loaded = use_ok($macro);
|
|
||||||
|
|
||||||
SKIP: {
|
|
||||||
|
|
||||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
|
||||||
|
|
||||||
foreach my $testSet (@testSets) {
|
foreach my $testSet (@testSets) {
|
||||||
my $output = WebGUI::Macro::Extras::process($session, $testSet->{path});
|
my $output = WebGUI::Macro::Extras::process($session, $testSet->{path});
|
||||||
is($output, $testSet->{output}, $testSet->{comment});
|
is($output, $testSet->{output}, $testSet->{comment});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
125
t/Macro/PickLanguage.t
Normal file
125
t/Macro/PickLanguage.t
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
#-------------------------------------------------------------------
|
||||||
|
# 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::Asset::Template;
|
||||||
|
|
||||||
|
use Test::More; # increment this value for each test you create
|
||||||
|
use Test::Deep;
|
||||||
|
use Test::MockObject;
|
||||||
|
use Test::MockObject::Extends;
|
||||||
|
|
||||||
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
|
my $numTests = 3;
|
||||||
|
|
||||||
|
$numTests += 1; #For the use_ok
|
||||||
|
|
||||||
|
plan tests => $numTests;
|
||||||
|
|
||||||
|
my $macro = 'WebGUI::Macro::PickLanguage';
|
||||||
|
my $loaded = use_ok($macro);
|
||||||
|
|
||||||
|
my $macroMock = Test::MockObject->new({});
|
||||||
|
$macroMock->set_isa('WebGUI::Macro::PickLanguage');
|
||||||
|
$macroMock->set_true('process');
|
||||||
|
|
||||||
|
#test for normal use
|
||||||
|
|
||||||
|
my $templateId = 'PICKLANGUAGE_TEMPLATE_';
|
||||||
|
|
||||||
|
my $templateMock = Test::MockObject->new({});
|
||||||
|
$templateMock->set_isa('WebGUI::Asset::Template');
|
||||||
|
$templateMock->set_always('getId', $templateId);
|
||||||
|
my $templateVars;
|
||||||
|
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||||
|
WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$templateVars,
|
||||||
|
{
|
||||||
|
lang_loop => [
|
||||||
|
{ 'language_url' => '?op=setLanguage;language=English',
|
||||||
|
'language_lang' => 'English',
|
||||||
|
'language_langAbbr' => 'en',
|
||||||
|
'language_langAbbrLoc' => 'US',
|
||||||
|
'language_langEng' => 'English'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'some template variables are created'
|
||||||
|
);
|
||||||
|
WebGUI::Test->unmockAssetId($templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
#test when template Id is left empty
|
||||||
|
|
||||||
|
$templateId = '';
|
||||||
|
my $templateNoId = $templateMock->mock('process','');
|
||||||
|
$templateMock->set_always('getId', $templateId);
|
||||||
|
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||||
|
|
||||||
|
{
|
||||||
|
|
||||||
|
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||||
|
WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||||
|
|
||||||
|
cmp_deeply(
|
||||||
|
$templateVars,
|
||||||
|
{
|
||||||
|
lang_loop => [
|
||||||
|
{ 'language_url' => '?op=setLanguage;language=English',
|
||||||
|
'language_lang' => 'English',
|
||||||
|
'language_langAbbr' => 'en',
|
||||||
|
'language_langAbbrLoc' => 'US',
|
||||||
|
'language_langEng' => 'English'
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'some template variables are created, when no templateId is passed on with the macro'
|
||||||
|
);
|
||||||
|
WebGUI::Test->unmockAssetId($templateId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#{
|
||||||
|
# WebGUI::Test->mockAssetId($templateNoId, $templateMock);
|
||||||
|
# $error = WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||||
|
#
|
||||||
|
# is($error,'Could not instanciate template with id []',"Empty template Id should return error");
|
||||||
|
#
|
||||||
|
# WebGUI::Test->unmockAssetId($templateNoId);
|
||||||
|
#}
|
||||||
|
|
||||||
|
#test for an incorrect template Id
|
||||||
|
|
||||||
|
$templateId = '1234567890123456789012';
|
||||||
|
my $templateWrongId = $templateMock->mock('process','');
|
||||||
|
$templateMock->set_always('getId', $templateId);
|
||||||
|
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||||
|
my $error;
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
WebGUI::Test->mockAssetId($templateWrongId, $templateMock);
|
||||||
|
$error = WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||||
|
|
||||||
|
is($error,'Could not instanciate template with id [1234567890123456789012]',"Template from the wrong namespace should not be initiated");
|
||||||
|
WebGUI::Test->unmockAssetId($templateWrongId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -14,24 +14,14 @@ use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
use WebGUI::Macro::c_companyName;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
my $numTests = 2+1;
|
plan tests => 2;
|
||||||
|
|
||||||
plan tests => $numTests;
|
|
||||||
|
|
||||||
my $macro = 'WebGUI::Macro::c_companyName';
|
|
||||||
my $loaded = use_ok($macro);
|
|
||||||
|
|
||||||
my $originalCompanyName = $session->setting->get('companyName');
|
|
||||||
|
|
||||||
SKIP: {
|
|
||||||
|
|
||||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
|
||||||
|
|
||||||
my $output = WebGUI::Macro::c_companyName::process($session);
|
my $output = WebGUI::Macro::c_companyName::process($session);
|
||||||
is($output, $originalCompanyName, "Testing companyName");
|
is($output, $originalCompanyName, "Testing companyName");
|
||||||
|
|
@ -39,8 +29,3 @@ is($output, $originalCompanyName, "Testing companyName");
|
||||||
$session->setting->set('companyName', q|Gooey's Consulting, LLC|);
|
$session->setting->set('companyName', q|Gooey's Consulting, LLC|);
|
||||||
$output = WebGUI::Macro::c_companyName::process($session);
|
$output = WebGUI::Macro::c_companyName::process($session);
|
||||||
is($output, q|Gooey's Consulting, LLC|, "Testing companyName with embedded quote and comma");
|
is($output, q|Gooey's Consulting, LLC|, "Testing companyName with embedded quote and comma");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
END {
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -14,26 +14,16 @@ use lib "$FindBin::Bin/../lib";
|
||||||
|
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
use WebGUI::Macro::e_companyEmail;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
use Test::More; # increment this value for each test you create
|
use Test::More; # increment this value for each test you create
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
||||||
my $numTests = 1 + 1;
|
plan tests => 1;
|
||||||
|
|
||||||
plan tests => $numTests;
|
|
||||||
|
|
||||||
my $macro = 'WebGUI::Macro::e_companyEmail';
|
|
||||||
my $loaded = use_ok($macro);
|
|
||||||
|
|
||||||
SKIP: {
|
|
||||||
|
|
||||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
|
||||||
|
|
||||||
my ($value) = $session->dbSlave->quickArray(
|
my ($value) = $session->dbSlave->quickArray(
|
||||||
"select value from settings where name='companyEmail'");
|
"select value from settings where name='companyEmail'");
|
||||||
my $output = WebGUI::Macro::e_companyEmail::process($session);
|
my $output = WebGUI::Macro::e_companyEmail::process($session);
|
||||||
is($output, $value, sprintf "Testing companyEmail");
|
is($output, $value, sprintf "Testing companyEmail");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use lib "$FindBin::Bin/../lib";
|
||||||
use WebGUI::Test;
|
use WebGUI::Test;
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
|
|
||||||
use Test::More tests => 58; # increment this value for each test you create
|
use Test::More tests => 62; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
|
|
||||||
my $session = WebGUI::Test->session;
|
my $session = WebGUI::Test->session;
|
||||||
|
|
@ -117,6 +117,16 @@ is($sessionBank[0]->scratch->deleteNameByValue('',''), undef, 'deleteNameByValue
|
||||||
is($sessionBank[3]->scratch->deleteNameByValue('falseValue','0'), 1, 'deleteNameByValue will delete values that are false (0)');
|
is($sessionBank[3]->scratch->deleteNameByValue('falseValue','0'), 1, 'deleteNameByValue will delete values that are false (0)');
|
||||||
is($sessionBank[2]->scratch->deleteNameByValue('falseValue',''), 1, "deleteNameByValue will delete values that are false ('')");
|
is($sessionBank[2]->scratch->deleteNameByValue('falseValue',''), 1, "deleteNameByValue will delete values that are false ('')");
|
||||||
|
|
||||||
|
$scratch->setLanguageOverride('English');
|
||||||
|
is($scratch->getLanguageOverride, 'English', 'session scratch language is not correctly set');
|
||||||
|
$scratch->removeLanguageOverride;
|
||||||
|
is($scratch->getLanguageOverride, undef, 'The session scratch variable language is not removed');
|
||||||
|
$scratch->setLanguageOverride('myimmaginarylanguagethatisnotinstalled');
|
||||||
|
is($scratch->getLanguageOverride, undef, 'A non-existing language is set');
|
||||||
|
$scratch->setLanguageOverride('English');
|
||||||
|
$scratch->setLanguageOverride();
|
||||||
|
is($scratch->getLanguageOverride, 'English', 'A empty string is falsely recognised as a language');
|
||||||
|
|
||||||
END {
|
END {
|
||||||
$session->scratch->deleteAll;
|
$session->scratch->deleteAll;
|
||||||
foreach my $wgSess ($newSession, @sessionBank) {
|
foreach my $wgSess ($newSession, @sessionBank) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue