From 2ef0dad0537df28c8db300581afb9840e802674f Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Wed, 30 Dec 2015 05:02:39 -0800 Subject: [PATCH] findDonor: initial set of unit tests. These tests spec out what findDonor() should do. --- Supporters/t/Supporters.t | 42 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/Supporters/t/Supporters.t b/Supporters/t/Supporters.t index d4cd390..08ed631 100644 --- a/Supporters/t/Supporters.t +++ b/Supporters/t/Supporters.t @@ -5,7 +5,7 @@ use strict; use warnings; -use Test::More tests => 160; +use Test::More tests => 173; use Test::Exception; use Scalar::Util qw(looks_like_number reftype); @@ -482,6 +482,46 @@ is($ret, 'drapper@example.org', "getPreferredEmailAddress: ....and returns the c =back +=item findDonor + +=cut + +my $lookupDonorId; + +dies_ok { $lookupDonorId = $sp->findDonor({}); } + "findDonor: no search criteria dies"; + +lives_ok { $lookupDonorId = $sp->findDonor({ledgerEntityId => "NotFound" }); } + "findDonor: 1 lookup of known missing succeeds ..."; + +is($lookupDonorId, undef, "findDonor: ... but finds nothing."); + +lives_ok { $lookupDonorId = $sp->findDonor({emailAddress => "nothingthere" }); } + "findDonor: 2 lookup of known missing succeeds ..."; + +is($lookupDonorId, undef, "findDonor: ... but finds nothing."); + +lives_ok { $lookupDonorId = $sp->findDonor({emailAddress => 'drapper@example.org', ledgerEntityId => "NOTFOUND" }); } + "findDonor: 1 and'ed criteria succeeds ..."; + +is($lookupDonorId, undef, "findDonor: ... but finds nothing."); + +lives_ok { $lookupDonorId = $sp->findDonor({emailAddress => 'NOTFOUND', ledgerEntityId => "Whitman-Dick" }); } + "findDonor: 2 and'ed criteria succeeds ..."; + +is($lookupDonorId, undef, "findDonor: ... but finds nothing."); + +lives_ok { $lookupDonorId = $sp->findDonor({emailAddress => 'drapper@example.org', ledgerEntityId => "Whitman-Dick" }); } + "findDonor: 1 valid multiple criteria succeeds ..."; + +is($lookupDonorId, $drapperId, "findDonor: ... and finds right entry."); + + lives_ok { $lookupDonorId = $sp->findDonor({emailAddress => 'drapper@example.com', ledgerEntityId => "Whitman-Dick" }); } + "findDonor: 1 valid multiple criteria succeeds ..."; + +is($lookupDonorId, $drapperId, "findDonor: ... and finds right entry."); + + =item Internal methods used only by the module itself. =over