root/trunk/t/58_navbar_common_locales_categories.t

Revision 1091, 2.5 kB (checked in by dom, 19 months ago)

Add noheaders option, and use that in preference to black content_type
arg. (fixes #220)

Line 
1use strict;
2use OpenGuides;
3use OpenGuides::Test;
4use Test::More;
5use Wiki::Toolkit::Setup::SQLite;
6
7eval { require DBD::SQLite; };
8if ( $@ ) {
9    plan skip_all => "DBD::SQLite not installed - no database to test with";
10    exit 0;
11}
12
13eval { require Test::HTML::Content; };
14if ( $@ ) {
15    plan skip_all => "Test::HTML::Content not installed";
16    exit 0;
17}
18
19sub get_recent_changes {
20    my ($guide) = @_;
21
22    my $output = $guide->display_recent_changes( return_output => 1 );
23    $output =~ s/^Content-Type.*[\r\n]+//m;
24   
25    return $output;
26}
27
28sub get_preferences {
29    my ($guide) = @_;
30
31    return OpenGuides::Template->output(
32        wiki         => $guide->wiki,
33        config       => $guide->config,
34        template     => "preferences.tt",
35        noheaders    => 1,
36        vars         => {
37                          not_editable => 1,
38                          show_form    => 1
39                        },
40    );
41}
42
43my %pages = (
44    recent_changes => \&get_recent_changes,
45    preferences    => \&get_preferences,
46);
47
48plan tests => 4 * keys %pages;
49
50my ( $config, $guide, $wiki, $output );
51
52# Clear out the database from any previous runs.
53unlink "t/node.db";
54unlink <t/indexes/*>;
55Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
56
57while (my ($page, $get_content) = each %pages) {
58
59    # Make a guide with common categories and locales enabled.
60    $config = OpenGuides::Test->make_basic_config;
61    $config->enable_common_categories( 1 );
62    $config->enable_common_locales( 1 );
63    $guide = OpenGuides->new( config => $config );
64
65    # Make sure common categories and locales show up.
66    $output = $get_content->($guide);
67
68    Test::HTML::Content::tag_ok( $output, "div", { id => "navbar_categories" },
69                                 "common categories in $page navbar" );
70    Test::HTML::Content::tag_ok( $output, "div", { id => "navbar_locales" },
71                                 "...common locales too" );
72
73    # Now make a guide with common categories and locales disabled.
74    $config = OpenGuides::Test->make_basic_config;
75    $guide = OpenGuides->new( config => $config );
76
77    # Make sure common categories/locales are omitted.
78    $output = $get_content->($guide);
79
80    Test::HTML::Content::no_tag( $output, "div", { id => "navbar_categories" },
81                                 "common categories in $page navbar" );
82    Test::HTML::Content::no_tag( $output, "div", { id => "navbar_locales" },
83                                 "...common locales too" );
84}
Note: See TracBrowser for help on using the browser.