1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
#!/usr/bin/perl -w
#
# Page.t:
# Tests for the Page functions
#
# 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-27 08:42:46 louise Exp $
#
use strict;
use warnings;
use Test::More tests => 4;
use Test::Exception;
use FindBin;
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;
}
ok(test_footer() == 1, 'Ran all tests for the footer function');
ok(test_header() == 1, 'Ran all tests for the header function');
|