Skip to content

Commit a9ae576

Browse files
committed
Add UT, remove useless
1 parent ef282e7 commit a9ae576

File tree

9 files changed

+228
-170
lines changed

9 files changed

+228
-170
lines changed

src/Endpoint/JsonRpcHttpEndpoint.php

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/EventListener/RequestListener.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ class RequestListener
1717

1818
public function __construct(SDKJsonRpcEndpoint $sdkEndpoint, $uri)
1919
{
20-
var_dump("CONSTRUCT");
2120
$this->uri = $uri;
2221
$this->sdkEndpoint = $sdkEndpoint;
2322
$this->allowedMethodList = [Request::METHOD_POST, Request::METHOD_OPTIONS];

src/Resources/config/services.private.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ services:
1111
# Alias method resolver (used in sdk.services.app.yml)
1212
json_rpc_http_server.alias.method_resolver: '@json_rpc_http_server.method_resolver'
1313

14+
json_rpc_http_server.request_listener:
15+
class: Yoanm\SymfonyJsonRpcHttpServer\EventListener\RequestListener
16+
arguments:
17+
- '@json_rpc_server_sdk.infra.endpoint'
18+
- '%json_rpc_http_server.http_endpoint_path%'
19+
tags:
20+
- { name: kernel.event_listener, event: kernel.request, method: 'onKernelRequest', priority: 9999 }
21+
22+

src/Resources/config/services.public.yaml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,6 @@ services:
22
_defaults:
33
public: true
44

5-
json_rpc_http_server.endpoint:
6-
class: Yoanm\SymfonyJsonRpcHttpServer\Endpoint\JsonRpcHttpEndpoint
7-
arguments:
8-
- '@json_rpc_server_sdk.infra.endpoint'
9-
10-
json_rpc_http_server.request_listener:
11-
class: Yoanm\SymfonyJsonRpcHttpServer\EventListener\RequestListener
12-
arguments:
13-
- '@json_rpc_server_sdk.infra.endpoint'
14-
- '%json_rpc_http_server.http_endpoint_path%'
15-
tags:
16-
- { name: kernel.event_listener, event: kernel.request, method: 'onKernelRequest', priority: 9999 }
17-
185
json_rpc_http_server.dispatcher.server:
196
class: Yoanm\SymfonyJsonRpcHttpServer\Dispatcher\SymfonyJsonRpcServerDispatcher
207
arguments:

tests/Common/DependencyInjection/AbstractTestClass.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
abstract class AbstractTestClass extends AbstractExtensionTestCase
1313
{
14-
const EXPECTED_ENDPOINT_SERVICE_ID = 'json_rpc_http_server.endpoint';
14+
const EXPECTED_DISPATCHER_SERVICE_ID = 'json_rpc_http_server.dispatcher.server';
1515
const EXPECTED_HTTP_ENDPOINT_PATH_CONTAINER_PARAM = 'json_rpc_http_server.http_endpoint_path';
1616
const EXPECTED_PARAMS_VALIDATOR_ALIAS = 'json_rpc_http_server.alias.params_validator';
1717
const EXPECTED_REQUEST_HANDLER_SERVICE_ID = 'json_rpc_server_sdk.app.handler.jsonrpc_request';
@@ -47,11 +47,11 @@ protected function loadContainer(array $configurationValues = [], $mockResolver
4747
}
4848

4949

50-
protected function assertEndpointIsUsable()
50+
protected function assertDispatcherInstalled()
5151
{
5252
// Retrieving this service will imply to load all related dependencies
5353
// Any binding issues will be raised
54-
$this->assertNotNull($this->container->get(self::EXPECTED_ENDPOINT_SERVICE_ID));
54+
$this->assertNotNull($this->container->get(self::EXPECTED_DISPATCHER_SERVICE_ID));
5555
}
5656

5757
/**

tests/Functional/DependencyInjection/ConfigFilesTest.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Yoanm\SymfonyJsonRpcHttpServer\DependencyInjection\JsonRpcHttpServerExtension;
1616
use Yoanm\SymfonyJsonRpcHttpServer\Dispatcher\SymfonyJsonRpcServerDispatcher;
1717
use Yoanm\SymfonyJsonRpcHttpServer\Endpoint\JsonRpcHttpEndpoint;
18+
use Yoanm\SymfonyJsonRpcHttpServer\EventListener\RequestListener;
1819
use Yoanm\SymfonyJsonRpcHttpServer\Resolver\MethodResolver;
1920

2021
/**
@@ -37,6 +38,7 @@ protected function getContainerExtensions(): array
3738
* @dataProvider provideSDKAppServiceIdAndClass
3839
* @dataProvider provideSDKInfraServiceIdAndClass
3940
* @dataProvider provideBundlePublicServiceIdAndClass
41+
* @dataProvider provideBundlePrivateServiceIdAndClass
4042
*
4143
* @param string $serviceId
4244
* @param string $expectedClassName
@@ -122,11 +124,6 @@ public function provideSDKInfraServiceIdAndClass()
122124
public function provideBundlePublicServiceIdAndClass()
123125
{
124126
return [
125-
'Bundle - Public - HTTP endpoint' => [
126-
'serviceId' => 'json_rpc_http_server.endpoint',
127-
'serviceClassName' => JsonRpcHttpEndpoint::class,
128-
'public' => true,
129-
],
130127
'Bundle - Public - Event Dispatcher' => [
131128
'serviceId' => 'json_rpc_http_server.dispatcher.server',
132129
'serviceClassName' => SymfonyJsonRpcServerDispatcher::class,
@@ -141,15 +138,20 @@ public function provideBundlePublicServiceIdAndClass()
141138
public function provideBundlePrivateServiceIdAndClass()
142139
{
143140
return [
141+
'Bundle - Public - HTTP endpoint' => [
142+
'serviceId' => 'json_rpc_http_server.request_listener',
143+
'serviceClassName' => RequestListener::class,
144+
'public' => false,
145+
],
144146
'Bundle - Private - JSON-RPC method resolver ServiceLocator' => [
145147
'serviceId' => 'json_rpc_http_server.service_locator.method_resolver',
146148
'serviceClassName' => ServiceLocator::class,
147-
'public' => true,
149+
'public' => false,
148150
],
149151
'Bundle - Private - MethodResolver alias' => [
150152
'serviceId' => 'json_rpc_http_server.alias.method_resolver',
151153
'serviceClassName' => MethodResolver::class,
152-
'public' => true,
154+
'public' => false,
153155
],
154156
];
155157
}

tests/Functional/DependencyInjection/JsonRpcHttpServerExtensionTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function testShouldBeLoadable()
3131
{
3232
$this->loadContainer();
3333

34-
$this->assertEndpointIsUsable();
34+
$this->assertDispatcherInstalled();
3535
}
3636

3737
public function testShouldManageCustomEndpointPathFromConfiguration()
@@ -42,7 +42,7 @@ public function testShouldManageCustomEndpointPathFromConfiguration()
4242
// Assert custom resolver is an alias of the stub
4343
$this->assertContainerBuilderHasParameter(self::EXPECTED_HTTP_ENDPOINT_PATH_CONTAINER_PARAM, $myCustomEndpoint);
4444

45-
$this->assertEndpointIsUsable();
45+
$this->assertDispatcherInstalled();
4646
}
4747

4848
public function testShouldReturnAnXsdValidationBasePath()
@@ -67,7 +67,7 @@ public function testShouldBindServerDispatcherToDispatcherAwareService()
6767
0
6868
);
6969

70-
$this->assertEndpointIsUsable();
70+
$this->assertDispatcherInstalled();
7171
}
7272

7373
public function testShouldThrowAnExceptionIfDispatcherAwareServiceDoesNotUseRightTrait()
@@ -104,7 +104,7 @@ public function testShouldInjectParamsValidatorAliasIfDefined()
104104
[new Reference(self::EXPECTED_PARAMS_VALIDATOR_ALIAS)]
105105
);
106106

107-
$this->assertEndpointIsUsable();
107+
$this->assertDispatcherInstalled();
108108
}
109109

110110
public function testShouldNotInjectParamsValidatorAliasIfNotDefined()
@@ -118,7 +118,7 @@ public function testShouldNotInjectParamsValidatorAliasIfNotDefined()
118118
}
119119
}
120120

121-
$this->assertEndpointIsUsable();
121+
$this->assertDispatcherInstalled();
122122
}
123123

124124
public function testShouldBindJsonRpcMethodsToMethodAwareServices()
@@ -165,7 +165,7 @@ public function testShouldBindJsonRpcMethodsToMethodAwareServices()
165165
1
166166
);
167167

168-
$this->assertEndpointIsUsable();
168+
$this->assertDispatcherInstalled();
169169
}
170170

171171
public function testShouldThowAnExceptionIfMethodAwareServiceDoesNotImplementRightInterface()

tests/Functional/Endpoint/JsonRpcHttpEndpointTest.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)