aboutsummaryrefslogtreecommitdiffstats
path: root/perllib/t/Page.t
diff options
context:
space:
mode:
Diffstat (limited to 'perllib/t/Page.t')
-rwxr-xr-xperllib/t/Page.t49
1 files changed, 43 insertions, 6 deletions
diff --git a/perllib/t/Page.t b/perllib/t/Page.t
index fc01697ed..2890dda1e 100755
--- a/perllib/t/Page.t
+++ b/perllib/t/Page.t
@@ -6,16 +6,53 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Page.t,v 1.1 2009-08-25 10:28:50 louise Exp $
+# $Id: Page.t,v 1.2 2009-08-26 16:52:14 louise Exp $
#
use strict;
use warnings;
-
-use Test::More tests => 1;
+use Test::More tests => 4;
+use Test::Exception;
use FindBin;
-use lib "$FindBin::Bin/..";
-use lib "$FindBin::Bin/../../../perllib";
+use lib "$FindBin::Bin";
+use lib "$FindBin::Bin/../perllib";
+use lib "$FindBin::Bin/../../perllib";
+
+use Page;
+use MockQuery;
+use mySociety::Locale;
+
+sub mock_query(){
+ my $q = new MockQuery('mysite');
+ return $q;
+}
+
+sub test_header(){
+ my $q = mock_query();
+ my $html;
+ my %params = (title => 'test title');
+ mySociety::Locale::negotiate_language('en-gb,English,en_GB');
+ mySociety::Locale::gettext_domain('FixMyStreet');
+ mySociety::Locale::change();
+
+ # Test that param that isn't explicitly allowed raises error
+ $params{'test-param'} = 'test';
+ throws_ok { Page::header($q, %params); } qr/bad parameter/, 'bad parameter caught ok';
+ delete $params{'test-param'};
+
+ # Test that template passed is rendered
+ $params{'template'} = 'test';
+ $html = Page::template_header('My test title', 'test', $q, 'en-gb', '/../t/templates/');
+ like ($html, qr/My test header template/, 'named template rendered ok');
+
+
+ return 1;
+}
+
+sub test_footer(){
+ return 1;
+}
-BEGIN { use_ok('Page'); } \ No newline at end of file
+ok(test_footer() == 1, 'Ran all tests for the footer function');
+ok(test_header() == 1, 'Ran all tests for the header function');