function testNext() { $response = $this->response('scheduler_next.json'); $this->expect_Curl_jsonRequest()->with('GET', 'https://test.hypercharge.net/v2/scheduler/e1420438c52b4cb3a03a14a7e4fc16e1/next')->andReturn($response); $next = Scheduler::next('e1420438c52b4cb3a03a14a7e4fc16e1'); $this->assertEqual('2014-06-02', $next); }
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']); }