diff --git a/Supporters/lib/Supporters.pm b/Supporters/lib/Supporters.pm index 7f3c924..e42e401 100644 --- a/Supporters/lib/Supporters.pm +++ b/Supporters/lib/Supporters.pm @@ -207,6 +207,39 @@ sub addEmailAddress($$$$) { } ###################################################################### +=begin addPostalAddress + +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 $formattedPostalAddress + + Scalar string that contains a multi-line, fully formatted, postal address. + +=item $addressType + + Scalar string that contains the address type. This type will be created in + the database if it does not already exist, so be careful. + +=back + +Returns the id value of the postal_address table entry. + +=cut + +sub addPostalAddress($$$$) { + my($self, $id, $formattedPostalAddress, $addressType) = @_; + + return undef; +} +###################################################################### + =begin getRequestType Arguments: diff --git a/Supporters/t/Supporters.t b/Supporters/t/Supporters.t index 6a86dd0..683fc78 100644 --- a/Supporters/t/Supporters.t +++ b/Supporters/t/Supporters.t @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 55; +use Test::More tests => 61; use Test::Exception; use Scalar::Util qw(looks_like_number reftype); @@ -144,6 +144,32 @@ ok($same = $sp->addAddressType("paypal payer"), "addAddressType: lookup works"); ok($same == $paypalPayerAddressType, "addAddressType: lookup returns same as the basic add"); +=item addPostalAddress + +=cut + +dies_ok { $sp->addPostalAddress(undef, "405 Madison Avenue\nNew York, NY 10000\nUSA", 'office'); } + "addPostalAddress: dies for undefined id"; +dies_ok { $sp->addPostalAddress("String", "405 Madison Avenue\nNew York, NY 10000\nUSA", 'office'); } + "addPostalAddress: dies for non-numeric id"; +dies_ok { $sp->addPostalAddress($drapperId, undef, 'work') } + "addPostalAddress: postal address undefined fails"; + +# Verify that the addressType wasn't added when the Email address is invalid +# and the address type did not already exist. + +$val = $sp->dbh()->selectall_hashref("SELECT id, name FROM address_type WHERE name = 'office'", 'name'); + +ok((not defined $val or not defined $val->{'name'}), + "addPostalAddress: type is not added when other input paramaters are invalid"); + +my $drapperPostalId; + +lives_ok { $drapperPostalId = $sp->addPostalAddress($drapperPostalId, + "405 Madison Avenue\nNew York, NY 10000\nUSA", 'office'); } + "addPostalAddress: addPostalAddress of a valid formatted_address works."; +ok((looks_like_number($drapperPostalId) and $drapperPostalId > 0), "addPostalAddress: id returned is sane."); + =item addRequestType/getRequestType =cut