addEmailAddress: call addAddressType underneath

address_type is added automatically from the addEmailAddress call.
Since addAddressType does a lookup first, this should not cause
duplicates.
This commit is contained in:
Bradley M. Kuhn 2015-12-09 19:56:22 -08:00
parent 63383eef02
commit b1436e037e
2 changed files with 11 additions and 1 deletions

View file

@ -174,6 +174,9 @@ sub addEmailAddress($$$$) {
my($self, $id, $emailAddress, $emailAddressType) = @_; my($self, $id, $emailAddress, $emailAddressType) = @_;
die "addEmailAddress: invalid id, $id" unless $self->_verifyId($id); die "addEmailAddress: invalid id, $id" unless $self->_verifyId($id);
my $addressTypeId = $self->addAddressType($emailAddressType);
} }
###################################################################### ######################################################################

View file

@ -5,7 +5,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 15; use Test::More tests => 21;
use Test::Exception; use Test::Exception;
use Scalar::Util qw(looks_like_number); use Scalar::Util qw(looks_like_number);
@ -79,11 +79,18 @@ dies_ok { $sp->addEmailAddress(undef, 'drapper@example.org', 'paypal'); }
dies_ok { $sp->addEmailAddress("String", 'drapper@example.org', 'paypal'); } dies_ok { $sp->addEmailAddress("String", 'drapper@example.org', 'paypal'); }
"addEmailAddress: dies for non-numeric id"; "addEmailAddress: dies for non-numeric id";
ok($sp->addEmailAddress($drapperId, 'drapper@example.org', 'work'),
"addEmailAddress: simple add test");
=item addAddressType =item addAddressType
=cut =cut
# This test cheats a bit -- it assumes that the database is assigning serials starting with 1
ok($sp->addAddressType('work') == 1,
"addEmailAddress: verify addEmailAddress added the addressType underneath");
dies_ok { $sp->addAddressType(undef); } "addAddressType: dies for undef"; dies_ok { $sp->addAddressType(undef); } "addAddressType: dies for undef";
my $paypalPayerAddressType; my $paypalPayerAddressType;