Merge commit 'v7.10.21' into WebGUI8. Also, add POD and fix broken tests.
This commit is contained in:
commit
4855816a29
72 changed files with 1357 additions and 82 deletions
|
|
@ -162,6 +162,11 @@ $storage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg'))
|
|||
$storage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('littleTextFile'));
|
||||
my $attachment_loop = $post1->getTemplateVars()->{attachment_loop};
|
||||
|
||||
use Data::Dumper;
|
||||
diag Dumper($attachment_loop);
|
||||
|
||||
my @extensions = map { [ $_->{filename}, $_->{extension} ] } @{ $attachment_loop };
|
||||
|
||||
cmp_bag(
|
||||
$attachment_loop,
|
||||
[
|
||||
|
|
@ -170,6 +175,7 @@ cmp_bag(
|
|||
url => $storage->getUrl('gooey.jpg'),
|
||||
icon => $session->url->extras('fileIcons/jpg.gif'),
|
||||
thumbnail => $storage->getThumbnailUrl('gooey.jpg'),
|
||||
extension => 'jpg',
|
||||
isImage => bool(1),
|
||||
},
|
||||
{
|
||||
|
|
@ -177,6 +183,7 @@ cmp_bag(
|
|||
url => $storage->getUrl('lamp.jpg'),
|
||||
icon => $session->url->extras('fileIcons/jpg.gif'),
|
||||
thumbnail => $storage->getThumbnailUrl('lamp.jpg'),
|
||||
extension => 'jpg',
|
||||
isImage => bool(1),
|
||||
},
|
||||
{
|
||||
|
|
@ -184,6 +191,7 @@ cmp_bag(
|
|||
url => $storage->getUrl('littleTextFile'),
|
||||
icon => $session->url->extras('fileIcons/unknown.gif'),
|
||||
thumbnail => '',
|
||||
extension => undef,
|
||||
isImage => bool(0),
|
||||
},
|
||||
],
|
||||
|
|
|
|||
|
|
@ -14,8 +14,11 @@ use File::Spec;
|
|||
##The goal of this test is to test the creation of Article Wobjects.
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Test::MockAsset;
|
||||
use WebGUI::Session;
|
||||
use Test::More tests => 23; # increment this value for each test you create
|
||||
use Test::More tests => 24; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
use WebGUI::Asset::Wobject::Article;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
|
@ -61,9 +64,10 @@ foreach my $newSetting (keys %{$newArticleSettings}) {
|
|||
}
|
||||
|
||||
# Test the duplicate method... not for assets, just the extended duplicate functionality of the article wobject
|
||||
my $filename = "page_title.jpg";
|
||||
my $filename = "extensions.tar";
|
||||
my $pathedFile = WebGUI::Test->getTestCollateralPath($filename);
|
||||
|
||||
|
||||
# Use some test collateral to create a storage location and assign it to our article
|
||||
my $storage = WebGUI::Storage->create($session);
|
||||
WebGUI::Test->addToCleanup($storage);
|
||||
|
|
@ -75,6 +79,10 @@ diag(join("\n", @{ $storage->getErrors })) unless $filenameOK;
|
|||
$article->update({storageId=>$storage->getId});
|
||||
my $storageOK = is($article->get('storageId'), $storage->getId, 'correct storage id stored');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip 'storage test setup problem', 3 unless $filenameOK and $storageOK;
|
||||
|
|
@ -117,6 +125,55 @@ $cachedOutput = $session->cache->get('view_'.$article->getId); # Check cache po
|
|||
isnt ($output, $cachedOutput, 'purgeCache method deletes cache');
|
||||
|
||||
|
||||
# lets test that our new template variable for the fileloop in the main view method returns the
|
||||
# right values for the new field in the attached files loop: <tmpl_var extension>
|
||||
# first we create a new template with only the <tmpl_var extension> field in it
|
||||
# --------------------------------------------------------------------------------------------------
|
||||
my $templateId = 'DUMMY_TEMPLATE________';
|
||||
|
||||
my $templateMock = WebGUI::Test::MockAsset->new('WebGUI::Asset::Template');
|
||||
$templateMock->mock_id($templateId);
|
||||
my $templateVars;
|
||||
$templateMock->set_true('prepare', sub { } );
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
my @extTestFiles = ("rotation_test.png","littleTextFile","jquery.js","tooWide.gif");
|
||||
|
||||
foreach my $f (@extTestFiles) {
|
||||
my $pathedFile = WebGUI::Test->getTestCollateralPath($f);
|
||||
my $storedFilename = $storage->addFileFromFilesystem($pathedFile);
|
||||
}
|
||||
|
||||
$article->update({templateId=>$templateId});
|
||||
$article->prepareView;
|
||||
$article->view;
|
||||
|
||||
cmp_bag(
|
||||
$templateVars->{attachment_loop},
|
||||
[
|
||||
superhashof({
|
||||
filename => 'rotation_test.png',
|
||||
extension => 'png',
|
||||
}),
|
||||
superhashof({
|
||||
filename => 'littleTextFile',
|
||||
extension => undef,
|
||||
}),
|
||||
superhashof({
|
||||
filename => 'jquery.js',
|
||||
extension => 'js',
|
||||
}),
|
||||
superhashof({
|
||||
filename => 'tooWide.gif',
|
||||
extension => 'gif',
|
||||
}),
|
||||
superhashof({
|
||||
filename => 'extensions.tar',
|
||||
extension => 'tar',
|
||||
}),
|
||||
],
|
||||
) or diag Dumper($templateVars->{attachment_loop});
|
||||
|
||||
TODO: {
|
||||
local $TODO = "Tests to make later";
|
||||
ok(0, 'Test exportAssetData method');
|
||||
|
|
@ -126,3 +183,7 @@ TODO: {
|
|||
ok(0, 'Test www_deleteFile method');
|
||||
ok(0, 'Test www_view method... maybe?');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -81,4 +81,4 @@ my $field1 = $thingy->getFields($thingId)->hashRef;
|
|||
|
||||
note 'getFieldValue';
|
||||
is $thingy->getFieldValue(WebGUI::Test->webguiBirthday, $field1), '8/16/2001', 'with epoch as default';
|
||||
is $thingy->getFieldValue('2011-07-04', $field1), '7/4/2011', 'with mysql date as default';
|
||||
is $thingy->getFieldValue('2011-07-04', $field1), '7/3/2011', 'with mysql date as default';
|
||||
|
|
|
|||
43
t/Asset/editFormOverride.t
Normal file
43
t/Asset/editFormOverride.t
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
use warnings;
|
||||
use strict;
|
||||
|
||||
use FindBin;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use lib "$FindBin::Bin/../t/lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Asset;
|
||||
use Test::More tests => 2;
|
||||
use Monkey::Patch qw(patch_class);
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
WebGUI::Test->originalConfig('assets/WebGUI::Asset::Wobject::Layout');
|
||||
my $asset = WebGUI::Asset->getTempspace($session)->addChild(
|
||||
{
|
||||
className => 'WebGUI::Asset::Wobject::Layout',
|
||||
}
|
||||
);
|
||||
WebGUI::Test->addToCleanup($asset);
|
||||
|
||||
sub capture {
|
||||
my $save;
|
||||
my $patch = patch_class 'WebGUI::Form::Control' => new => sub {
|
||||
my $orig = shift;
|
||||
my $self = $orig->(@_);
|
||||
my $name = $self->get('name');
|
||||
$save = $self if $name && $name eq 'assetsToHide';
|
||||
return $self;
|
||||
};
|
||||
$asset->getEditForm;
|
||||
#use Data::Dumper::Concise;
|
||||
#print STDERR '# ' . Dumper $save->{_params};
|
||||
return $save;
|
||||
}
|
||||
|
||||
my $config = $session->config;
|
||||
my $pfx = 'assets/WebGUI::Asset::Wobject::Layout/fields/assetsToHide';
|
||||
$config->set("$pfx/uiLevel", 1);
|
||||
is capture->get('uiLevel'), 1, 'uiLevel override to 1';
|
||||
|
||||
$config->set("$pfx/uiLevel", "2");
|
||||
is capture->get('uiLevel'), 2, 'uiLEvel override to 2';
|
||||
Loading…
Add table
Add a link
Reference in a new issue