From ec7e50e8e03ffacbba4804bdb7ec4d46e2c5013a Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 30 Dec 2015 16:51:04 -0800 Subject: [PATCH] getPublicAck: initial tests spec out API. --- Supporters/lib/Supporters.pm | 26 +++++++++++++++++++++- Supporters/t/Supporters.t | 43 +++++++++++++++++++++++++++++++++++- 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 16b18ca..442c509 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -377,7 +377,6 @@ sub getPreferredEmailAddress($$) { return $emailAddress; } } - ###################################################################### =begin getLedgerEntityId @@ -420,6 +419,31 @@ sub getLedgerEntityId($$) { } ###################################################################### +=begin getPublicAck + +Arguments: + +=over + +=item $donorId + + Valid donor id number currently in the database. die() will occur if + the id number is not in the database already as a donor id. + +=back + +Returns the a boolean indicating whether or not the donor seeks to be +publicly acknowledged. undef can be returned if the donor has not specified, +so callers must check for undef. + +=cut + +sub getPublicAck($$) { + my($self, $donorId) = @_; + +} +###################################################################### + =begin addPostalAddress Arguments: diff --git a/Supporters/t/Supporters.t b/Supporters/t/Supporters.t index d048fb8..b61d331 100644 --- a/Supporters/t/Supporters.t +++ b/Supporters/t/Supporters.t @@ -8,7 +8,7 @@ use strict; use warnings; -use Test::More tests => 205; +use Test::More tests => 215; use Test::Exception; use Sub::Override; use File::Temp qw/tempfile/; @@ -136,6 +136,47 @@ ok((defined $val and defined $val->{$olsonId}{email_address_id} and $val->{$olso my $olsonFirstEmailId = $val->{$olsonId}{email_address_id}; +my $sterlingId; +lives_ok { $sterlingId = $sp->addSupporter({ display_name => "Roger Sterling", + ledger_entity_id => "Sterling-Roger", + email_address => 'sterlingjr@example.com', + email_address_type => 'home' }) } + "addSupporter: succeeds with no public_ack setting specified..."; + +ok( (looks_like_number($sterlingId) and $sterlingId > $olsonId), + "addSupporter: ... and return value is sane."); + +=item getPublicAck + +=cut + +dies_ok { my $ledgerId = $sp->getPublicAck(0); } + "getPublicAck: fails when rows are not returned but _verifyId() somehow passed"; + +# Replace _verifyId() to always return true + +$overrideSub = Sub::Override->new( 'Supporters::_verifyId' => sub ($$) { return 1;} ); +dies_ok { my $ledgerId = $sp->getPublicAck(0); } + "getPublicAck: fails when rows are not returned but _verifyId() somehow passed"; +$overrideSub->restore; + +my $publicAckVal; +lives_ok { $publicAckVal = $sp->getPublicAck($olsonId); } + "getPublicAck: lives when valid id is given for someone who does not want it..."; + +is($publicAckVal, 0, "getPublicAck: ...and return value is correct."); + +lives_ok { $publicAckVal = $sp->getPublicAck($drapperId); } + "getPublicAck: lives when valid id is given for someone who wants it..."; + +is($publicAckVal, 1, "getPublicAck: ...and return value is correct."); + +lives_ok { $publicAckVal = $sp->getPublicAck($sterlingId); } + "getPublicAck: lives when valid id is given for someone who is undecided..."; + +is($publicAckVal, undef, "getPublicAck: ...and return value is correct."); + + =item getLedgerEntityId =cut