Exemplo n.º 1
0
 /**
  * @return FullAddress
  */
 public function testGetFullAddress()
 {
     $request = $this->operation['response']['body'];
     $fullAddress = new FullAddress($request);
     $result = Address::getFullAddress($fullAddress->getAddress(), array(), $this->apiContext, $this->mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertInstanceOf('\\BlockCypher\\Api\\FullAddress', $result);
     // Assert only immutable values.
     $this->assertEquals($fullAddress->getAddress(), $result->getAddress());
     $this->assertEquals($fullAddress->getTxUrl(), $result->getTxUrl());
     $this->assertEquals(count($fullAddress->getTxs()), count($result->getTxs()));
     $this->assertContainsOnlyInstancesOf('\\BlockCypher\\Api\\TX', $result->getTxs());
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Obtain multiple FullAddress resources for the given identifiers.
  *
  * @deprecated since version 1.2. Use AddressClient.
  * @param string[] $array
  * @param array $params Parameters. Options: unspentOnly, and before
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return FullAddress[]
  */
 public static function getMultiple($array, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentArrayValidator::validate($array, 'array');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array('unspentOnly' => 1, 'before' => 1);
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $addressList = implode(";", $array);
     $payLoad = "";
     $chainUrlPrefix = self::getChainUrlPrefix($apiContext);
     $json = self::executeCall("{$chainUrlPrefix}/addrs/{$addressList}/full?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     return FullAddress::getList($json);
 }
 /**
  * @return FullAddress[]
  */
 public function testGetMultiple()
 {
     $request = $this->operation['response']['body'];
     $fullAddressArray = FullAddress::getList($request);
     $fullAddressList = array();
     /** @var FullAddress $fullAddress */
     foreach ($fullAddressArray as $fullAddress) {
         $fullAddressList[] = $fullAddress->getAddress();
     }
     $result = FullAddress::getMultiple($fullAddressList, array(), $this->apiContext, $this->mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertContainsOnlyInstancesOf('\\BlockCypher\\Api\\FullAddress', $result);
     $this->assertEquals(count($result), count($fullAddressList));
     foreach ($result as $fullAddr) {
         $this->assertContains($fullAddr->getAddress(), $fullAddressList);
     }
     return $result;
 }
Exemplo n.º 4
0
 /**
  * @dataProvider mockProviderGetParamsValidation
  * @param FullAddress $obj
  * @param $mockApiContext
  * @param $params
  * @expectedException \InvalidArgumentException
  */
 public function testGetMultipleParamsValidationForParams($obj, $mockApiContext, $params)
 {
     $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock();
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue('[' . FullAddressTest::getJson() . ']'));
     $fullAddressList = array(FullAddressTest::getObject()->getAddress());
     /** @noinspection PhpUndefinedVariableInspection */
     /** @noinspection PhpParamsInspection */
     $obj->get($fullAddressList, $params, $mockApiContext, $mockBlockCypherRestCall);
 }
Exemplo n.º 5
0
 /**
  * Obtain the FullAddress resource for the given address.
  *
  * @deprecated since version 1.2. Use AddressClient.
  * @param string $address
  * @param array $params Parameters. Options: unspentOnly, and before
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return FullAddress
  */
 public static function getFullAddress($address, $params = array(), $apiContext = null, $restCall = null)
 {
     return FullAddress::get($address, $params, $apiContext, $restCall);
 }
Exemplo n.º 6
0
 /**
  * Obtain multiple FullAddress resources for the given identifiers.
  *
  * @param string[] $array
  * @param array $params Parameters. Options: unspentOnly, and before
  * @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
  * @param BlockCypherRestCall $restCall is the Rest Call Service that is used to make rest calls
  * @return FullAddress[]
  */
 public function getMultipleFullAddresses($array, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentArrayValidator::validate($array, 'array');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array('unspentOnly' => 1, 'before' => 1, 'after' => 1, 'limit' => 1, 'txlimit' => 1, 'confirmations' => 1, 'confidence' => 1, 'includeHex' => 1, 'includeConfidence' => 1, 'omitWalletAddresses' => 1);
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $addressList = implode(";", $array);
     $payLoad = "";
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/addrs/{$addressList}/full?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     return FullAddress::getList($json);
 }
 /**
  * @dataProvider mockProvider
  * @param FullAddress $obj
  */
 public function testGet($obj, $mockApiContext)
 {
     $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock();
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue(FullWalletAsFullAddressTest::getJson()));
     /** @noinspection PhpParamsInspection */
     $result = $obj->get("alice", array(), $mockApiContext, $mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertInstanceOf('BlockCypher\\Api\\FullAddress', $result);
 }