Merge branch 'master' into WebGUI8. Merged up to 7.10.4
This commit is contained in:
commit
5f3014aaee
66 changed files with 3078 additions and 997 deletions
|
|
@ -17,6 +17,7 @@ use WebGUI::Test;
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::VersionTag;
|
||||
use Test::MockObject;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
plan tests => 29;
|
||||
|
|
@ -147,12 +148,20 @@ sub copied {
|
|||
return undef;
|
||||
}
|
||||
|
||||
my @methods = qw(Single Children Descendants);
|
||||
my $process = Test::MockObject->new->mock(update => sub {});
|
||||
my @methods = (
|
||||
# single duplicate doesn't fork, so we can just test the www method to
|
||||
# make sure it gets it right
|
||||
sub { shift->www_copy },
|
||||
sub { shift->duplicateBranch(1, 'clipboard') },
|
||||
sub { shift->duplicateBranch(0, 'clipboard') },
|
||||
);
|
||||
my @prefixes = qw(single children descendants);
|
||||
for my $i (0..2) {
|
||||
my $meth = "_wwwCopy$methods[$i]";
|
||||
my $meth = $methods[$i];
|
||||
$root->$meth();
|
||||
my $clip = copied();
|
||||
is_tree_of_folders($clip, $i+1, $meth);
|
||||
is_tree_of_folders($clip, $i+1, @prefixes[$i]);
|
||||
$clip->purge;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,4 +142,13 @@ is ($event7->get('startDate'), '2000-09-01', 'startDate bumped by 1 day');
|
|||
is ($event7->get('endTime'), '00:00:00', 'endTime set to 00:00:00 if the hour is more than 23');
|
||||
is ($event7->get('endDate'), '2000-09-02', 'endDate bumped by 1 day');
|
||||
|
||||
#######################################
|
||||
#
|
||||
# duplicate
|
||||
#
|
||||
#######################################
|
||||
|
||||
|
||||
my $event6b = $event6->duplicate();
|
||||
isnt($event6b->get('storageId'), $event6->get('storageId'), 'duplicating an asset creates a new storage location');
|
||||
done_testing;
|
||||
|
|
|
|||
66
t/Asset/Shortcut/020-content-last-modified.t
Normal file
66
t/Asset/Shortcut/020-content-last-modified.t
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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";
|
||||
|
||||
## The goal of this test is to test the link between the asset and its shortcut
|
||||
# and that changes to the asset are propagated to the shortcut
|
||||
|
||||
use Scalar::Util qw( blessed );
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use Test::More;
|
||||
use WebGUI::Asset::Shortcut;
|
||||
use WebGUI::Asset::Snippet;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Shortcut Test"});
|
||||
WebGUI::Test->addToCleanup($versionTag);
|
||||
# Make a snippet to shortcut
|
||||
my $now = time();
|
||||
my $snippet = $node->addChild({
|
||||
className => "WebGUI::Asset::Snippet",
|
||||
},
|
||||
undef, $now-50);
|
||||
|
||||
my $shortcut = $node->addChild({
|
||||
className => "WebGUI::Asset::Shortcut",
|
||||
shortcutToAssetId => $snippet->getId,
|
||||
},
|
||||
undef, $now-10);
|
||||
$versionTag->commit;
|
||||
$session->db->write(q|update assetData set lastModified=? where assetId=?|,[WebGUI::Test->webguiBirthday, $snippet->getId]);
|
||||
foreach my $asset ($snippet, $shortcut) {
|
||||
$asset = $asset->cloneFromDb;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 2;
|
||||
|
||||
is( $shortcut->getContentLastModified, $now-10, "getContentLastModified: returns date of shortcut since it has a newer revision date.");
|
||||
|
||||
$snippet->update({snippet => 'updated', }, $now-5);
|
||||
|
||||
diag $snippet->get('lastModified');
|
||||
diag $snippet->getContentLastModified;
|
||||
$shortcut = $shortcut->cloneFromDb; ##Wipe the cached version of the shortcut.
|
||||
|
||||
is( $shortcut->getContentLastModified, $snippet->get('lastModified'), "returns lastModified when shortcutted asset has a more recent date");
|
||||
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ use Test::MockObject::Extends;
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Test::MockAsset;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 8; # increment this value for each test you create
|
||||
use Test::More tests => 9; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
|
||||
|
|
@ -126,6 +126,14 @@ cmp_deeply(
|
|||
$session->request->setup_body({ });
|
||||
$session->scratch->delete('userId');
|
||||
|
||||
################################################################
|
||||
#
|
||||
# getStatusList
|
||||
#
|
||||
################################################################
|
||||
$board->update({statusList => "In\r\nOut\rHome\nLunch"});
|
||||
is_deeply [$board->getStatusList], [qw(In Out Home Lunch)], 'getStatusList';
|
||||
|
||||
################################################################
|
||||
#
|
||||
# view
|
||||
|
|
|
|||
|
|
@ -119,13 +119,37 @@ my $dt = DateTime->from_epoch(epoch => $now, time_zone => $session->datetime->ge
|
|||
my $folderName = $dt->strftime('%B_%d_%Y');
|
||||
$folderName =~ s/^(\w+_)0/$1/;
|
||||
is($todayFolder->getTitle, $folderName, '... folder has the right name');
|
||||
my $folderUrl = join '/', $archive->getUrl, lc $folderName;
|
||||
is($todayFolder->getUrl, $folderUrl, '... folder has the right URL');
|
||||
my $folderUrl = $archive->getFolderUrl($folderName);
|
||||
is($todayFolder->get('url'), $folderUrl, '... folder has the right URL');
|
||||
is($todayFolder->getParent->getId, $archive->getId, '... created folder has the right parent');
|
||||
is($todayFolder->get('state'), 'published', '... created folder is published');
|
||||
is($todayFolder->get('status'), 'approved', '... created folder is approved');
|
||||
is($todayFolder->get('styleTemplateId'), $archive->get('styleTemplateId'), '... created folder has correct styleTemplateId');
|
||||
|
||||
{
|
||||
my $undo = WebGUI::Test->overrideSetting(urlExtension => 'ext');
|
||||
my $arch2 = $home->addChild({
|
||||
className => $class,
|
||||
title => 'Extension Tester',
|
||||
});
|
||||
addToCleanup($arch2);
|
||||
|
||||
is $arch2->get('url'),
|
||||
'home/extension-tester.ext',
|
||||
'ext added';
|
||||
|
||||
is $arch2->getFolderUrl('blah'),
|
||||
'home/extension-tester/blah.ext',
|
||||
'folder url: strip extension from parent and add to child';
|
||||
|
||||
my $folder = $arch2->getFolder($now);
|
||||
ok defined $folder, 'getFolder with url extension';
|
||||
|
||||
is $folder->get('url'),
|
||||
$arch2->getFolderUrl($folder->getMenuTitle),
|
||||
'getFolderUrl and folder getUrl match';
|
||||
}
|
||||
|
||||
my $sameFolder = $archive->getFolder($now);
|
||||
is($sameFolder->getId, $todayFolder->getId, 'call with same time returns the same folder');
|
||||
undef $sameFolder;
|
||||
|
|
|
|||
106
t/Fork.t
Normal file
106
t/Fork.t
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# WebGUI::Fork tests
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/lib";
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
use JSON;
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Fork;
|
||||
|
||||
my $class = 'WebGUI::Fork';
|
||||
my $testClass = 'WebGUI::Test::Fork';
|
||||
my $pipe = $class->init();
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
# test simplest (non-forking) case
|
||||
|
||||
my $process = $class->create($session);
|
||||
my $request = $process->request( $testClass, 'simple', ['data'] );
|
||||
|
||||
cmp_bag(
|
||||
[ keys %$request ],
|
||||
[qw(webguiRoot configFile sessionId id module subname data)],
|
||||
'request hash has the right keys'
|
||||
);
|
||||
|
||||
my $now = time;
|
||||
|
||||
$class->runRequest($request);
|
||||
ok $process->isFinished, 'finished';
|
||||
my $error = $process->getError;
|
||||
ok( !$error, 'no errors' ) or diag " Expected nothing, got: $error\n";
|
||||
$process->setWait(0);
|
||||
is $process->getStatus, 'data', 'proper status';
|
||||
my $started = $process->startTime;
|
||||
ok( ( $started >= $now ), 'sane startTime' );
|
||||
ok( ( $process->endTime >= $started ), 'sane endTime' );
|
||||
|
||||
$process->delete;
|
||||
|
||||
note "Testing error case\n";
|
||||
$process = $class->create($session);
|
||||
$request = $process->request( $testClass, 'error', ['error'] );
|
||||
$class->runRequest($request);
|
||||
ok $process->isFinished, 'finished';
|
||||
is $process->getError, "error\n", 'has error code';
|
||||
$process->setWait(0);
|
||||
my $status = $process->getStatus;
|
||||
ok( !$status, 'no discernable status' ) or diag $status;
|
||||
ok( ( $process->endTime >= $started ), 'sane endTime' );
|
||||
|
||||
my $forkCount = 0;
|
||||
my $forkAndExec = $class->can('forkAndExec');
|
||||
my $replace = sub {
|
||||
my $self = shift;
|
||||
$forkCount++;
|
||||
$self->$forkAndExec(@_);
|
||||
};
|
||||
|
||||
{
|
||||
no strict 'refs';
|
||||
no warnings 'redefine';
|
||||
*{ $class . '::forkAndExec' } = $replace;
|
||||
}
|
||||
|
||||
sub backgroundTest {
|
||||
note "$_[0]\n";
|
||||
$process = $class->start( $session, $testClass, 'complex', ['data'] );
|
||||
my $sleeping;
|
||||
while ( !$process->isFinished && $sleeping++ < 10 ) {
|
||||
sleep 1;
|
||||
}
|
||||
ok $process->isFinished, 'finished';
|
||||
is $process->getStatus, 'baz', 'correct status'
|
||||
or diag $process->getError . "\n";
|
||||
|
||||
$process->delete;
|
||||
}
|
||||
backgroundTest('talk to background');
|
||||
is $forkCount, 0, 'we did not fork';
|
||||
close $pipe;
|
||||
backgroundTest('On-demand fork');
|
||||
is $forkCount, 1, 'we did fork';
|
||||
|
||||
done_testing;
|
||||
|
||||
#vim:ft=perl
|
||||
5
t/HTML.t
5
t/HTML.t
|
|
@ -127,6 +127,7 @@ my @htmlTextSets = (
|
|||
my $numTests = scalar @filterSets
|
||||
+ scalar @macroParamSets
|
||||
+ scalar @htmlTextSets
|
||||
+ 3
|
||||
;
|
||||
|
||||
plan tests => $numTests;
|
||||
|
|
@ -145,3 +146,7 @@ foreach my $testSet (@htmlTextSets) {
|
|||
my $text = WebGUI::HTML::html2text($testSet->{inputText});
|
||||
is($text, $testSet->{output}, $testSet->{comment});
|
||||
}
|
||||
|
||||
is(WebGUI::HTML::processReplacements($session, 'grass'), 'grass', 'processReplacements: grass is not replaced');
|
||||
is(WebGUI::HTML::processReplacements($session, 'shitake'), 'shitake', '... shitake is not replaced');
|
||||
is(WebGUI::HTML::processReplacements($session, 'This is shit.'), 'This is crap.', '... shit is replaced');
|
||||
|
|
|
|||
10
t/SQL.t
10
t/SQL.t
|
|
@ -299,3 +299,13 @@ cmp_deeply(
|
|||
'Check table structure',
|
||||
);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# REGRESSIONS
|
||||
|
||||
# 11940 : quickCSV chokes on newlines
|
||||
$session->db->write(
|
||||
'INSERT INTO testTable (myIndex,message,myKey) VALUES (?,?,?)',
|
||||
[ 10, "a\ntest", 'B' ],
|
||||
);
|
||||
ok( $session->db->quickCSV( 'SELECT * FROM testTable' ), 'get some output even with newlines in data' );
|
||||
|
||||
|
|
|
|||
20
t/lib/WebGUI/Test/Fork.pm
Normal file
20
t/lib/WebGUI/Test/Fork.pm
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package WebGUI::Test::Fork;
|
||||
|
||||
sub simple {
|
||||
my ( $self, $arr ) = @_;
|
||||
$self->update( $arr->[0] );
|
||||
}
|
||||
|
||||
sub error {
|
||||
my ( $self, $arr ) = @_;
|
||||
die "$arr->[0]\n";
|
||||
}
|
||||
|
||||
sub complex {
|
||||
my $self = shift;
|
||||
$self->update( sub {'foo'} );
|
||||
$self->update( sub {'bar'} );
|
||||
$self->update( sub {'baz'} );
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
@ -2,13 +2,13 @@
|
|||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>PM capturó a tres delincuentes que robaron agencia bancaria en San Martín</title>
|
||||
<link>http://www.vtv.gob.ve/rss-noticias-nacionales</link>
|
||||
<link>http://ejemplo.local/rss-noticias-locales</link>
|
||||
<description>RSS Noticias Nacionales</description>
|
||||
<language>es</language>
|
||||
<item>
|
||||
<title>PM capturó a tres delincuentes que robaron agencia bancaria en San Martín</title>
|
||||
<link>http://www.vtv.gob.ve/noticias-nacionales/25087</link>
|
||||
<description><p>Efectivos de la Policía Metropolitana (PM) de Caracas capturaron, este lunes en horas de la mañana, a tres delincuentes implicados en el robo perpetrado en el Banco Industrial de Venezuela (BIV) ubicado dentro de la oficina del Instituto Postal Telegráfico de Venezuela, Ipostel, en la avenida José Ángel Lamas, San Martín.</p></description>
|
||||
<link>http://ejemplo.local/noticias-locales/99999</link>
|
||||
<description><p>Efectivos de la Policía Metropolitana (PM) capturaron, este lunes en horas de la mañana, a tres delincuentes implicados en un robo.</description>
|
||||
<pubDate>Mon, 19 Oct 2009 15:42:17 -0400</pubDate>
|
||||
</item>
|
||||
</channel>
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>PM capturó a tres delincuentes que robaron agencia bancaria en San Martín</title>
|
||||
<link>http://www.vtv.gob.ve/rss-noticias-nacionales</link>
|
||||
<description>RSS Noticias Nacionales</description>
|
||||
<link>http://ejemplo.local/rss-noticias-locales</link>
|
||||
<description>RSS Noticias Locales</description>
|
||||
<language>es</language>
|
||||
<item>
|
||||
<title>PM capturó a tres delincuentes que robaron agencia bancaria en San Martín</title>
|
||||
<link>http://www.vtv.gob.ve/noticias-nacionales/25087</link>
|
||||
<description><p>Efectivos de la Policía Metropolitana (PM) de Caracas capturaron, este lunes en horas de la mañana, a tres delincuentes implicados en el robo perpetrado en el Banco Industrial de Venezuela (BIV) ubicado dentro de la oficina del Instituto Postal Telegráfico de Venezuela, Ipostel, en la avenida José Ángel Lamas, San Martín.</p></description>
|
||||
<link>http://ejemplo.local/noticias-locales/99999</link>
|
||||
<description><p>Efectivos de la Policía Metropolitana (PM) capturaron, este lunes en horas de la mañana, a tres delincuentes implicados en un robo.</description>
|
||||
<pubDate>Mon, 19 Oct 2009 15:42:17 -0400</pubDate>
|
||||
</item>
|
||||
</channel>
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
<rss version="2.0">
|
||||
<channel>
|
||||
<title>PM capturó a tres delincuentes que robaron agencia bancaria en San Martín</title>
|
||||
<link>http://www.vtv.gob.ve/rss-noticias-nacionales</link>
|
||||
<description>RSS Noticias Nacionales</description>
|
||||
<link>http://ejemplo.local/rss-noticias-locales</link>
|
||||
<description>RSS Noticias Locales</description>
|
||||
<language>es</language>
|
||||
<item>
|
||||
<title>PM capturó a tres delincuentes que robaron agencia bancaria en San Martín</title>
|
||||
<link>http://www.vtv.gob.ve/noticias-nacionales/25087</link>
|
||||
<description><p>Efectivos de la Policía Metropolitana (PM) de Caracas capturaron, este lunes en horas de la mañana, a tres delincuentes implicados en el robo perpetrado en el Banco Industrial de Venezuela (BIV) ubicado dentro de la oficina del Instituto Postal Telegráfico de Venezuela, Ipostel, en la avenida José Ángel Lamas, San Martín.</p></description>
|
||||
<link>http://ejemplo.local/noticias-locales/99999</link>
|
||||
<description><p>Efectivos de la Policía Metropolitana (PM) Caracas capturaron, este lunes en horas de la mañana, a tres delincuentes implicados en un robo.</description>
|
||||
<pubDate>Mon, 19 Oct 2009 15:42:17 -0400</pubDate>
|
||||
</item>
|
||||
</channel>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue