Example #1
0
 /**
  * @dataProvider mockProvider
  * @param WalletClient $obj
  * @param PHPUnit_Framework_MockObject_MockObject|ApiContext $mockApiContext
  * @param PHPUnit_Framework_MockObject_MockObject|BlockCypherRestCall $mockBlockCypherRestCall
  */
 public function testRemoveAddresses($obj, $mockApiContext, $mockBlockCypherRestCall)
 {
     $addressList = AddressListTest::getObject();
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(WalletTest::getJson(array_diff(WalletTest::addresses(), $addressList->getAddresses()))));
     $result = $obj->addAddresses(WalletTest::getObject()->getName(), $addressList, array(), $mockApiContext, $mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertNotContains($addressList->getAddresses(), $result->getAddresses());
 }
<?php

// Run on console:
// php -f .\sample\wallet-api\AddAddressesToWalletEndpoint.php
require __DIR__ . '/../bootstrap.php';
use BlockCypher\Api\AddressList;
use BlockCypher\Auth\SimpleTokenCredential;
use BlockCypher\Client\WalletClient;
use BlockCypher\Rest\ApiContext;
$apiContext = ApiContext::create('main', 'btc', 'v1', new SimpleTokenCredential('c0afcccdde5081d6429de37d16166ead'), array('mode' => 'sandbox', 'log.LogEnabled' => true, 'log.FileName' => 'BlockCypher.log', 'log.LogLevel' => 'DEBUG'));
$walletClient = new WalletClient($apiContext);
$addressList = AddressList::fromAddressesArray(array("13cj1QtfW61kQHoqXm3khVRYPJrgQiRM6j"));
$wallet = $walletClient->addAddresses('alice', $addressList);
ResultPrinter::printResult("Add Addresses to a Wallet Endpoint", "Wallet", 'alice', $addressList, $wallet);