root/branches/new-install-process/t/48_google_analytics.t

Revision 967, 1.9 kB (checked in by kake, 22 months ago)

Add tests that I forgot to add to svn! (Thanks Bob.)

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
13plan tests => 5;
14
15my ( $config, $guide, $wiki, $cookie, $output );
16
17# Clear out the database from any previous runs.
18unlink "t/node.db";
19unlink <t/indexes/*>;
20Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
21
22# Make a guide.
23$config = OpenGuides::Test->make_basic_config;
24$guide = OpenGuides->new( config => $config );
25
26# Write a node.
27OpenGuides::Test->write_data(
28                              guide => $guide,
29                              node  => "Red Lion",
30                            );
31
32# Make sure analytics stuff only shows up if we want it to.
33$output = $guide->display_node(
34                                id => "Red Lion",
35                                return_output => 1,
36                              );
37unlike( $output, qr/urchinTracker/, "Google analytics omitted by default" );
38
39$config->google_analytics_key( "" );
40$output = $guide->display_node(
41                                id => "Red Lion",
42                                return_output => 1,
43                              );
44unlike( $output, qr/urchinTracker/, "...also if analytics key is blank" );
45
46$config->google_analytics_key( 0 );
47$output = $guide->display_node(
48                                id => "Red Lion",
49                                return_output => 1,
50                              );
51unlike( $output, qr/urchinTracker/, "...also if analytics key is zero" );
52
53$config->google_analytics_key( "ThisIsNotAKey" );
54$output = $guide->display_node(
55                                id => "Red Lion",
56                                return_output => 1,
57                              );
58like( $output, qr/urchinTracker/, "does show up if key is provided" );
59like( $output, qr/ThisIsNotAKey/, "...correct key" );
Note: See TracBrowser for help on using the browser.