Skip to content

Commit 2e03281

Browse files
authored
Merge pull request #14 from scaytrase/feature/badges
Badges and Readme
2 parents 2077477 + ef881ae commit 2e03281

File tree

5 files changed

+75
-29
lines changed

5 files changed

+75
-29
lines changed

.scrutinizer.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
build:
2+
tests:
3+
override:
4+
-
5+
command: phpunit --coverage-clover=build/clover.xml
6+
coverage:
7+
file: build/clover.xml
8+
format: php-clover

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
1-
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/9706918a-39d4-4822-8e25-d0a01182b10b/big.png)](https://insight.sensiolabs.com/projects/9706918a-39d4-4822-8e25-d0a01182b10b)
1+
[![Build Status](https://travis-ci.org/scaytrase/json-rpc-client.svg?branch=master)](https://travis-ci.org/scaytrase/json-rpc-client)
2+
[![Code Coverage](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/?branch=master)
3+
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/scaytrase/json-rpc-client/?branch=master)
4+
[![SensioLabsInsight](https://insight.sensiolabs.com/projects/9706918a-39d4-4822-8e25-d0a01182b10b/mini.png)](https://insight.sensiolabs.com/projects/9706918a-39d4-4822-8e25-d0a01182b10b)
25

3-
# RPC Library
46

5-
Built-in support for batch-like requests. Processing depends on client implementation (may not be real batch)
7+
[![Latest Stable Version](https://poser.pugx.org/scaytrase/json-rpc-client/v/stable)](https://packagist.org/packages/scaytrase/json-rpc-client)
8+
[![Total Downloads](https://poser.pugx.org/scaytrase/json-rpc-client/downloads)](https://packagist.org/packages/scaytrase/json-rpc-client)
9+
[![Latest Unstable Version](https://poser.pugx.org/scaytrase/json-rpc-client/v/unstable)](https://packagist.org/packages/scaytrase/json-rpc-client)
610

7-
## Common interfaces
8-
* RPC request (call)
9-
* RPC response (result)
10-
* RPC error
11-
## Decorators
12-
* Lazy client decorator
13-
* Loggable client decorator
14-
* Cacheable client decorator
11+
# JSON-RPC 2.0 Client implementation
1512

16-
# JSON-RPC Implementation
13+
Extension of [`scaytrase/rpc-common`](https://github.com/scaytrase/rpc-common)
14+
15+
* JSON RPC Interfaces
16+
* JSON RPC client
17+
* Async with Guzzle
18+
* Automatic batch with multiple requests or `LazyClientDecorator`
1719

1820
[JSON-RPC 2.0 Specification](http://www.jsonrpc.org/specification)

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
},
1919
"require-dev": {
2020
"phpunit/phpunit": "~4.5|~5.1",
21+
"phpunit/php-code-coverage": "~2.1|~3.0",
2122
"psr/cache": "~1.0"
2223
},
2324
"autoload": {

src/ScayTrase/Api/JsonRpc/Tests/JsonRpcClientTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ function ($args) use ($self, $params, $isArray) {
6464
$content = $request->getBody()->getContents();
6565
$data = json_decode($content);
6666
if ($isArray) {
67-
self::assertTrue(is_array($data));
68-
self::assertNotEmpty($data);
67+
$self::assertTrue(is_array($data));
68+
$self::assertNotEmpty($data);
6969
$data = array_shift($data);
7070
}
7171
$self::assertEquals(JSON_ERROR_NONE, json_last_error());
@@ -86,8 +86,8 @@ function () {
8686
);
8787
}
8888
);
89-
$client = new JsonRpcClient($guzzle->reveal(), new Uri('http://localhost/'));
90-
return $client;
89+
90+
return new JsonRpcClient($guzzle->reveal(), new Uri('http://localhost/'));
9191
}
9292

9393
/**

src/ScayTrase/Api/JsonRpc/Tests/ResponseBodyValidatorTest.php

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,31 +15,66 @@ class ResponseBodyValidatorTest extends \PHPUnit_Framework_TestCase
1515
public function invalidResponseBodyProvider()
1616
{
1717
return [
18-
'empty body' => [(object)null],
19-
'only version' => [(object)['jsonrpc' => '2.0']],
20-
'invalid version' => [(object)['jsonrpc' => '1.1']],
21-
'only result' => [(object)['result' => (object)['success' => true]]],
22-
'only id' => [(object)['id' => 1234]],
23-
'result and id' => [(object)['result' => (object)['success' => true], 'id' => 1234]],
24-
'result and id and invalid version' => [(object)['jsonrpc' => '1.1', 'result' => (object)['success' => true], 'id' => 1234]],
25-
'both result and error present' => [(object)['jsonrpc' => '2.0', 'result' => (object)['success' => true], 'id' => 1234, 'error' => (object)['code' => JsonRpcErrorInterface::INTERNAL_ERROR, 'message' => 'Test error']]],
18+
'empty body' => [(object)null],
19+
'only version' => [(object)['jsonrpc' => '2.0']],
20+
'invalid version' => [(object)['jsonrpc' => '1.1']],
21+
'only result' => [(object)['result' => (object)['success' => true]]],
22+
'only id' => [(object)['id' => 1234]],
23+
'result and id' => [(object)['result' => (object)['success' => true], 'id' => 1234]],
24+
'result and id and invalid version' => [
25+
(object)[
26+
'jsonrpc' => '1.1',
27+
'result' => (object)['success' => true],
28+
'id' => 1234,
29+
],
30+
],
31+
'both result and error present' => [
32+
(object)[
33+
'jsonrpc' => '2.0',
34+
'result' => (object)['success' => true],
35+
'id' => 1234,
36+
'error' => (object)[
37+
'code' => JsonRpcErrorInterface::INTERNAL_ERROR,
38+
'message' => 'Test error',
39+
],
40+
],
41+
],
2642
];
2743
}
2844

2945
public function validResponseBodyProvider()
3046
{
3147
return [
32-
'valid response' => [(object)['jsonrpc' => '2.0', 'result' => ['success' => true], 'id' => 1234]],
48+
'valid response' => [(object)['jsonrpc' => '2.0', 'result' => ['success' => true], 'id' => 1234]],
3349
'valid empty response' => [(object)['jsonrpc' => '2.0', 'result' => null, 'id' => 1234]],
34-
'valid error' => [(object)['jsonrpc' => '2.0', 'error' => (object)['code' => JsonRpcErrorInterface::INTERNAL_ERROR, 'message' => 'Test error'], 'id' => 1234]],
35-
'valid error w\ data' => [(object)['jsonrpc' => '2.0', 'error' => (object)['code' => JsonRpcErrorInterface::INTERNAL_ERROR, 'message' => 'Test error', 'data' => 'Test error data'], 'id' => 1234]],
50+
'valid error' => [
51+
(object)[
52+
'jsonrpc' => '2.0',
53+
'error' => (object)[
54+
'code' => JsonRpcErrorInterface::INTERNAL_ERROR,
55+
'message' => 'Test error',
56+
],
57+
'id' => 1234,
58+
],
59+
],
60+
'valid error w\ data' => [
61+
(object)[
62+
'jsonrpc' => '2.0',
63+
'error' => (object)[
64+
'code' => JsonRpcErrorInterface::INTERNAL_ERROR,
65+
'message' => 'Test error',
66+
'data' => 'Test error data',
67+
],
68+
'id' => 1234,
69+
],
70+
],
3671
];
3772
}
3873

3974
/**
4075
* @param \stdClass $body
4176
*
42-
*@dataProvider invalidResponseBodyProvider
77+
* @dataProvider invalidResponseBodyProvider
4378
* @expectedException \ScayTrase\Api\JsonRpc\Exception\ResponseParseException
4479
*/
4580
public function testInvalidBody(\stdClass $body)
@@ -50,12 +85,12 @@ public function testInvalidBody(\stdClass $body)
5085

5186
/**
5287
* @param \stdClass $body
88+
*
5389
* @dataProvider validResponseBodyProvider
5490
*/
5591
public function testValidBody(\stdClass $body)
5692
{
5793
$parser = new ResponseBodyValidator();
5894
$parser->validate($body);
5995
}
60-
6196
}

0 commit comments

Comments
 (0)