source: trunk/t/41_deletion.t @ 309

Last change on this file since 309 was 309, checked in by kake, 18 years ago

Page deletion must now be explicitly enabled in wiki.conf. Added some deletion-related tests. Sorted out PREREQUISITES.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 1.4 KB
Line 
1use strict;
2use Test::More tests => 3;
3use Config::Tiny;
4use Cwd;
5use CGI::Wiki::Formatter::UseMod;
6use OpenGuides::Template;
7use Test::MockObject;
8
9my $config = Config::Tiny->new;
10$config->{_}->{template_path} = cwd . "/templates";
11$config->{_}->{site_name} = "Test Site";
12
13# White box testing - we know that OpenGuides::Template only actually uses
14# the node_name_to_node_param method of the formatter component of the wiki
15# object passed in, and I CBA to faff about with picking out the test DB
16# info to make a proper wiki object here.
17my $fake_wiki = Test::MockObject->new;
18$fake_wiki->mock("formatter",
19                 sub { return CGI::Wiki::Formatter::UseMod->new( munge_urls => 1 ); } );
20
21my $output = OpenGuides::Template->output(
22    wiki     => $fake_wiki,
23    config   => $config,
24    template => "node.tt",
25);
26unlike( $output, qr/action=delete/,
27        "doesn't offer page deletion link by default" );
28$config->{_}->{enable_page_deletion} = "y";
29$output = OpenGuides::Template->output(
30    wiki     => $fake_wiki,
31    config   => $config,
32    template => "node.tt",
33);
34like( $output, qr/action=delete/,
35      "...but does when enable_page_deletion is set to 'y'" );
36$config->{_}->{enable_page_deletion} = "1";
37$output = OpenGuides::Template->output(
38    wiki     => $fake_wiki,
39    config   => $config,
40    template => "node.tt",
41);
42like( $output, qr/action=delete/,
43      "...and when enable_page_deletion is set to '1'" );
Note: See TracBrowser for help on using the repository browser.