getPublicAck: initial tests spec out API.

This commit is contained in:
Bradley M. Kuhn 2015-12-30 16:51:04 -08:00
parent aba9894180
commit ec7e50e8e0
2 changed files with 67 additions and 2 deletions

View file

@ -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:

View file

@ -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