Commit graph

145 commits

Author SHA1 Message Date
Bradley M. Kuhn
59d824e6b8 isSupporter: tests, implementation & docs. 2015-12-30 17:19:10 -08:00
Bradley M. Kuhn
21080cc4d5 getDisplayName: tests, implementation, and docs. 2015-12-30 17:12:58 -08:00
Bradley M. Kuhn
c9c85bb540 Correct auto-0 public_ack.
Actually, public_ack can be NULL and that's ok.  It indicates that the
donor has not answered the question yet.
2015-12-30 17:04:00 -08:00
Bradley M. Kuhn
990fa89f1d _getDonorField: generalize code for donor fields
This method can be used for a one-liner for any field in the donor
table.

Used it to implement getLedgerEntityId and getPublicAck.
2015-12-30 17:03:07 -08:00
Bradley M. Kuhn
a07235f74d Declare variable in the right place. 2015-12-30 17:02:50 -08:00
Bradley M. Kuhn
ec7e50e8e0 getPublicAck: initial tests spec out API. 2015-12-30 16:51:04 -08:00
Bradley M. Kuhn
aba9894180 Add module to list. 2015-12-30 16:33:23 -08:00
Bradley M. Kuhn
a8dbc5ad76 lastGave(): initial tests to define API 2015-12-30 16:33:03 -08:00
Bradley M. Kuhn
195732b6b0 confess is better here than die.
Maybe I should use it throughout?
2015-12-30 16:09:59 -08:00
Bradley M. Kuhn
724cb77605 new: additional arguments related to ledger.
I'll need a full command line here, as it turns out, and also regular
expressions to use for searching for monthly vs. annual donations.
2015-12-30 12:08:33 -08:00
Bradley M. Kuhn
2e14c340ec getLedgerEntityId: Initial implementation.
All tests now pass:

ok 15 - getLedgerEntityId: fails when rows are not returned but _verifyId() somehow passed
ok 16 - getLedgerEntityId: fails when rows are not returned but _verifyId() somehow passed
ok 17 - getLedgerEntityId: lives when valid id is given...
ok 18 - getLedgerEntityId: ...and return value is correct.
2015-12-30 11:31:36 -08:00
Bradley M. Kuhn
0ca9d394e2 getLedgerEntityId: tests showing basic API & docs
These tests show the basic API for the getLedgerEntityId() method.

Documentation for the method also included.
2015-12-30 11:31:09 -08:00
Bradley M. Kuhn
2e9938738f Add license notice at top of these files. 2015-12-30 11:09:47 -08:00
Bradley M. Kuhn
4cd05c9508 Remove blank line. 2015-12-30 06:10:12 -08:00
Bradley M. Kuhn
cb38348048 findDonor: initial implementation.
This seems to work and all existing tests for it pass:

ok 134 - findDonor: no search criteria dies
ok 135 - findDonor: 1 lookup of known missing succeeds ...
ok 136 - findDonor: ... but finds nothing.
ok 137 - findDonor: 2 lookup of known missing succeeds ...
ok 138 - findDonor: ... but finds nothing.
ok 139 - findDonor: 1 and'ed criteria succeeds   ...
ok 140 - findDonor: ... but finds nothing.
ok 141 - findDonor: 2 and'ed criteria succeeds   ...
ok 142 - findDonor: ... but finds nothing.
ok 143 - findDonor: 1 valid multiple criteria succeeds   ...
ok 144 - findDonor: ... and finds right entry.
ok 145 - findDonor: 2 valid multiple criteria succeeds   ...
ok 146 - findDonor: ... and finds right entry.
ok 147 - findDonor: 3 valid multiple criteria succeeds   ...
ok 148 - findDonor: ... and finds right entry.
ok 149 - findDonor: single criteria find expecting multiple records succeeds...
ok 150 - findDonor: ... and finds the right entires.
2015-12-30 06:09:43 -08:00
Bradley M. Kuhn
7e6e96d95f findDonor: API change: return multiple entries
Since the emailAddress criterion could find more than one entry, this
change has findDonor returning a list rather than a scalar integer and
thus finding multiple items are ok.

