Skip to content

Commit

Permalink
Item9509: Fix unit tests - Didn't work with minimal LocalSite.cfg
Browse files Browse the repository at this point in the history
 - Content-Type includes character set in full configuration
 - Short URL's not properly implemented in test.

git-svn-id: http://svn.foswiki.org/trunk@8621 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
GeorgeClark authored and GeorgeClark committed Aug 21, 2010
1 parent ce02a5f commit a014be2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
10 changes: 4 additions & 6 deletions UnitTestContrib/test/unit/FuncTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -195,25 +195,23 @@ sub test_getViewUrl {
$ss = 'view' . $Foswiki::cfg{ScriptSuffix};
}

$ss .= '/' if ($ss);

# relative to specified web
my $result = Foswiki::Func::getViewUrl( $this->{users_web}, "WebHome" );
$this->assert_matches( qr!/$ss$this->{users_web}/WebHome!, $result );
$this->assert_matches( qr!$ss/$this->{users_web}/WebHome!, $result );

# relative to web in path_info
$result = Foswiki::Func::getViewUrl( "", "WebHome" );
$this->assert_matches( qr!/$ss$this->{test_web}/WebHome!, $result );
$this->assert_matches( qr!$ss/$this->{test_web}/WebHome!, $result );

$Foswiki::Plugins::SESSION =
new Foswiki( undef,
new Unit::Request( { topic => "Sausages.AndMash" } ) );

$result = Foswiki::Func::getViewUrl( "Sausages", "AndMash" );
$this->assert_matches( qr!/${ss}Sausages/AndMash!, $result );
$this->assert_matches( qr!${ss}/Sausages/AndMash!, $result );

$result = Foswiki::Func::getViewUrl( "", "AndMash" );
$this->assert_matches( qr!/${ss}Sausages/AndMash!, $result );
$this->assert_matches( qr!${ss}/Sausages/AndMash!, $result );
$Foswiki::Plugins::SESSION->finish();
}

Expand Down
10 changes: 5 additions & 5 deletions UnitTestContrib/test/unit/ViewScriptTests.pm
Original file line number Diff line number Diff line change
Expand Up @@ -225,19 +225,19 @@ sub test_render_raw {

($text, $hdr) = $this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'text');
$this->assert_equals( "$topic2", $text, "Unexpected output from raw=text" );
$this->assert_matches( qr#^Content-Type: text/plain;#ms, $hdr, "raw=text should return text/plain - got $hdr");
$this->assert_matches( qr#^Content-Type: text/plain#ms, $hdr, "raw=text should return text/plain - got $hdr");

($text, $hdr) = $this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'all');
$this->assert_matches( qr#$topic2meta$topic2#, $text, "Unexpected output from raw=all" );
$this->assert_matches( qr#^Content-Type: text/plain;#ms, $hdr, "raw=all should return text/plain - got $hdr");
$this->assert_matches( qr#^Content-Type: text/plain#ms, $hdr, "raw=all should return text/plain - got $hdr");

($text,$hdr) = $this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'on');
$this->assert_matches( qr#.*$topic2txtarea$topic2rawON.*#, $text, "Unexpected output from raw=on" );
$this->assert_matches( qr#^Content-Type: text/html;#ms, $hdr, "raw=on should return text/html - got $hdr");
$this->assert_matches( qr#^Content-Type: text/html#ms, $hdr, "raw=on should return text/html - got $hdr");

($text, $hdr) = $this->setup_view( $this->{test_web}, 'TestTopic2', 'viewfour', 'debug');
$this->assert_matches( qr#.*$topic2txtarea$topic2metaQ$topic2rawON.*#, $text, "Unexpected output from raw=debug" );
$this->assert_matches( qr#^Content-Type: text/html;#ms, $hdr, "raw=debug should return text/html - got $hdr");
$this->assert_matches( qr#^Content-Type: text/html#ms, $hdr, "raw=debug should return text/html - got $hdr");
}


Expand All @@ -264,7 +264,7 @@ NotTOAutoLink
<hr />posttemplate
HERE
chomp $topic2plain;
$this->assert_matches( qr#^Content-Type: text/plain;#ms, $hdr, "contenttype=text/plain should return text/plain - got $hdr");
$this->assert_matches( qr#^Content-Type: text/plain#ms, $hdr, "contenttype=text/plain should return text/plain - got $hdr");
$this->assert_does_not_match( qr#<(noautolink|nop)>#, $text, "autolink or nop found in text skin" );
$this->assert_equals( "$topic2plain", $text, "Unexpected output from contentype=text/plain skin=text" );

Expand Down

0 comments on commit a014be2

Please sign in to comment.