From e10f8ed61ad5c4c71de2485afaa55a03bce9dc15 Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 30 Dec 2015 05:54:38 -0800 Subject: [PATCH] addEmailAddress: test for duplicate adds. These tests verify that duplicate adds do not try to add the same email address again. These tests currently fail. --- Supporters/t/Supporters.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Supporters/t/Supporters.t b/Supporters/t/Supporters.t index 54addc7..aedaf2e 100644 --- a/Supporters/t/Supporters.t +++ b/Supporters/t/Supporters.t @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 182; +use Test::More tests => 185; use Test::Exception; use Scalar::Util qw(looks_like_number reftype); @@ -100,6 +100,8 @@ my $val = $sp->dbh()->selectall_hashref("SELECT donor_id, email_address_id " . ok((defined $val and defined $val->{$olsonId}{email_address_id} and $val->{$olsonId}{email_address_id} > 0), "addSuporter: email address mapping is created on addSupporter() w/ email address included"); +my $olsonFirstEmailId = $val->{$olsonId}{email_address_id}; + =item addEmailAddress =cut @@ -128,6 +130,15 @@ $val = $sp->dbh()->selectall_hashref("SELECT id, name FROM address_type WHERE na ok((not defined $val or not defined $val->{'name'}), "addEmailAddress: type is not added with email address is bad"); +my $sameOlsonId; +dies_ok { $sameOlsonId = $sp->addEmailAddress($olsonId, 'olson@example.net', 'paypal') } + "addEmailAddress: fails adding existing email address with mismatched type."; + +lives_ok { $sameOlsonId = $sp->addEmailAddress($olsonId, 'olson@example.net', 'home') } + "addEmailAddress: succeeds when adding email that already exists..."; + +is($sameOlsonId, $olsonFirstEmailId, "addEmailAddress: ... and returns same id."); + my $drapperEmailId; lives_ok { $drapperEmailId = $sp->addEmailAddress($drapperId, 'drapper@example.org', 'work') }