Tests are more extensive now that this API change is in effect.
2015-12-30 06:08:39 -08:00
Bradley M. Kuhn
501355b839 addEmailAddress: redundant add w/ same address.
This should succeed as the previous tests show.  They now pass:

ok 21 - addEmailAddress: fails adding existing email address with mismatched type.
ok 22 - addEmailAddress: succeeds when adding email that already exists...
ok 23 - addEmailAddress: ... and returns same id.
2015-12-30 06:00:42 -08:00
Bradley M. Kuhn
e10f8ed61a 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.
2015-12-30 06:00:10 -08:00
Bradley M. Kuhn
6d1825240a addEmailAddress: permit shared email addresses.
An existing email address can exist already.  If it does, just map it to
the new donor_id as well.
2015-12-30 05:49:12 -08:00
Bradley M. Kuhn
736f022005 _lookupEmailAddress: replace _lookupEmailAddressId
Actually, I will ultimately need the whole record for my purposes, so
rework this function to return everything.
2015-12-30 05:41:10 -08:00
Bradley M. Kuhn
4d2fc22de1 _lookupEmailAddressId: implement helper function
This helper function will be needed for a few changes I'm about to make.
2015-12-30 05:33:05 -08:00
Bradley M. Kuhn
2ef0dad053 findDonor: initial set of unit tests.
These tests spec out what findDonor() should do.
2015-12-30 05:02:39 -08:00
Bradley M. Kuhn
9c8db6b84f fulfillRequest: allow requestTypeId per getRequest
getRequest() now allows requestTypeId, so fulfillRequest() can as well.
Add tests for that, and don't die if requestType isn't given.
2015-12-30 04:12:21 -08:00
Bradley M. Kuhn
d6ce8225d9 getRequest: test documentation better detailed
Add a bit more detail in the test description to note we're using
requestType, not requestTypeId parameter in this test.
2015-12-30 04:05:21 -08:00
Bradley M. Kuhn
5b8453d9ae getRequest: Modify test to support requestTypeId
Now that requestTypeId parameter is valid, one of these tests should use
it.
2015-12-30 04:04:48 -08:00
Bradley M. Kuhn
1760f60759 getRequest: re-implement to take hash argument
Instead of a bunch of serial arguments, reimplement getRequest() to take
a hash of parameters.

In the process, add support for requestTypeId to be included.
2015-12-30 04:04:37 -08:00
Bradley M. Kuhn
e4dcfd11d5 _verifyRequestTypeId =>_lookupRequestTypeById
I found need to have _verifyRequestTypeId() actually return the
request_type in a reimplementation of getRequest() that I'm working on,
so I've made this change.
2015-12-30 03:57:19 -08:00
Bradley M. Kuhn
10030b3488 _verifyRequestTypeId =>_lookupRequestTypeById
I found need to have _verifyRequestTypeId() actually return the
request_type in a reimplementation of getRequest() that I'm working on,
so I've made this change.  Some tests are failing because of the use of
_verifyRequestTypeId().  Next commit will address that.
2015-12-30 03:55:28 -08:00
Bradley M. Kuhn
b03a469338 Simplify code: use helper function that does same
This code was roughly duplicate of what _verifyRequestTypeId() was
already doing.
2015-12-30 03:33:36 -08:00
Bradley M. Kuhn
9de60c3c5e Use donorId rather than supporterId as main handle
Since we converted to making this a more general donor database, change
the handle used for an individual in the database from supporterId to
donorId.

Note that I left addSupporter() method name untouched because it does
automatically assume you mean a supporter, not a mere donor.  Later, an
addDonor() method should likely be added.
2015-12-30 03:13:41 -08:00
Bradley M. Kuhn
95ef1fce28 Change table to donor; add is_supporter field.
Up until now, this software has been focused on just Supporters, but
really there is no reason this should not be a general donor database.
Therefore, don't use the name supporter in the database, and add a
field.

public_ack is now allowed to be NULL, because the idea being we don't
have an answer from all who donate whether or not they want public
acknowledgment.

