Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @dataProvider mockProviderGetParamsValidation
- * @param AddressBalance $obj
- * @param $mockApiContext
- * @param $params
- * @expectedException \InvalidArgumentException
- */
- public function testGetParamsValidationForParams(
- $obj, /** @noinspection PhpDocSignatureInspection */
- $mockApiContext,
- $params
- )
- {
- $mockBlockCypherRestCall = $this->getMockBuilder('\BlockCypher\Transport\BlockCypherRestCall')
- ->setMethods(array('getBaseChainUrl'))
- ->disableOriginalConstructor()
- ->getMock();
- $mockBlockCypherRestCall->expects($this->any())
- ->method('execute')
- ->will($this->returnValue(
- AddressBalanceTest::getJson()
- ));
- /** @noinspection PhpUndefinedVariableInspection */
- /** @noinspection PhpParamsInspection */
- $obj->get("1DEP8i3QJCsomS4BSMY2RpU1upv62aGvhD", $params, $mockApiContext, $mockBlockCypherRestCall);
- }
- PHPUNit Run..
- PHPUnit 8.4.3 by Sebastian Bergmann and contributors.
- Failed asserting that exception of type "PHPUnit\Framework\MockObject\RuntimeException" matches expected exception "\InvalidArgumentException". Message was: "Trying to configure method "execute" which cannot be configured because it does not exist, has not been specified, is final, or is static" at
- C:\Users\avion\projects\blockcypher\php-client\tests\BlockCypher\Test\Api\AddressBalanceTest.php:123
- .
- Time: 2.0699999999999998 seconds, Memory: 16.00 MB
- Interesting enough took a look at the class that is being mocked... execute is this..
- /**
- * @param array $handlers Array of handlers
- * @param string $path Resource path relative to base service endpoint
- * @param string $method HTTP method - one of GET, POST, PUT, DELETE, PATCH etc
- * @param string $data Request payload
- * @param array $headers HTTP headers
- * @return mixed
- * @throws \BlockCypher\Exception\BlockCypherConnectionException
- */
- public function execute($handlers = array(), $path, $method, $data = '', $headers = array())
- {
- $config = $this->apiContext->getConfig();
- $httpConfig = new BlockCypherHttpConfig(null, $method, $config);
- $headers = $headers ? $headers : array();
- $httpConfig->setHeaders($headers +
- array(
- 'Content-Type' => 'application/json'
- )
- );
- /** @var \BlockCypher\Handler\IBlockCypherHandler $handler */
- foreach ($handlers as $handler) {
- if (!is_object($handler)) {
- $fullHandler = "\\" . (string)$handler;
- $handler = new $fullHandler($this->apiContext);
- }
- $handler->handle($httpConfig, $data, array('path' => $path, 'apiContext' => $this->apiContext));
- }
- $connection = new BlockCypherHttpConnection($httpConfig, $config);
- $response = $connection->execute($data);
- return $response;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement