Skip to content

Commit

Permalink
Item11105: Add unit test for attachment comment
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@12514 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Sep 12, 2011
1 parent c26bc5a commit ae6efd5
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions UnitTestContrib/test/unit/FuncTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,65 @@ sub test_attachments {

}

sub test_attachment_comment {
my $this = shift;
$Foswiki::cfg{EnableHierarchicalWebs} = 1;

my $data = "\0b\1l\2a\3h\4b\5l\6a\7h";
my $data2 = "\0h\1a\2l\3b\4h\5a\6l\7b";
my $attnm = 'blahblahblah.gif';

my $topic = "BlahBlahBlah";
my $name1 = 'blahblahblah.gif';

my $stream =
$this->write_file( $this->{tmpdatafile}, $data,
{ binmode => 1, read => 1 } );
$this->write_file( $this->{tmpdatafile2}, $data2, { binmode => 1 } );

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

my $attachComment = 'Feasgar Blha';

my $e = Foswiki::Func::saveAttachment(
$this->{test_web},
$topic, $name1,
{
dontlog => 1,
comment => $attachComment,
stream => $stream,
filepath => '/local/file',
filesize => 999,
filedate => 0,
}
);
$this->assert( !$e, $e );

my ( $date, $user, $rev, $actualComment ) =
Foswiki::Func::getRevisionInfo( $this->{test_web}, $topic, undef, $name1 );

$this->assert_str_equals( $attachComment, $actualComment );

$actualComment .= ' changed';

$e = Foswiki::Func::saveAttachment(
$this->{test_web},
$topic, $name1,
{
dontlog => 1,
comment => $attachComment,
}
);
$this->assert( !$e, $e );

( $date, $user, $rev, $actualComment ) =
Foswiki::Func::getRevisionInfo( $this->{test_web}, $topic, undef, $name1 );

$this->assert_str_equals( $attachComment, $actualComment );

}


sub test_noauth_saveAttachment {
my $this = shift;
use Foswiki::AccessControlException;
Expand Down

0 comments on commit ae6efd5

Please sign in to comment.