Begin work on addEmailAddress method.
Basic stub and a few tests.
This commit is contained in:
parent
2c14c20db9
commit
ba6843e21e
2 changed files with 41 additions and 1 deletions
Supporters
|
@ -102,9 +102,44 @@ sub addSupporter ($$) {
|
||||||
$sth->execute($sp->{ledger_entity_id}, $sp->{display_name}, $sp->{public_ack});
|
$sth->execute($sp->{ledger_entity_id}, $sp->{display_name}, $sp->{public_ack});
|
||||||
my $id = $this->dbh->last_insert_id("","","","");
|
my $id = $this->dbh->last_insert_id("","","","");
|
||||||
$sth->finish();
|
$sth->finish();
|
||||||
|
|
||||||
|
$this->addEmailAddress($id, $sp->{email_address}, $sp->{email_address_type})
|
||||||
|
if defined $sp->{email_address};
|
||||||
|
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
######################################################################
|
||||||
|
|
||||||
|
=begin addEmailAddress
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
=over
|
||||||
|
|
||||||
|
=item $id
|
||||||
|
|
||||||
|
Valid supporter id number currently in the database. die() will occur if
|
||||||
|
the id number is not in the database already as a supporter id.
|
||||||
|
|
||||||
|
=item $emailAddress
|
||||||
|
|
||||||
|
Scalar string that contains an email address. die() will occur if the
|
||||||
|
email address isn't properly formatted.
|
||||||
|
|
||||||
|
=item $emailAddressType
|
||||||
|
|
||||||
|
Scalar string that contains the email address type. This type will be
|
||||||
|
created in the database if it does not already exist, so be careful.
|
||||||
|
|
||||||
|
=back
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub addEmailAddress($$$$) {
|
||||||
|
my($self, $id, $emailAddress, $emailAddressType) = @_;
|
||||||
|
|
||||||
|
die "addEmailAddress: invalid id, $id" unless $self->_verifyId($id);
|
||||||
|
}
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
=head1 Non-Public Methods
|
=head1 Non-Public Methods
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
|
|
||||||
use Test::More tests => 13;
|
use Test::More tests => 15;
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
|
|
||||||
use Scalar::Util qw(looks_like_number);
|
use Scalar::Util qw(looks_like_number);
|
||||||
|
@ -74,6 +74,11 @@ dies_ok { $sp->_verifyId("String") } "_verifyId: dies for non-numeric id";
|
||||||
# This is a hacky way to test this; but should work
|
# This is a hacky way to test this; but should work
|
||||||
ok(not ($sp->_verifyId($id2 + 10)), "_verifyId: non-existent id is not found");
|
ok(not ($sp->_verifyId($id2 + 10)), "_verifyId: non-existent id is not found");
|
||||||
|
|
||||||
|
dies_ok { $sp->_addEmailAdress(undef, 'drapper@example.org', 'paypal'); }
|
||||||
|
"_addEmailAdress: dies for undefined id";
|
||||||
|
dies_ok { $sp->_addEmailAdress("String", 'drapper@example.org', 'paypal'); }
|
||||||
|
"_addEmailAdress: dies for non-numeric id";
|
||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
|
||||||
=back
|
=back
|
||||||
|
|
Loading…
Add table
Reference in a new issue