From c07b0b9c724aab659733e7a8feb6198a740289f0 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Sat, 7 Jul 2007 03:38:16 +0000 Subject: [PATCH] Add the Storage::Image test. This really, really wants to be done with Test::Class in the long term. Fixed a bug where Storage::Image's getFiles does not obey the showAll switch that its parent has. --- lib/WebGUI/Storage/Image.pm | 2 +- t/Storage/Image.t | 58 +++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 t/Storage/Image.t diff --git a/lib/WebGUI/Storage/Image.pm b/lib/WebGUI/Storage/Image.pm index a98f73a32..9ad9978e7 100644 --- a/lib/WebGUI/Storage/Image.pm +++ b/lib/WebGUI/Storage/Image.pm @@ -179,7 +179,7 @@ Returns an array reference of the files in this storage location. sub getFiles { my $self = shift; - my $files = $self->SUPER::getFiles; + my $files = $self->SUPER::getFiles(@_); my @newFiles; foreach my $file (@{$files}) { next if $file =~ /^thumb-/; diff --git a/t/Storage/Image.t b/t/Storage/Image.t new file mode 100644 index 000000000..cba9f5d9c --- /dev/null +++ b/t/Storage/Image.t @@ -0,0 +1,58 @@ +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2006 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"; +our $todo; + +use WebGUI::Test; +use WebGUI::Session; +use WebGUI::Storage::Image; + +use File::Spec; +use Test::More; +use Test::Deep; + +plan tests => 7; # increment this value for each test you create + +my $session = WebGUI::Test->session; + +my $uploadDir = $session->config->get('uploadsPath'); +ok ($uploadDir, "uploadDir defined in config"); + +my $uploadUrl = $session->config->get('uploadsURL'); +ok ($uploadUrl, "uploadDir defined in config"); + +my $originalCaseInsensitiveOS = $session->config->get('caseInsensitiveOS'); +$session->config->set('caseInsensitiveOS', 0); + +#################################################### +# +# getFiles +# +#################################################### + +my $imageStore = WebGUI::Storage::Image->create($session); +cmp_bag($imageStore->getFiles(1), ['.', '..'], 'Starting with an empty storage object, no files in here except for . and ..'); +$imageStore->addFileFromScalar('.dotfile', 'dot file'); +cmp_bag($imageStore->getFiles(), [ ], 'getFiles() by default does not return dot files'); +cmp_bag($imageStore->getFiles(1), ['.', '..', '.dotfile'], 'getFiles(1) returns all files, including dot files'); +$imageStore->addFileFromScalar('dot.file', 'dot.file'); +cmp_bag($imageStore->getFiles(), ['dot.file'], 'getFiles() returns normal files'); +cmp_bag($imageStore->getFiles(1), ['.', '..', '.dotfile', 'dot.file'], 'getFiles(1) returns all files, including dot files'); + +END { + foreach my $stor ( + $imageStore, + ) { + ref $stor eq "WebGUI::Storage::Image" and $stor->delete; + } +}