From 7c3d5721463a509376b19bd0d02419039f09e213 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Mon, 16 Aug 2010 10:09:10 -0700 Subject: [PATCH] Add tests for attachment_loop handling in the Post. --- t/Asset/Post.t | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/t/Asset/Post.t b/t/Asset/Post.t index 98e7a01dd..b33219df0 100644 --- a/t/Asset/Post.t +++ b/t/Asset/Post.t @@ -19,7 +19,8 @@ use strict; use lib "$FindBin::Bin/../lib"; use WebGUI::Test; use WebGUI::Session; -use Test::More tests => 17; # increment this value for each test you create +use Test::More tests => 18; # increment this value for each test you create +use Test::Deep; use WebGUI::Asset::Wobject::Collaboration; use WebGUI::Asset::Post; use WebGUI::Asset::Post::Thread; @@ -166,4 +167,40 @@ $variables = $post2->getTemplateVars(); is( $variables->{'ownerUserId'}, 1, 'first post owned by admin'); ok( $variables->{'hideProfileUrl'}, 'hide profile url, since poster is visitor'); +##Check for attachments + +my $storage = $post1->getStorageLocation(); +$storage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('gooey.jpg')); +$storage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('lamp.jpg')); +$storage->addFileFromFilesystem(WebGUI::Test->getTestCollateralPath('littleTextFile')); +my $attachment_loop = $post1->getTemplateVars()->{attachment_loop}; + +cmp_bag( + $attachment_loop, + [ + { + filename => 'gooey.jpg', + url => $storage->getUrl('gooey.jpg'), + icon => $session->url->extras('fileIcons/jpg.gif'), + thumbnail => $storage->getThumbnailUrl('gooey.jpg'), + isImage => bool(1), + }, + { + filename => 'lamp.jpg', + url => $storage->getUrl('lamp.jpg'), + icon => $session->url->extras('fileIcons/jpg.gif'), + thumbnail => $storage->getThumbnailUrl('lamp.jpg'), + isImage => bool(1), + }, + { + filename => 'littleTextFile', + url => $storage->getUrl('littleTextFile'), + icon => $session->url->extras('fileIcons/unknown.gif'), + thumbnail => '', + isImage => bool(0), + }, + ], + 'checking attachment loop with multiple attachments for handling of image and non-image types' +); + # vim: syntax=perl filetype=perl