function testResponseSchedulerErrorJson() { $json = \Hypercharge\JsonSchemaFixture::response('scheduler_error.json'); $this->assertJson($json); $data = json_decode($json); $this->assertIdentical(340, $data->error->code); }
function testConstructorLoadsJsonResponse() { $response = json_decode(JsonSchemaFixture::response('scheduled_transactions_one.json')); $this->assertIsA($response->entries[0], 'stdClass'); $trx = new Transaction($response->entries[0]); $this->assertIdentical(500, $trx->amount); $this->assertIdentical('USD', $trx->currency); $this->assertEqual('3ba2d77ab04f773c0a47bd1081ac50be', $trx->unique_id); }
/** * @param string $fileName e.g. "sale.json" for /vendor/hypercharge/hypercharge-schema/test/fixtures/sale.json * @return mixed array for *.json, string for other */ function schemaResponse($fileName) { return self::parseIfJson(JsonSchemaFixture::response($fileName) . "\n", $fileName); }
function testJsonResponseWorkflowError() { $data = json_decode(\Hypercharge\JsonSchemaFixture::response('scheduler_workflow_error.json')); $this->assertIsA($data, 'stdClass'); $this->assertIdentical(400, $data->error->code); $e = errorFromResponseHash($data->error); $this->assertIsa($e, 'Hypercharge\\Errors\\WorkflowError'); $this->assertEqual('Something went wrong, please contact support!', $e->message); $this->assertEqual("transaction already has a schedule.", $e->technical_message); }
function response($responseFixture) { return json_decode(JsonSchemaFixture::response($responseFixture)); }
function testEachWithEmpty() { $response = json_decode(JsonSchemaFixture::response('scheduled_transactions_empty.json')); $this->expect_Curl_jsonRequest()->with('GET', 'https://test.hypercharge.net/v2/scheduler/e1420438c52b4cb3a03a14a7e4fc16e1/transactions?page=3')->andReturn($response); $_this = $this; SchedulerTransactions::each('e1420438c52b4cb3a03a14a7e4fc16e1', array('page' => 3), function ($trx) use($_this) { $_this->fail('callback should not be called!'); }); }