From b1436e037ef7bcd67006f39c6967a6b13ce3d0d9 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 9 Dec 2015 19:56:22 -0800 Subject: [PATCH] addEmailAddress: call addAddressType underneath address_type is added automatically from the addEmailAddress call. Since addAddressType does a lookup first, this should not cause duplicates. --- Supporters/lib/Supporters.pm | 3 +++ Supporters/t/Supporters.t | 9 ++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index dfcd7c5..7e2f33e 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -174,6 +174,9 @@ sub addEmailAddress($$$$) { my($self, $id, $emailAddress, $emailAddressType) = @_; die "addEmailAddress: invalid id, $id" unless $self->_verifyId($id); + + my $addressTypeId = $self->addAddressType($emailAddressType); + } ###################################################################### diff --git a/Supporters/t/Supporters.t b/Supporters/t/Supporters.t index 1733f04..00e8801 100644 --- a/Supporters/t/Supporters.t +++ b/Supporters/t/Supporters.t @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 15; +use Test::More tests => 21; use Test::Exception; 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'); } "addEmailAddress: dies for non-numeric id"; +ok($sp->addEmailAddress($drapperId, 'drapper@example.org', 'work'), + "addEmailAddress: simple add test"); =item addAddressType =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"; my $paypalPayerAddressType;