Skip to content

Commit

Permalink
Item13068: rewrite testcase to generate fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
Comment committed Nov 27, 2014
1 parent 91bb61d commit 8998755
Showing 1 changed file with 137 additions and 0 deletions.
137 changes: 137 additions & 0 deletions UnitTestContrib/test/unit/SemiAutomaticTestCaseTests.pm
Expand Up @@ -11,12 +11,140 @@ use Error qw( :try );

my $VIEW_UI_FN;

# Some data used only by TestCaseAutoSearchOrder
my @test_comma_v = (
<<'T1',
head 1.1;
access;
symbols;
locks; strict;
comment @# @;
expand @o@;
1.1
date 2005.12.14.21.56.33; author KennethLavrsen; state Exp;
branches;
next ;
desc
@none
@
1.1
log
@none
@
text
@%META:TOPICINFO{author="KennethLavrsen" date="1134597393" format="1.1" version="1.1"}%
%META:FORM{name="SearchWebForm"}%
%META:FIELD{name="TextItem" attributes="" title="Text Item" value="Value_1"}%
%META:FIELD{name="NumberItem" attributes="" title="Number Item" value="3"}%
@
T1

<<'T2',
head 1.2;
access;
symbols;
locks; strict;
comment @# @;
expand @o@;
1.2
date 2005.12.14.22.23.23; author KennethLavrsen; state Exp;
branches;
next 1.1;
1.1
date 2005.12.14.21.58.17; author KennethLavrsen; state Exp;
branches;
next ;
desc
@none
@
1.2
log
@none
@
text
@%META:TOPICINFO{author="KennethLavrsen" date="1134599003" format="1.1" version="1.2"}%
%META:FORM{name="SearchWebForm"}%
%META:FIELD{name="TextItem" attributes="" title="Text Item" value="Value_2"}%
%META:FIELD{name="NumberItem" attributes="" title="Number Item" value="2"}%
@
1.1
log
@none
@
text
@d1 1
a1 1
%META:TOPICINFO{author="KennethLavrsen" date="1134597497" format="1.1" version="1.1"}%
@
T2

<<'T3');
head 1.1;
access;
symbols;
locks; strict;
comment @# @;
expand @o@;
1.1
date 2005.12.14.21.59.27; author KennethLavrsen; state Exp;
branches;
next ;
desc
@none
@
1.1
log
@none
@
text
@%META:TOPICINFO{author="KennethLavrsen" date="1134597567" format="1.1" version="1.1"}%
%META:FORM{name="SearchWebForm"}%
%META:FIELD{name="TextItem" attributes="" title="Text Item" value="Value_3"}%
%META:FIELD{name="NumberItem" attributes="" title="Number Item" value="1"}%
@
T3

sub set_up {
my $this = shift;
$this->SUPER::set_up();

# Testcases are written using good anchors
$Foswiki::cfg{RequireCompatibleAnchors} = 0;

# Test using an RCS store, fo which we have some bogus topics.
$Foswiki::cfg{Store}{Implementation} = 'Foswiki::Store::RcsLite';
for ( my $i = 1 ; $i <= scalar @test_comma_v ; $i++ ) {
my $f = "$Foswiki::cfg{DataDir}/TestCases/SearchTestTopic$i.txt,v";
unlink $f if -e $f;
open( F, '>', $f ) || die $!;
print F $test_comma_v[ $i - 1 ];
close(F);
}

$VIEW_UI_FN ||= $this->getUIFn('view');

# This user is used in some testcases. All we need to do is make sure
Expand Down Expand Up @@ -44,6 +172,15 @@ sub set_up {
return;
}

sub tear_down {
my $this = shift;
for ( my $i = 1 ; $i <= scalar @test_comma_v ; $i++ ) {
my $f = "$Foswiki::cfg{DataDir}/TestCases/SearchTestTopic$i.txt,v";
unlink $f if -e $f;
}
$this->SUPER::tear_down();
}

sub list_tests {
my ( $this, $suite ) = @_;
my @set = $this->SUPER::list_tests(@_);
Expand Down

0 comments on commit 8998755

Please sign in to comment.