示例#1
0
 function testRequestMoney()
 {
     $requestor = new MockCoinbase_Requestor();
     $requestor->returns('doCurlRequest', array("statusCode" => 200, "body" => '
     {
       "success": true,
       "transaction": {
         "id": "501a3554f8182b2754000003",
         "created_at": "2012-08-02T01:07:48-07:00",
         "hsh": null,
         "notes": "Sample request for you!",
         "amount": {
           "amount": "1.23400000",
           "currency": "BTC"
         },
         "request": true,
         "status": "pending",
         "sender": {
           "id": "5011f33df8182b142400000a",
           "name": "User One",
           "email": "*****@*****.**"
         },
         "recipient": {
           "id": "5011f33df8182b142400000e",
           "name": "User Two",
           "email": "*****@*****.**"
         }
       }
     }'));
     $coinbase = new Coinbase("");
     $coinbase->setRequestor($requestor);
     $response = $coinbase->requestMoney("*****@*****.**", "1.234", "Sample transaction for you");
     $this->assertEqual($response->success, true);
     $this->assertEqual($response->transaction->id, '501a3554f8182b2754000003');
     $this->assertEqual($response->transaction->hsh, null);
     $this->assertEqual($response->transaction->request, true);
     $requestor->returns('doCurlRequest', array("statusCode" => 200, "body" => '
     {
       "success": true
     }'));
     $this->assertEqual($coinbase->resendRequest('501a3554f8182b2754000003')->success, true);
     $this->assertEqual($coinbase->cancelRequest('501a3554f8182b2754000003')->success, true);
     $this->assertEqual($coinbase->completeRequest('501a3554f8182b2754000003')->success, true);
 }