function testConstructYieldsWithObject()
 {
     $res = json_decode(JsonSchemaFixture::response('scheduler_page_2.json'));
     $this->assertIsA($res, 'StdClass');
     $c = new PaginatedCollection($res, function ($entry) {
         return new Transaction($entry);
     });
     $this->assertIdentical(10, $c->getTotalCount());
     $this->assertIdentical(2, $c->getPage());
     $this->assertIdentical(2, $c->getPagesCount());
     $this->assertIdentical(7, $c->getPerPage());
     $this->assertIdentical(3, count($c->getEntries()));
     $uids = array();
     foreach ($c as $trx) {
         $uids[] = $trx->unique_id;
         $this->assertIsA($trx, 'Hypercharge\\Transaction');
         $this->assertIsA($trx->amount, 'int');
         $this->assertIsA($trx->active, 'boolean');
     }
     $this->assertEqual(array('b39cf4adcdea97eb55903eab47518272', '912f9a230e6f5166f2708616cf7ee805', 'c14bb3479c669ecd5393ba700a01392b'), $uids);
 }
示例#2
0
 function testHandleError400()
 {
     $this->expectException('Hypercharge\\Errors\\InputDataInvalidError');
     $curl = new Curl('user', 'passw');
     $curl->handleError('http://url', 400, JsonSchemaFixture::response('scheduler_error.json'), null, array());
 }
 function testStripBankAccountNumberDoubleEscapedJson()
 {
     $str = json_encode(array('bla' => 'again ' . json_encode(array('message' => 'foobar ' . JsonSchemaFixture::request('debit_sale.json')))));
     $this->assertTrue(strstr($str, '1290701'));
     $stripped = Helper::stripCc($str);
     $this->assertFalse(strstr($stripped, '1290701'));
 }