OpenGuides
view release on metacpan or search on metacpan
t/105_template.t view on Meta::CPAN
config => $config,
template => "105_test.tt",
cookies => $cookie
);
like( $output, qr/Set-Cookie: $cookie/, "cookie in header" );
# Test that external URLs for text formatting work.
$config = OpenGuides::Config->new(
vars => {
template_path => cwd . '/t/templates',
site_name => 'Wiki::Toolkit Test Site',
script_url => 'http://wiki.example.com/',
script_name => 'mywiki.cgi',
formatting_rules_node => 'Some External Help',
formatting_rules_link => 'http://www.example.com/wikitext',
}
);
$output = OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "105_test.tt"
);
like ( $output, qr/FORMATTING RULES LINK: http:\/\/www.example.com\/wikitext/,
"formatting_rules_link var honoured for explicit URLs" );
# Test that home_link is set correctly when script_name is blank.
$config = OpenGuides::Config->new(
vars => {
template_path => cwd . '/t/templates',
site_name => 'Wiki::Toolkit Test Site',
script_url => 'http://wiki.example.com/',
script_name => '',
}
);
$output = OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "105_test.tt"
);
like( $output, qr/HOME LINK: http:\/\/wiki.example.com/,
"home_link var set OK when script_name blank" );
# Test that full_cgi_url comes out right if the trailing '/' is
# missing from script_url in the config file.
$config = OpenGuides::Config->new(
vars => {
template_path => cwd . '/t/templates',
site_name => 'Wiki::Toolkit Test Site',
script_url => 'http://wiki.example.com',
script_name => 'wiki.cgi',
}
);
$output = OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "105_test.tt"
);
like( $output, qr/FULL CGI URL: http:\/\/wiki.example.com\/wiki.cgi/,
"full_cgi_url OK when trailing '/' missed off script_url" );
# Test that TT vars are picked up from user cookie prefs.
$cookie = OpenGuides::CGI->make_prefs_cookie(
config => $config,
omit_formatting_link => 1,
);
$ENV{HTTP_COOKIE} = $cookie;
$output = OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "105_test.tt"
);
like( $output, qr/FORMATTING RULES LINK: /,
"formatting_rules_link TT var blank as set in cookie" );
# Test that explicitly supplied vars override vars in cookie.
$output = OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "105_test.tt",
vars => { omit_formatting_link => "fish" },
);
like( $output, qr/OMIT FORMATTING LINK: fish/,
"explicitly supplied TT vars override cookie ones" );
# Test that enable_page_deletion is set correctly in various circumstances.
$config = OpenGuides::Config->new(
vars => {
template_path => cwd . "/t/templates",
site_name => "Test Site",
script_url => "/",
script_name => "",
},
);
$output = OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "105_test.tt",
);
like( $output, qr/ENABLE PAGE DELETION: 0/,
"enable_page_deletion var set correctly when not specified in conf" );
$config->enable_page_deletion( "n" );
$output = OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "105_test.tt",
);
like( $output, qr/ENABLE PAGE DELETION: 0/,
"enable_page_deletion var set correctly when set to 'n' in conf" );
$config->enable_page_deletion( "y" );
$output = OpenGuides::Template->output(
wiki => $wiki,
config => $config,
template => "105_test.tt",
);
like( $output, qr/ENABLE PAGE DELETION: 1/,
"enable_page_deletion var set correctly when set to 'y' in conf" );
$config->enable_page_deletion( 0 );
$output = OpenGuides::Template->output(
( run in 0.615 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )