From 43da2c622a6b95e39b197c93fc1456961ea74369 Mon Sep 17 00:00:00 2001 From: louise Date: Tue, 13 Oct 2009 09:25:56 +0000 Subject: Add some functions for figuring out if a user has accepted new T&Cs --- t/Problems.t | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 t/Problems.t (limited to 't') diff --git a/t/Problems.t b/t/Problems.t new file mode 100755 index 000000000..8a5c828e3 --- /dev/null +++ b/t/Problems.t @@ -0,0 +1,50 @@ +#!/usr/bin/perl -w +# +# Problem.t: +# Tests for the Problem functions +# +# Copyright (c) 2009 UK Citizens Online Democracy. All rights reserved. +# Email: louise@mysociety.org; WWW: http://www.mysociety.org/ +# +# $Id: Problems.t,v 1.1 2009-10-13 09:25:56 louise Exp $ +# + +use strict; +use warnings; +use Test::More tests => 6; +use Test::Exception; + +use FindBin; +use lib "$FindBin::Bin"; +use lib "$FindBin::Bin/../perllib"; +use lib "$FindBin::Bin/../../perllib"; + +use Problems; + +sub test_update_user_notified_data_sharing() { + + my $update = {created => 1256947200}; + my $notification_start = 1256947201; + my $accepted = Problems::update_user_notified_data_sharing($update, $notification_start); + ok($accepted == 0, 'update_user_notified_data_sharing returns false for an update created before the notification started to be displayed'); + $notification_start = 1256947199; + $accepted = Problems::update_user_notified_data_sharing($update, $notification_start); + ok($accepted == 1, 'update_user_notified_data_sharing returns true for a problem created after the notification started to be displayed'); + return 1; +} + +sub test_user_notified_data_sharing() { + + my $problem = {time => 1256947200}; + my $notification_start = 1256947201; + my $accepted = Problems::user_notified_data_sharing($problem, $notification_start); + ok($accepted == 0, 'user_notified_data_sharing returns false for a problem created before the notification started to be displayed'); + $notification_start = 1256947199; + $accepted = Problems::user_notified_data_sharing($problem, $notification_start); + ok($accepted == 1, 'user_notified_data_sharing returns true for a problem created after the notification started to be displayed'); + return 1; +} + +ok(test_user_notified_data_sharing() == 1, 'Ran all tests for user_notified_data_sharing '); +ok(test_update_user_notified_data_sharing() == 1, 'Ran all tests for update_user_notified_data_sharing'); + -- cgit v1.2.3