Skip to content

Commit

Permalink
Item9352: unit tests to highlight the change in behaviour of Foswiki:…
Browse files Browse the repository at this point in the history
…:Func::attachmentExists

git-svn-id: http://svn.foswiki.org/trunk@8242 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
AndrewJones authored and AndrewJones committed Jul 19, 2010
1 parent 5c3cd6f commit 8139534
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions UnitTestContrib/test/unit/FuncTests.pm
Expand Up @@ -1012,6 +1012,41 @@ sub test_copyAttachment {

}

sub test_attachmentExists {
my $this = shift;

my $topic = "AttachmentExists";

open( FILE, ">", "$Foswiki::cfg{TempfileDir}/testfile.txt" );
print FILE "one two three";
close( FILE );

Foswiki::Func::saveTopicText( $this->{test_web}, $topic, 'foo' );
Foswiki::Func::saveAttachment(
$this->{test_web}, $topic, "testfile.txt",
{ file => "$Foswiki::cfg{TempfileDir}/testfile.txt",
comment => "a comment" } );

$this->assert(Foswiki::Func::attachmentExists( $this->{test_web}, $topic,
"testfile.txt"));
}

sub test_attachmentExistsInMetaOnly {
my $this = shift;

my $topic = "AttachmentExistsInMetaOnly";
my $text = <<'HERE';
foo
%META:FILEATTACHMENT{name="Sample.txt" attr="" comment="Just a sample" date="964294620" path="Sample.txt" size="30" user="ProjectContributor" version=""}%
HERE

Foswiki::Func::saveTopicText( $this->{test_web}, $topic, $text );

$this->assert(not Foswiki::Func::attachmentExists( $this->{test_web}, $topic,
"Sample.txt"));
}

sub test_workarea {
my $this = shift;

Expand Down

0 comments on commit 8139534

Please sign in to comment.