Skip to content

Commit 5dc146e

Browse files
author
Pavel Batanov
committed
Badges
* Scrutinizer coverage
1 parent 2077477 commit 5dc146e

File tree

3 files changed

+65
-14
lines changed

3 files changed

+65
-14
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: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
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)
5+
6+
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)
210

311
# RPC Library
412

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)