function testEachConsumesFixture()
 {
     $this->expect_Curl_jsonRequest()->with('GET', 'https://test.hypercharge.net/v2/scheduler?page=1&per_page=7')->andReturn($this->response('scheduler_page_1.json'));
     $_this = $this;
     $uids = array();
     $cp = function ($scheduler) use($_this, &$uids) {
         $_this->assertEqual('DateRecurringSchedule', $scheduler->type);
         $uids[] = $scheduler->unique_id;
     };
     Scheduler::each(array('page' => 1, 'per_page' => 7), $cp);
     $this->assertEqual(array('0293069be5a868ae69290e8a0eff72b3', '0763d2761d004a86f24807594610900b', '22cd57da4a1c36652b6eb3e5b7587b03', 'd07061244f5a468271bf27486ccfcaa2', 'ff700580d3c19e1f1d8f6364c1c7d707', 'f3268a2e9ae4d389d92d4503c480c67d', 'c4e9afeddc0c7dd907433187ac86e1bd'), $uids);
 }
 function testTransactionsEach()
 {
     $counts = array('scheduler' => 0, 'transaction' => 0);
     $_this = $this;
     Scheduler::each(array('start_date_from' => '2013-06-27', 'start_date_to' => '2013-06-27'), function ($scheduler) use($_this, &$counts) {
         $counts['transaction'] = 0;
         $_this->assertIsA($scheduler, 'Hypercharge\\Scheduler');
         $_this->assertEqual(Scheduler::MONTHLY, $scheduler->interval);
         SchedulerTransactions::each($scheduler->unique_id, array(), function ($trx) use($_this, &$counts) {
             $i = $counts['transaction'];
             $_this->assertIsA($trx, 'Hypercharge\\Transaction');
             $_this->assertEqual(5000, $trx->amount);
             $_this->assertEqual('USD', $trx->currency);
             $_this->assertEqual('recurring_sale', $trx->transaction_type);
             // the 3 first transactions ...
             if ($i < 4) {
                 // ... are known to be approved
                 $_this->assertTrue($trx->isApproved());
                 // ... and occured once per month, until august 2013, youngest first.
                 $_this->assertPattern('/^2013-0' . (8 - $i) . '-27/', $trx->timestamp);
             }
             $counts['transaction']++;
         });
         $counts['scheduler']++;
         $_this->assertTrue($counts['transaction'] >= 3);
     });
     $this->assertEqual(9, $counts['scheduler']);
 }