/** * @dataProvider mockProvider * @param WalletClient $obj * @param PHPUnit_Framework_MockObject_MockObject|ApiContext $mockApiContext * @param PHPUnit_Framework_MockObject_MockObject|BlockCypherRestCall $mockBlockCypherRestCall */ public function testGenerateAddress($obj, $mockApiContext, $mockBlockCypherRestCall) { $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(WalletGenerateAddressResponseTest::getJson())); $result = $obj->generateAddress(WalletTest::getObject()->getName(), array(), $mockApiContext, $mockBlockCypherRestCall); $this->assertNotNull($result); }
<?php // Run on console: // php -f .\sample\wallet-api\GenerateAddressInWalletEndpoint.php require __DIR__ . '/../bootstrap.php'; 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); $walletGenerateAddressResponse = $walletClient->generateAddress('alice'); ResultPrinter::printResult("Generate Address In Wallet Endpoint", "Wallet", 'alice', null, $walletGenerateAddressResponse);
/** * @param $walletName * @param $coinSymbol * @param $token * @return WalletGenerateAddressResponse */ public function generateAddress($walletName, $coinSymbol, $token) { $apiContext = $this->apiContextFactory->getApiContext($coinSymbol, $token); $walletClient = new WalletClient($apiContext); $walletGenerateAddressResponse = $walletClient->generateAddress($walletName); return $walletGenerateAddressResponse; }