the is_supporter boolean is added to record whether or not they came
through the supporter program.
2015-12-30 03:10:07 -08:00
Bradley M. Kuhn
f74c5d1854 DESTROY: detect _beginWork/_commit mismatches.
The best place to detect these mismatches is in DESTROY.  An error
should be given when they are mismatched and we DESTROY the object.
That's now done.
2015-12-20 18:52:08 -08:00
Bradley M. Kuhn
096561a5c4 _rollback() work if failure occurs in these calls.
This is the location where there was unbalanced _beginWork()/_commit()
calls.  In future, when writing tests, it's probably good to check this
often in the tests.
2015-12-20 18:51:53 -08:00
Bradley M. Kuhn
794d34a79f Test begin work/commit nesting in a few places.
I discovered a bug where _beginWork() and _commit() calls were not
properly matched.  These tests are added to find them.
2015-12-20 18:51:46 -08:00
Bradley M. Kuhn
5a37adc626 getPreferredEmailAddress: initial implementation. 2015-12-20 18:22:15 -08:00
Bradley M. Kuhn
2e39065c3e setPreferredEmailAddress: initial implementation
These tests now pass:

ok 106 - setPreferredEmailAddress: dies for undefined id
ok 107 - setPreferredEmailAddress: dies for non-numeric id
ok 108 - setPreferredEmailAddress: email address undefined fails
ok 109 - setPreferredEmailAddress: email address with extra @ fails to add.
ok 112 - setPreferredEmailAddress: email address not found in database does not die....
ok 113 - setPreferredEmailAddress: ....but returns undef
ok 116 - setPreferredEmailAddress: setting preferred email address succeeds....
ok 117 - setPreferredEmailAddress: ... and returns correct email_address_id on success
2015-12-20 18:10:56 -08:00
Bradley M. Kuhn
69a5ffdbf6 get/setPreferredEmailAddress: initial tests. 2015-12-20 17:57:30 -08:00
Bradley M. Kuhn
f1b8406e61 Add missing =back in documentation. 2015-12-20 17:11:01 -08:00
Bradley M. Kuhn
2dafc3c544 Correct test; it used incorrect variable 2015-12-20 17:10:18 -08:00
Bradley M. Kuhn
cb1ce38650 fulfillRequest: test had incorrect return value.
fulfillRequest() returns the id, not a hash of values.
2015-12-20 17:07:44 -08:00
Bradley M. Kuhn
3ff735584c This test did not belong here.
I believe this was due to a bad cut-and-paste in a previous commit.
2015-12-20 17:05:20 -08:00
Bradley M. Kuhn
f29a243db3 Extract $requestId from getRequest() return.
of course, getRequest() returns  a hash so we must properly extract the
value we want.

This fix causes this test to now pass:

ok 73 - fulfillRequest: databse entry from successful return is correct
2015-12-20 17:02:44 -08:00
Bradley M. Kuhn
6307cfdd26 Fix typos in the test message descriptions. 2015-12-20 16:59:29 -08:00
Bradley M. Kuhn
ef7a4ecc49 Add blank line. 2015-12-20 16:58:42 -08:00
Bradley M. Kuhn
3b3ee21288 Fix typos in SQL and return value.
This causes the basic add test to finally pass:

ok 70 - fulfillRequest: succeeds for existing request
2015-12-20 16:58:13 -08:00
Bradley M. Kuhn
a1f00e68a0 confess() rather than die() here.
We  really want to know the context of what happened when it dies here.
2015-12-20 16:55:15 -08:00
Bradley M. Kuhn
6de0eb64a2 Remove uncontrolled debugging statements.
Yes, I should add a debug mode.  But I'm not going to.
2015-12-20 16:43:16 -08:00
Bradley M. Kuhn
89149fe043 getRequest: Initial implementation.
This implementation of getRequest passes all the current tests, except
for those relate to fulfillment.
2015-12-20 16:40:27 -08:00
Bradley M. Kuhn
4f42fe50d2 Test have today in UTC
It seems that date('now'), at least in sqlite, is in UTC.  So, we want
the tests to match that.

There are still timing bugs possible here, but with this change, they
should only occur if you run the test right at 23:58 or 23:59 UTC. :)
2015-12-20 16:39:00 -08:00
Bradley M. Kuhn
c8bbcc05e4 Parameter here is "notes", not "note" 2015-12-20 15:15:39 -08:00