Skip to content

Commit

Permalink
Item2371: unit tests for search format controls when no format is spe…
Browse files Browse the repository at this point in the history
…cified

git-svn-id: http://svn.foswiki.org/trunk@5748 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
CrawfordCurrie authored and CrawfordCurrie committed Dec 7, 2009
1 parent f24dcb5 commit dc33ff0
Showing 1 changed file with 130 additions and 0 deletions.
130 changes: 130 additions & 0 deletions UnitTestContrib/test/unit/Fn_SEARCH.pm
Expand Up @@ -2378,4 +2378,134 @@ GNURF
$this->assert_equals("$this->{test_web}/B,$this->{test_web}/C,$this->{test_web}/A", $result);
}

# The results of SEARCH are highly sensitive to the template;
# reduce sensitivity by trimming the result
sub _cut_the_crap {
my $result = shift;
$result =~ s/<!--.*?-->//gs;
$result =~ s/<\/?(span|div|b|h\d)\b.*?>//gs;
$result =~ s/ (class|style|rel)=(["'])[^"']*\2//g;
$result =~ s/( href=(["']))[^"']*(\2)/$1$3/g;
$result =~ s/\d\d:\d\d( \(\w+\))?/TIME/g;
$result =~ s/\d{2} \w{3} \d{4}/DATE/g;
return $result;
}
sub test_no_format_no_shit {
my $this = shift;

my $result =
$this->{test_topicObject}->expandMacros('%SEARCH{"BLEEGLE"}%');
$this->assert_html_equals( <<CRUD, _cut_the_crap($result) );
Searched: <noautolink>BLEEGLE</noautolink>
Results from <nop>TemporarySEARCHTestWebSEARCH web retrieved at TIME<br />
<a href="">OkATopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dontmatchme.blah
<a href="">OkBTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dont.matchmeblah
<a href="">OkTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE blah/matchme.blah
<a href="">TestTopicSEARCH</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE
Number of topics: 4
CRUD
$result =
$this->{test_topicObject}->expandMacros(
'%SEARCH{"BLEEGLE" nosummary="on"}%');
$this->assert_html_equals( <<CRUD, _cut_the_crap($result) );
Searched: <noautolink>BLEEGLE</noautolink>
Results from <nop>TemporarySEARCHTestWebSEARCH web retrieved at TIME<br />
<a href="">OkATopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a><br />
<a href="">OkBTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a><br />
<a href="">OkTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a><br />
<a href="">TestTopicSEARCH</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a><br />
Number of topics: 4
CRUD
$result =
$this->{test_topicObject}->expandMacros(
'%SEARCH{"BLEEGLE" nosearch="on"}%');
$this->assert_html_equals( <<CRUD, _cut_the_crap($result) );
Results from <nop>TemporarySEARCHTestWebSEARCH web retrieved at TIME<br />
<a href="">OkATopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dontmatchme.blah
<a href="">OkBTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dont.matchmeblah
<a href="">OkTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE blah/matchme.blah
<a href="">TestTopicSEARCH</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE
Number of topics: 4
CRUD
$result =
$this->{test_topicObject}->expandMacros(
'%SEARCH{"BLEEGLE" nototal="on"}%');
$this->assert_html_equals( <<CRUD, _cut_the_crap($result) );
Searched: <noautolink>BLEEGLE</noautolink>
Results from <nop>TemporarySEARCHTestWebSEARCH web retrieved at TIME<br />
<a href="">OkATopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dontmatchme.blah
<a href="">OkBTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dont.matchmeblah
<a href="">OkTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE blah/matchme.blah
<a href="">TestTopicSEARCH</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE
CRUD
$result =
$this->{test_topicObject}->expandMacros(
'%SEARCH{"BLEEGLE" noheader="on"}%');
$this->assert_html_equals( <<CRUD, _cut_the_crap($result) );
Searched: <noautolink>BLEEGLE</noautolink>
<a href="">OkATopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dontmatchme.blah
<a href="">OkBTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dont.matchmeblah
<a href="">OkTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE blah/matchme.blah
<a href="">TestTopicSEARCH</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE
Number of topics: 4
CRUD
$result =
$this->{test_topicObject}->expandMacros(
'%SEARCH{"BLEEGLE" noempty="on"}%');
$this->assert_html_equals( <<CRUD, _cut_the_crap($result) );
Searched: <noautolink>BLEEGLE</noautolink>
Results from <nop>TemporarySEARCHTestWebSEARCH web retrieved at TIME<br />
<a href="">OkATopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dontmatchme.blah
<a href="">OkBTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dont.matchmeblah
<a href="">OkTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE blah/matchme.blah
<a href="">TestTopicSEARCH</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE
Number of topics: 4
CRUD
$result =
$this->{test_topicObject}->expandMacros(
'%SEARCH{"BLEEGLE" zeroresults="on"}%');
$this->assert_html_equals( <<CRUD, _cut_the_crap($result) );
Searched: <noautolink>BLEEGLE</noautolink>
Results from <nop>TemporarySEARCHTestWebSEARCH web retrieved at TIME<br />
<a href="">OkATopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dontmatchme.blah
<a href="">OkBTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE dont.matchmeblah
<a href="">OkTopic</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE blah/matchme.blah
<a href="">TestTopicSEARCH</a> TemporarySEARCHUsersWeb.WikiGuestNEW - <a href="">DATE - TIME</a>&nbsp;<br /><nop>BLEEGLE
Number of topics: 4
CRUD

$result =
$this->{test_topicObject}->expandMacros(
'%SEARCH{"BLEEGLE" nosummary="on" nosearch="on" nototal="on" zeroresults="off" noheader="on" noempty="on"}%');
my $result2 =
$this->{test_topicObject}->expandMacros(
'%SEARCH{"BLEEGLE" nosummary="on" nonoise="on"}%');
$this->assert_html_equals( $result, $result2 );
}

1;

0 comments on commit dc33ff0

Please sign in to comment.