function testCountRecurringDonationsPastYear() { // donation will have recurring_donation_KEY set // SELECT COUNT(*) FROM donation WHERE supporter_KEY=### AND RESULT=0 AND Transaction_Date= recurring_donation_KEY IS NOT NULL // data__recurring_donations_past_year $s = new Supporter(array('supporter_KEY' => 58)); $donations = array(array('supporter_KEY' => 58, 'donation_KEY' => 61, 'RESULT' => 0, 'recurring_donation_KEY' => 455, 'Transaction_Date' => date('Y-m-d H:i:s', strtotime('-7 months')), 'RESULT' => 0), array('supporter_KEY' => 58, 'donation_KEY' => 62, 'RESULT' => 0, 'recurring_donation_KEY' => 455, 'Transaction_Date' => date('Y-m-d H:i:s', strtotime('-13 months')), 'RESULT' => 0), array('supporter_KEY' => 58, 'donation_KEY' => 63, 'RESULT' => 1, 'recurring_donation_KEY' => 455), array('supporter_KEY' => 58, 'donation_KEY' => 64, 'RESULT' => 0), array('supporter_KEY' => 59, 'donation_KEY' => 65, 'RESULT' => 0, 'recurring_donation_KEY' => 455)); foreach ($donations as $donation_data) { $d = new Donation($donation_data); $d->db_insert(); } $s->updateDonationCounts(); $this->assertEqual($s->data['data__recurring_donations_past_year'], 1); }