Skip to content

Commit 8fd1bb5

Browse files
committed
Merge branch 'release/1.0.0'
2 parents 493e2d3 + 221626d commit 8fd1bb5

File tree

12 files changed

+85
-46
lines changed

12 files changed

+85
-46
lines changed

.github/CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @yoanm

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@ build
44
composer.lock
55

66
features/demo_app/var/
7+
8+
#Phpunit
9+
.phpunit.result.cache

.scrutinizer.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,28 @@ build_failure_conditions:
1111
build:
1212
dependencies:
1313
override:
14-
- make build
14+
-
15+
command: make build
16+
title: Build deps
1517
tests:
1618
stop_on_failure: true
1719
override:
1820
-
1921
command: make coverage
22+
title: Coverage
2023
idle_timeout: 1200
2124
coverage:
2225
file: 'build/coverage/clover.xml'
2326
format: 'php-clover'
24-
- php-scrutinizer-run --enable-security-analysis
25-
- make codestyle
27+
-
28+
command: make codestyle
29+
title: Code style
30+
-
31+
command: composer global require maglnet/composer-require-checker && composer-require-checker check composer.json
32+
title: Composer-require-checker
33+
-
34+
command: php-scrutinizer-run --enable-security-analysis
35+
title: Scrutinizer checks
2636
cache:
2737
directories:
2838
- ~/.composer
@@ -36,7 +46,7 @@ build:
3646
COVERAGE_OUTPUT_STYLE: 'clover'
3747
COVERAGE_CLOVER_FILE_PATH: 'build/coverage/clover.xml'
3848
php:
39-
version: "7.1"
49+
version: "7.3"
4050
timezone: UTC
4151
postgresql: false
4252
redis: false

.travis.yml

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
11
language: php
22

33
php:
4-
- '7.1'
54
- '7.2'
65
- '7.3'
76
- '7.4'
87

98
env:
109
global:
11-
CI: 'true'
12-
TEST_OUTPUT_STYLE: 'pretty'
13-
PHPCS_REPORT_STYLE: 'full'
14-
COMPOSER_OPTIONS: '--optimize-autoloader'
15-
matrix:
16-
- SYMFONY_VERSION: '~3.0'
17-
- SYMFONY_VERSION: '~4.0'
18-
19-
sudo: false
20-
21-
matrix:
10+
- CI: 'true'
11+
- TEST_OUTPUT_STYLE: 'pretty'
12+
- PHPCS_REPORT_STYLE: 'full'
13+
- COMPOSER_OPTIONS: '--optimize-autoloader'
14+
jobs:
15+
- SYMFONY_VERSION: '~4.0'
16+
- SYMFONY_VERSION: '~5.0'
17+
18+
jobs:
2219
fast_finish: true
2320

