From 8ffb9ac03036496008de781b2070f2fec9bfde23 Mon Sep 17 00:00:00 2001 From: GeorgeClark Date: Fri, 14 May 2010 03:14:38 +0000 Subject: [PATCH] Item9015: Add unit test to confirm attachments missing from metadata are found. git-svn-id: http://svn.foswiki.org/trunk/AttachmentListPlugin@7397 0b4bb1d4-4e5a-0410-9cc4-b2b747904278 --- .../AttachmentListPluginTests.pm | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/unit/AttachmentListPlugin/AttachmentListPluginTests.pm b/test/unit/AttachmentListPlugin/AttachmentListPluginTests.pm index e478ef5..17ca8e6 100644 --- a/test/unit/AttachmentListPlugin/AttachmentListPluginTests.pm +++ b/test/unit/AttachmentListPlugin/AttachmentListPluginTests.pm @@ -13,6 +13,7 @@ use Foswiki::OopsException; use Foswiki::Plugins::AttachmentListPlugin; use Devel::Symdump; use Data::Dumper; +use File::Path qw(mkpath); my %testAttachments = ( topic1 => { @@ -192,6 +193,39 @@ sub test_param_topic { =pod +Test retrieval of attachments autoattached, and not in metadata. + +=cut + +sub test_Item9015 { + my $this = shift; + + my $testTopic1 = $testAttachments{topic1}{name}; + my $testTopic2 = $testAttachments{topic2}{name}; + + my $source = +"%ATTACHMENTLIST{topic=\"$testTopic1,$testTopic2\" format=\"\$fileName\" separator=\",\" sort=\"\$fileName\"}%"; + + my $expected = +'A_important_salary_raise.txt,AutoAttachedFile.blah,B_contract_negotiations.txt,C_image.jpg,D_photo.PNG'; + + + my $content = "datadata\n"; + my $path = $Foswiki::cfg{PubDir} . '/' . $this->{test_web} . '/' . $testTopic1; + my $file = 'AutoAttachedFile.blah'; + + mkpath($path); + open( my $fh, '>', "$path/$file" ) + or die "Unable to open $path/$file for writing: $!\n"; + print $fh "$content \n"; + close($fh); + + $this->_do_test( $testTopic1, $expected, $source ); + + unlink "$path/$file"; +} +=pod + TODO: Test retrieval of attachments of specified topic 1, passed 2 times.