getDisplayName: tests, implementation, and docs.
This commit is contained in:
parent
c9c85bb540
commit
21080cc4d5
2 changed files with 59 additions and 5 deletions
|
@ -445,6 +445,29 @@ sub getPublicAck($$$) {
|
||||||
}
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
=begin getDisplayName
|
||||||
|
|
||||||
|
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 string of the display name for the donor. undef can be returned
|
||||||
|
if the donor has not specified, so callers must check for undef.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub getDisplayName($$$) {
|
||||||
|
return $_[0]->_getDonorField("display_name", $_[1]);
|
||||||
|
}
|
||||||
|
######################################################################
|
||||||
|
|
||||||
=begin addPostalAddress
|
=begin addPostalAddress
|
||||||
|
|
||||||
Arguments:
|
Arguments:
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More tests => 215;
|
use Test::More tests => 223;
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
use Sub::Override;
|
use Sub::Override;
|
||||||
use File::Temp qw/tempfile/;
|
use File::Temp qw/tempfile/;
|
||||||
|
@ -97,11 +97,11 @@ is_deeply($sp->ledgerCmd(), ["testcmd" ], "new: verify ledgerCmd set");
|
||||||
dies_ok { $sp->addSupporter({}) }
|
dies_ok { $sp->addSupporter({}) }
|
||||||
"addSupporter: ledger_entity_id required";
|
"addSupporter: ledger_entity_id required";
|
||||||
|
|
||||||
my $id1;
|
my $campbellId;
|
||||||
lives_ok { $id1 = $sp->addSupporter({ ledger_entity_id => "Campbell-Peter" }); }
|
lives_ok { $campbellId = $sp->addSupporter({ ledger_entity_id => "Campbell-Peter" }); }
|
||||||
"addSupporter: add works for minimal acceptable settings";
|
"addSupporter: add works for minimal acceptable settings";
|
||||||
|
|
||||||
ok( (looks_like_number($id1) and $id1 > 0),
|
ok( (looks_like_number($campbellId) and $campbellId > 0),
|
||||||
"addSupporter: add works for minimal acceptable settings");
|
"addSupporter: add works for minimal acceptable settings");
|
||||||
|
|
||||||
dies_ok { $sp->addSupporter({ public_ack => 1, ledger_entity_id => "Whitman-Dick" }) }
|
dies_ok { $sp->addSupporter({ public_ack => 1, ledger_entity_id => "Whitman-Dick" }) }
|
||||||
|
@ -112,7 +112,7 @@ lives_ok { $drapperId = $sp->addSupporter({ display_name => "Donald Drapper",
|
||||||
public_ack => 1, ledger_entity_id => "Whitman-Dick" }); }
|
public_ack => 1, ledger_entity_id => "Whitman-Dick" }); }
|
||||||
"addSupporter: public_ack set to true with a display_name given";
|
"addSupporter: public_ack set to true with a display_name given";
|
||||||
|
|
||||||
ok( (looks_like_number($drapperId) and $drapperId > $id1),
|
ok( (looks_like_number($drapperId) and $drapperId > $campbellId),
|
||||||
"addSupporter: add works with public_ack set to true and a display_name given");
|
"addSupporter: add works with public_ack set to true and a display_name given");
|
||||||
|
|
||||||
my $olsonId;
|
my $olsonId;
|
||||||
|
@ -176,6 +176,37 @@ lives_ok { $publicAckVal = $sp->getPublicAck($sterlingId); }
|
||||||
|
|
||||||
is($publicAckVal, undef, "getPublicAck: ...and return value is correct.");
|
is($publicAckVal, undef, "getPublicAck: ...and return value is correct.");
|
||||||
|
|
||||||
|
=item getDisplayName
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
my $displayNameVal;
|
||||||
|
|
||||||
|
dies_ok { $displayNameVal = $sp->getDisplayName(0); }
|
||||||
|
"getDisplayName: 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 { $displayNameVal = $sp->getDisplayName(0); }
|
||||||
|
"getDisplayName: fails when rows are not returned but _verifyId() somehow passed";
|
||||||
|
$overrideSub->restore;
|
||||||
|
|
||||||
|
lives_ok { $displayNameVal = $sp->getDisplayName($olsonId); }
|
||||||
|
"getDisplayName: lives when valid id is given for someone who does not want it...";
|
||||||
|
|
||||||
|
is($displayNameVal, "Peggy Olson", "getDisplayName: ...and return value is correct.");
|
||||||
|
|
||||||
|
lives_ok { $displayNameVal = $sp->getDisplayName($drapperId); }
|
||||||
|
"getDisplayName: lives when valid id is given for someone who wants it...";
|
||||||
|
|
||||||
|
is($displayNameVal, "Donald Drapper", "getDisplayName: ...and return value is correct.");
|
||||||
|
|
||||||
|
lives_ok { $displayNameVal = $sp->getDisplayName($campbellId); }
|
||||||
|
"getDisplayName: lives when valid id is given for someone who is undecided...";
|
||||||
|
|
||||||
|
is($displayNameVal, undef, "getDisplayName: ...and return value is correct.");
|
||||||
|
|
||||||
|
|
||||||
=item getLedgerEntityId
|
=item getLedgerEntityId
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue