Ejemplo n.º 1
0
 function testPageComsumesFixture()
 {
     $this->expect_Curl_jsonRequest()->with('GET', 'https://test.hypercharge.net/v2/scheduler')->andReturn($this->response('scheduler_page_1.json'));
     $page = Scheduler::page();
     $this->assertIsA($page, 'Hypercharge\\PaginatedCollection');
     $this->assertEqual(1, $page->getPage());
     $this->assertEqual(10, $page->getTotalCount());
     $this->assertEqual(7, $page->getPerPage());
     $uids = array();
     foreach ($page as $entry) {
         $this->assertIsA($entry, 'Hypercharge\\Scheduler');
         $uids[] = $entry->unique_id;
     }
     $this->assertEqual(array('0293069be5a868ae69290e8a0eff72b3', '0763d2761d004a86f24807594610900b', '22cd57da4a1c36652b6eb3e5b7587b03', 'd07061244f5a468271bf27486ccfcaa2', 'ff700580d3c19e1f1d8f6364c1c7d707', 'f3268a2e9ae4d389d92d4503c480c67d', 'c4e9afeddc0c7dd907433187ac86e1bd'), $uids);
 }
 function testTransactionsPage()
 {
     $_this = $this;
     $schedulers = Scheduler::page(array('start_date_from' => '2013-06-27', 'start_date_to' => '2013-06-27'));
     $this->assertIsA($schedulers, 'Hypercharge\\PaginatedCollection');
     $this->assertEqual(9, $schedulers->getCount());
     foreach ($schedulers as $scheduler) {
         $this->assertIsA($scheduler, 'Hypercharge\\Scheduler');
         $this->assertEqual(Scheduler::MONTHLY, $scheduler->interval);
         $transactions = SchedulerTransactions::page($scheduler->unique_id);
         $this->assertIsA($transactions, 'Hypercharge\\PaginatedCollection');
         // first 3 transactions are known. They become more
         $this->assertTrue($transactions->getCount() >= 3);
         foreach ($transactions as $i => $trx) {
             $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);
             }
         }
     }
 }