| 1 | use strict; |
|---|
| 2 | use Wiki::Toolkit::Formatter::UseMod; |
|---|
| 3 | use OpenGuides::Template; |
|---|
| 4 | use OpenGuides::Test; |
|---|
| 5 | use Test::MockObject; |
|---|
| 6 | use Test::More tests => 3; |
|---|
| 7 | |
|---|
| 8 | my $config = OpenGuides::Test->make_basic_config; |
|---|
| 9 | $config->site_name( "Test Site" ); |
|---|
| 10 | $config->script_url( "/" ); |
|---|
| 11 | |
|---|
| 12 | # White box testing - we know that OpenGuides::Template only actually uses |
|---|
| 13 | # the node_name_to_node_param method of the formatter component of the wiki |
|---|
| 14 | # object passed in, and I CBA to faff about with picking out the test DB |
|---|
| 15 | # info to make a proper wiki object here. |
|---|
| 16 | my $fake_wiki = Test::MockObject->new; |
|---|
| 17 | $fake_wiki->mock("formatter", |
|---|
| 18 | sub { return Wiki::Toolkit::Formatter::UseMod->new( munge_urls => 1 ); } ); |
|---|
| 19 | |
|---|
| 20 | my $output = OpenGuides::Template->output( |
|---|
| 21 | wiki => $fake_wiki, |
|---|
| 22 | config => $config, |
|---|
| 23 | template => "node.tt", |
|---|
| 24 | ); |
|---|
| 25 | unlike( $output, qr/action=delete/, |
|---|
| 26 | "doesn't offer page deletion link by default" ); |
|---|
| 27 | $config->enable_page_deletion( "y" ); |
|---|
| 28 | $output = OpenGuides::Template->output( |
|---|
| 29 | wiki => $fake_wiki, |
|---|
| 30 | config => $config, |
|---|
| 31 | template => "node.tt", |
|---|
| 32 | ); |
|---|
| 33 | like( $output, qr/action=delete/, |
|---|
| 34 | "...but does when enable_page_deletion is set to 'y'" ); |
|---|
| 35 | $config->enable_page_deletion( 1 ); |
|---|
| 36 | $output = OpenGuides::Template->output( |
|---|
| 37 | wiki => $fake_wiki, |
|---|
| 38 | config => $config, |
|---|
| 39 | template => "node.tt", |
|---|
| 40 | ); |
|---|
| 41 | like( $output, qr/action=delete/, |
|---|
| 42 | "...and when enable_page_deletion is set to '1'" ); |
|---|