2421
before_install:
@@ -41,3 +38,4 @@ branches:
4138
except:
4239
- /.*\-dev$/
4340
- /.*\-patch(\-\d+)?$/
41+
- /^dev-.*/

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
[![Scrutinizer Build Status](https://img.shields.io/scrutinizer/build/g/yoanm/symfony-jsonrpc-http-server-doc.svg?label=Scrutinizer&logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/build-status/master) [![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/yoanm/symfony-jsonrpc-http-server-doc/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/?branch=master) [![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/yoanm/symfony-jsonrpc-http-server-doc/master.svg?logo=scrutinizer)](https://scrutinizer-ci.com/g/yoanm/symfony-jsonrpc-http-server-doc/?branch=master)
55

6-
[![Travis Build Status](https://img.shields.io/travis/com/yoanm/symfony-jsonrpc-http-server-doc/master.svg?label=Travis&logo=travis)](https://travis-ci.com/yoanm/symfony-jsonrpc-http-server-doc) <!-- NOT WORKING WITH travis-ci.com [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/symfony-jsonrpc-http-server-doc.svg?logo=travis)](https://php.net/) --> [![Travis Symfony Versions](https://img.shields.io/badge/Symfony-v3%20%2F%20v4-8892BF.svg?logo=travis)](https://symfony.com/)
6+
[![Travis Build Status](https://img.shields.io/travis/com/yoanm/symfony-jsonrpc-http-server-doc/master.svg?label=Travis&logo=travis)](https://travis-ci.com/yoanm/symfony-jsonrpc-http-server-doc) <!-- NOT WORKING WITH travis-ci.com [![Travis PHP versions](https://img.shields.io/travis/php-v/yoanm/symfony-jsonrpc-http-server-doc.svg?logo=travis)](https://php.net/) --> [![Travis Symfony Versions](https://img.shields.io/badge/Symfony-v4%20%2F%20v5-8892BF.svg?logo=travis)](https://symfony.com/)
77

88
[![Latest Stable Version](https://img.shields.io/packagist/v/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server-doc) [![Packagist PHP version](https://img.shields.io/packagist/php-v/yoanm/symfony-jsonrpc-http-server-doc.svg)](https://packagist.org/packages/yoanm/symfony-jsonrpc-http-server-doc)
99

1010
Symfony bundle for easy JSON-RPC server documentation
1111

12-
Symfony bundle for [`yoanm/jsonrpc-server-doc-sdk`](https://raw.githubusercontent.com/yoanm/php-jsonrpc-server-doc-sdk)
12+
Symfony bundle for [`yoanm/jsonrpc-server-doc-sdk`](https://github.com/yoanm/php-jsonrpc-server-doc-sdk)
1313

1414
See [yoanm/symfony-jsonrpc-params-sf-constraints-doc](https://github.com/yoanm/symfony-jsonrpc-params-sf-constraints-doc) for params documentation generation.
1515

composer.json

+10-7
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,25 @@
3232
"yoanm/symfony-jsonrpc-http-server-swagger-doc": "Symfony bundle for easy JSON-RPC server Swagger 2.0 documentation"
3333
},
3434
"require": {
35-
"php": ">=7.1",
35+
"ext-json": "*",
36+
"php": ">=7.2",
3637
"yoanm/jsonrpc-server-sdk": "^3.0",
3738
"yoanm/jsonrpc-server-doc-sdk": "^0.2",
38-
"yoanm/symfony-jsonrpc-http-server": "^2.0",
39-
"symfony/http-kernel": "^3.0 || ^4.0",
40-
"symfony/config": "^3.0 || ^4.0",
41-
"symfony/dependency-injection": "^3.0 || ^4.0"
39+
"yoanm/symfony-jsonrpc-http-server": "^3.0",
40+
"symfony/http-foundation": "^4.0 || ^5.0",
41+
"symfony/http-kernel": "^4.0 || ^5.0",
42+
"symfony/config": "^4.0 || ^5.0",
43+
"symfony/dependency-injection": "^4.0 || ^5.0",
44+
"symfony/event-dispatcher-contracts": "^1.0 || ^2.0"
4245
},
4346
"require-dev": {
4447
"behat/behat": "~3.0",
4548
"squizlabs/php_codesniffer": "3.*",
4649
"phpunit/phpunit": "^7.0 || ^8.0",
4750
"matthiasnoback/symfony-dependency-injection-test": "^3.0 || ^4.0",
4851
"matthiasnoback/symfony-config-test": "^3.0 || ^4.0",
49-
"symfony/framework-bundle": "^3.0 || ^4.0",
50-
"symfony/routing": "^3.0 || ^4.0",
52+
"symfony/framework-bundle": "^4.0 || ^5.0",
53+
"symfony/routing": "^4.0 || ^5.0",
5154
"yoanm/php-unit-extended": "~1.0"
5255
}
5356
}

src/Creator/HttpServerDocCreator.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace Yoanm\SymfonyJsonRpcHttpServerDoc\Creator;
33

4-
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
4+
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
55
use Yoanm\JsonRpcServer\Domain\JsonRpcMethodAwareInterface;
66
use Yoanm\JsonRpcServer\Domain\JsonRpcMethodInterface;
77
use Yoanm\JsonRpcServerDoc\Domain\Model\HttpServerDoc;
@@ -49,7 +49,7 @@ public function create($host = null) : HttpServerDoc
4949
$this->appendMethodsDoc($serverDoc);
5050

5151
$event = new ServerDocCreatedEvent($serverDoc);
52-
$this->dispatcher->dispatch($event::EVENT_NAME, $event);
52+
$this->dispatcher->dispatch($event, $event::EVENT_NAME);
5353

5454
return $serverDoc;
5555
}
@@ -75,7 +75,7 @@ protected function appendMethodsDoc(ServerDoc $serverDoc)
7575
)
7676
->setMethod($method);
7777

78-
$this->dispatcher->dispatch($event::EVENT_NAME, $event);
78+
$this->dispatcher->dispatch($event, $event::EVENT_NAME);
7979

8080
$serverDoc->addMethod($event->getDoc());
8181
}

src/DependencyInjection/Configuration.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class Configuration implements ConfigurationInterface
1515
*/
1616
public function getConfigTreeBuilder()
1717
{
18-
$treeBuilder = new TreeBuilder();
18+
$treeBuilder = new TreeBuilder(JsonRpcHttpServerDocExtension::EXTENSION_IDENTIFIER);
1919

20-
$rootNode = $treeBuilder->root(JsonRpcHttpServerDocExtension::EXTENSION_IDENTIFIER);
20+
$rootNode = $treeBuilder->getRootNode();
2121

2222
$rootNode
2323
->addDefaultsIfNotSet()

src/Endpoint/DocumentationEndpoint.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ public function httpOptions() : Response
3535
$response->headers->set('Content-Type', 'application/json');
3636

3737
// Set allowed http methods
38-
$response->headers->set('Allow', $this->allowedMethodList);
39-
$response->headers->set('Access-Control-Request-Method', $this->allowedMethodList);
38+
$allowedMethodListString = implode(', ', $this->allowedMethodList);
39+
$response->headers->set('Allow', $allowedMethodListString);
40+
$response->headers->set('Access-Control-Request-Method', $allowedMethodListString);
4041

4142
// Set allowed content type
4243
$response->headers->set('Accept', 'application/json');

src/Event/DocEvent.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Yoanm\SymfonyJsonRpcHttpServerDoc\Event;
44

5-
use Symfony\Component\EventDispatcher\Event;
5+
use Symfony\Contracts\EventDispatcher\Event;
66

77
/**
88
* Class DocEvent

tests/Functional/Creator/HttpServerDocCreatorTest.php

+35-12
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ protected function setUp(): void
3636

3737
public function testShouldCreateBasicDocWithoutMethods()
3838
{
39+
$this->dispatcher->dispatch(Argument::type(ServerDocCreatedEvent::class), ServerDocCreatedEvent::EVENT_NAME)
40+
->willReturnArgument(0)
41+
->shouldBeCalled();
42+
3943
$doc = $this->creator->create();
4044

4145
$this->assertSame(
@@ -56,6 +60,10 @@ public function testShouldCreateBasicDocWithoutMethods()
5660

5761
public function testShouldCreateDocWithHost()
5862
{
63+
$this->dispatcher->dispatch(Argument::type(ServerDocCreatedEvent::class), ServerDocCreatedEvent::EVENT_NAME)
64+
->willReturnArgument(0)
65+
->shouldBeCalled();
66+
5967
$host = 'my-host';
6068
$doc = $this->creator->create($host);
6169

@@ -77,6 +85,14 @@ public function testShouldCreateDocWithHost()
7785

7886
public function testShouldCreateDocWithMethodList()
7987
{
88+
$this->dispatcher->dispatch(Argument::type(ServerDocCreatedEvent::class), ServerDocCreatedEvent::EVENT_NAME)
89+
->willReturnArgument(0)
90+
->shouldBeCalled();
91+
92+
$this->dispatcher->dispatch(Argument::type(MethodDocCreatedEvent::class), MethodDocCreatedEvent::EVENT_NAME)
93+
->willReturnArgument(0)
94+
->shouldBeCalledTimes(2);
95+
8096
$method1Name = 'method-1';
8197
$method2Name = 'method-2';
8298
$method1 = $this->prophesize(JsonRpcMethodInterface::class);
@@ -114,9 +130,11 @@ public function testShouldDispatchServerDocCreatedEvent()
114130
{
115131
$docInEvent = null;
116132

117-
$this->dispatcher->dispatch(ServerDocCreatedEvent::EVENT_NAME, Argument::type(ServerDocCreatedEvent::class))
133+
$this->dispatcher->dispatch(Argument::type(ServerDocCreatedEvent::class), ServerDocCreatedEvent::EVENT_NAME)
118134
->will(function ($args) use (&$docInEvent) {
119-
$docInEvent = $args[1]->getDoc();
135+
$docInEvent = $args[0]->getDoc();
136+
137+
return $args[0];
120138
})
121139
->shouldBeCalled();
122140

@@ -137,34 +155,39 @@ public function testShouldDispatchMethodDocCreatedEvent()
137155
$this->creator->addJsonRpcMethod($method1Name, $method1->reveal());
138156
$this->creator->addJsonRpcMethod($method2Name, $method2->reveal());
139157

140-
$this->dispatcher->dispatch(ServerDocCreatedEvent::EVENT_NAME, Argument::cetera())
141-
->shouldBeCalled()
142-
;
158+
159+
$this->dispatcher->dispatch(Argument::type(ServerDocCreatedEvent::class), ServerDocCreatedEvent::EVENT_NAME)
160+
->willReturnArgument(0)
161+
->shouldBeCalled();
143162

144163
$this->dispatcher->dispatch(
145-
MethodDocCreatedEvent::EVENT_NAME,
146164
Argument::allOf(
147165
Argument::type(MethodDocCreatedEvent::class),
148166
Argument::which('getMethod', $method1->reveal())
149-
)
167+
),
168+
MethodDocCreatedEvent::EVENT_NAME
150169
)
151170
->will(function ($args) use (&$docInEvent1) {
152-
$docInEvent1 = $args[1]->getDoc();
171+
$docInEvent1 = $args[0]->getDoc();
172+
173+
return $args[0];
153174
})
154175
->shouldBeCalled();
155-
156176
$this->dispatcher->dispatch(
157-
MethodDocCreatedEvent::EVENT_NAME,
158177
Argument::allOf(
159178
Argument::type(MethodDocCreatedEvent::class),
160179
Argument::which('getMethod', $method2->reveal())
161-
)
180+
),
181+
MethodDocCreatedEvent::EVENT_NAME
162182
)
163183
->will(function ($args) use (&$docInEvent2) {
164-
$docInEvent2 = $args[1]->getDoc();
184+
$docInEvent2 = $args[0]->getDoc();
185+
186+
return $args[0];
165187
})
166188
->shouldBeCalled();
167189

190+
168191
$doc = $this->creator->create();
169192

170193
[$method1Doc, $method2Doc] = $doc->getMethodList();

tests/Functional/Endpoint/DocumentationEndpointTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function testHttPostShouldHaveUseRawDocIfNoFilenameProvided()
8989

9090
public function testHttOptionsShouldReturnAllowedMethodsAndContentType()
9191
{
92-
$expectedAllowedMethodList = [Request::METHOD_GET, Request::METHOD_OPTIONS];
92+
$expectedAllowedMethodList = implode(', ', [Request::METHOD_GET, Request::METHOD_OPTIONS]);
9393

9494
$response = $this->endpoint->httpOptions();
9595

0 commit comments

Comments
 (0)