aboutsummaryrefslogtreecommitdiffstats
path: root/t
diff options
context:
space:
mode:
authormatthew <matthew>2009-12-16 12:43:12 +0000
committermatthew <matthew>2009-12-16 12:43:12 +0000
commit009adcb0cf2e3d56df0daed103301248018a11f8 (patch)
treed6309a31c7dae8ec365048dc856affec3180b014 /t
parentb6acf6c339b2ea00258567acd5e93f88c6023777 (diff)
Add test for recent().
Diffstat (limited to 't')
-rwxr-xr-xt/Cobrand.t22
-rw-r--r--t/Cobrands/Mysite/Util.pm10
2 files changed, 29 insertions, 3 deletions
diff --git a/t/Cobrand.t b/t/Cobrand.t
index bfd867e7a..9821b4b1d 100755
--- a/t/Cobrand.t
+++ b/t/Cobrand.t
@@ -6,13 +6,14 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org; WWW: http://www.mysociety.org/
#
-# $Id: Cobrand.t,v 1.24 2009-12-15 17:32:21 louise Exp $
+# $Id: Cobrand.t,v 1.25 2009-12-16 12:43:12 matthew Exp $
#
use strict;
use warnings;
-use Test::More tests => 59;
+use Test::More tests => 62;
use Test::Exception;
+use Error qw(:try);
use FindBin;
use lib "$FindBin::Bin";
@@ -255,6 +256,22 @@ sub test_council_check {
is($check_result, 1, 'council_check returns 1 if there is no council_check function defined by the cobrand');
}
+sub test_recent {
+ my $cobrand = 'mysite';
+ my $check_result = Cobrand::recent($cobrand);
+ is_deeply($check_result, [ { id => 1, title => 'Title 1' }, { id => 2, title => 'Title 2' } ], 'recent returns output from cobrand module');
+
+ # Can't test default here as calls database. So test it throws a db not configured error :)
+ my $error;
+ $cobrand = 'nosite';
+ try {
+ $check_result = Cobrand::recent($cobrand);
+ } catch Error with {
+ $error = shift;
+ };
+ ok($error =~ /^configure not yet called in new_dbh/, 'Default throws a database error');
+}
+
ok(test_cobrand_handle() == 1, 'Ran all tests for the cobrand_handle function');
ok(test_site_restriction() == 1, 'Ran all tests for the site_restriction function');
ok(test_base_url() == 1, 'Ran all tests for the base url');
@@ -274,3 +291,4 @@ ok(test_show_watermark() == 1, 'Ran all tests for show_watermark');
ok(test_allow_photo_upload() == 1, 'Ran all tests for allow_photo_upload');
ok(test_allow_photo_display() == 1, 'Ran all tests for allow_photo_display');
ok(test_council_check() == 1, 'Ran all tests for council_check');
+ok(test_recent() == 1, 'Ran all tests for recent');
diff --git a/t/Cobrands/Mysite/Util.pm b/t/Cobrands/Mysite/Util.pm
index aadf1edd9..8aedd2c8c 100644
--- a/t/Cobrands/Mysite/Util.pm
+++ b/t/Cobrands/Mysite/Util.pm
@@ -7,7 +7,7 @@
# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved.
# Email: louise@mysociety.org. WWW: http://www.mysociety.org
#
-# $Id: Util.pm,v 1.19 2009-10-20 11:55:51 louise Exp $
+# $Id: Util.pm,v 1.20 2009-12-16 12:43:13 matthew Exp $
package Cobrands::Mysite::Util;
use Page;
@@ -102,4 +102,12 @@ sub allow_photo_display {
sub council_check {
return 0;
}
+
+sub recent {
+ return [
+ { id => 1, title => 'Title 1' },
+ { id => 2, title => 'Title 2' }
+ ];
+}
+
1;