Beispiel #1
0
 /**
  * Obtain multiple Block resources for the given identifiers (hash or height).
  *
  * @param string[] $array
  * @param array $params Parameters. Options: txstart, and limit
  * @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 Block[]
  */
 public function getMultiple($array, $params = array(), $apiContext = null, $restCall = null)
 {
     ArgumentArrayValidator::validate($array, 'array');
     ArgumentGetParamsValidator::validate($params, 'params');
     $allowedParams = array('txstart' => 1, 'limit' => 1);
     $params = ArgumentGetParamsValidator::sanitize($params, $allowedParams);
     $blockList = implode(";", $array);
     $payLoad = "";
     $chainUrlPrefix = $this->getChainUrlPrefix($apiContext);
     $json = $this->executeCall("{$chainUrlPrefix}/blocks/{$blockList}?" . http_build_query($params), "GET", $payLoad, null, $apiContext, $restCall);
     return Block::getList($json);
 }
Beispiel #2
0
 /**
  * @dataProvider mockProvider
  * @param Block $obj
  */
 public function testGetMultipleWithParams($obj, $mockApiContext)
 {
     $mockBlockCypherRestCall = $this->getMockBuilder('\\BlockCypher\\Transport\\BlockCypherRestCall')->disableOriginalConstructor()->getMock();
     $mockBlockCypherRestCall->expects($this->any())->method('execute')->will($this->returnValue('[' . BlockTest::getJson() . ']'));
     $blockList = array(BlockTest::getObject()->getHeight());
     $params = array('txstart' => 1, 'limit' => 1);
     $result = $obj->getMultiple($blockList, $params, $mockApiContext, $mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertEquals($result[0], BlockTest::getObject());
 }
 /**
  * @return Block
  */
 public function testGetWithPaging()
 {
     $request = $this->operation['response']['body'];
     $block = new Block($request);
     $params = array('txstart' => 1, 'limit' => 1);
     $result = Block::get($block->getHash(), $params, $this->apiContext, $this->mockBlockCypherRestCall);
     $this->assertNotNull($result);
     $this->assertInstanceOf('\\BlockCypher\\Api\\Block', $result);
     // Assert only immutable values.
     $this->assertEquals($block->getHash(), $result->getHash());
     $this->assertEquals($block->getTxUrl(), $result->getTxUrl());
     $this->assertEquals(count($block->getTxids()), count($result->getTxids()));
     return $result;
 }