Skip to content

Commit

Permalink
Item1247: Fix buggy unit test ($text wasn't expanded properly).
Browse files Browse the repository at this point in the history
One test was dubious, when subwebs='SomeWeb', it should list all sub-webs from SomeWeb, and not SomeWeb itself

git-svn-id: http://svn.foswiki.org/trunk@3017 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
OlivierRaginel authored and OlivierRaginel committed Mar 11, 2009
1 parent 0052ff5 commit eeb22cc
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions UnitTestContrib/test/unit/Fn_WEBLIST.pm
Expand Up @@ -42,6 +42,7 @@ sub set_up {

sub test_public {
my $this = shift;

# separator=", " Line separator Default: "$n" (new line)
my $text = $this->{test_topicObject}->expandMacros('%WEBLIST%');
$this->assert_str_equals( join( "\n", @allWebs ), $text );
Expand All @@ -53,15 +54,17 @@ sub test_template {
my $this = shift;

# separator=", " Line separator Default: "$n" (new line)
my $text = $this->{test_topicObject}->expandMacros('%WEBLIST{webs="webtemplate"}%');
my $text =
$this->{test_topicObject}->expandMacros('%WEBLIST{webs="webtemplate"}%');
$this->assert_str_equals( join( "\n", @templateWebs ), $text );
}

sub test_separator {
my $this = shift;

# separator=", " Line separator Default: "$n" (new line)
my $text = $this->{test_topicObject}->expandMacros('%WEBLIST{separator=";"}%');
my $text =
$this->{test_topicObject}->expandMacros('%WEBLIST{separator=";"}%');
$this->assert_str_equals( join( ';', @allWebs ), $text );
}

Expand All @@ -75,8 +78,8 @@ sub test_format {
my $text =
$this->{test_topicObject}
->expandMacros('%WEBLIST{"$name:$qname:$web" web="sponge"}%');
$this->assert_str_equals(
join( "\n", map { "$_:\"$_\":sponge" } @allWebs ), $text );
$this->assert_str_equals( join( "\n", map { "$_:\"$_\":sponge" } @allWebs ),
$text );
$text =
$this->{test_topicObject}->expandMacros('%WEBLIST{"$name:$qname:$web"}%');
$this->assert_str_equals( join( "\n", map { "$_:\"$_\":" } @allWebs ),
Expand All @@ -86,8 +89,8 @@ sub test_format {
$text =
$this->{test_topicObject}
->expandMacros('%WEBLIST{format="$name:$qname:$web" web="sponge"}%');
$this->assert_str_equals(
join( "\n", map { "$_:\"$_\":sponge" } @allWebs ), $text );
$this->assert_str_equals( join( "\n", map { "$_:\"$_\":sponge" } @allWebs ),
$text );
}

sub test_subwebs {
Expand Down Expand Up @@ -156,14 +159,13 @@ sub test_webs {
sub test_WEBLIST_all {
my $this = shift;

my $text = ' %WEBLIST{format="#$name#" separator=" "}% ';
$this->{test_topicObject}->expandMacros($text);
my $text =
$this->{test_topicObject}
->expandMacros(' %WEBLIST{format="#$name#" separator=" "}% ');

foreach my $web (
$this->{test_web},
"$this->{test_web}/Subweb",
$Foswiki::cfg{UsersWebName}, 'Sandbox', $Foswiki::cfg{SystemWebName}
)
foreach my $web ( $this->{test_web}, "$this->{test_web}/Subweb",
$Foswiki::cfg{UsersWebName},
'Sandbox', $Foswiki::cfg{SystemWebName} )
{
$this->assert_matches( qr!#$web#!, $text );
}
Expand All @@ -173,16 +175,20 @@ sub test_WEBLIST_relative {
my $this = shift;

my $text =
' %WEBLIST{format="#$name#" separator=" " subwebs="' . $this->{test_web} . '"}% ';
$text = $this->{test_topicObject}->expandMacros($text);
$this->assert_matches( qr!#$this->{test_web}#!, $text );
$this->{test_topicObject}
->expandMacros( ' %WEBLIST{format="#$name#" separator=" " subwebs="'
. $this->{test_web}
. '"}% ' );
$this->assert_matches( qr!#$this->{test_web}/Subweb#!, $text );
}

sub test_WEBLIST_end {
my $this = shift;

my $text = ' %WEBLIST{format="#$name#" separator=" " subwebs="'
. $this->{test_web} . '/Subweb"}% ';
my $text =
' %WEBLIST{format="#$name#" separator=" " subwebs="'
. $this->{test_web}
. '/Subweb"}% ';
$text = $this->{test_topicObject}->expandMacros($text);
$this->assert_equals( ' ', $text );
}
Expand Down

0 comments on commit eeb22cc

Please sign in to comment.