for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace ScayTrase\Api\JsonRpc\Tests;
use GuzzleHttp\Exception\ServerException;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Uri;
use ScayTrase\Api\JsonRpc\JsonRpcClient;
use ScayTrase\Api\Rpc\Exception\RemoteCallFailedException;
class ClientExceptionsTest extends AbstractJsonRpcClientTest
{
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage Request should be either array or single RpcRequestInterface instance
*/
public function testInvalidArrayArgumentException()
$client = new JsonRpcClient($this->getClient(), new Uri());
$client->invoke('test');
'test'
string
object<ScayTrase\Api\Rpc...c\RpcRequestInterface>>
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example:
function acceptsInteger($int) { } $x = '123'; // string "123" // Instead of acceptsInteger($x); // we recommend to use acceptsInteger((integer) $x);
}
* @expectedException \ScayTrase\Api\Rpc\Exception\RemoteCallFailedException
* @expectedExceptionMessage Error completing request
public function testGuzzleException()
$exception = ServerException::create(new Request('GET', new Uri()));
$request = $this->createRequestForSingleInvocation('test', [], $exception);
$client->invoke($request)->getResponse($request);
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: