Skip to content

Commit fc5c777

Browse files
committed
Fix + UTs
1 parent 00eda58 commit fc5c777

File tree

4 files changed

+29
-3
lines changed

4 files changed

+29
-3
lines changed

src/DependencyInjection/Configuration.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ public function getConfigTreeBuilder()
2626
->addDefaultsIfNotSet()
2727
->children()
2828
->booleanNode('enabled')
29-
->info('Whether to render debug information on error or not (should NOT be enabled on prod)')
29+
->info(
30+
'Whether to render debug information on error or not (should NOT be enabled on prod)'
31+
)
3032
->defaultFalse()
3133
->end()
3234
->integerNode('max_trace_size')

src/DependencyInjection/JsonRpcHttpServerExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ private function checkMethodAwareServiceIdList(
230230
private function bindDebug(ContainerBuilder $container) : void
231231
{
232232
if ($container->getParameter(self::EXTENSION_IDENTIFIER.'.debug.enabled')) {
233-
$container->getDefinition(self::EXTENSION_IDENTIFIER.'.app.serialization.jsonrpc_response_normalizer')
234-
->addArgument(new Reference(self::EXTENSION_IDENTIFIER.'.app.serialization.jsonrpc_response_error_normalizer'));
233+
$container->getDefinition('json_rpc_server_sdk.app.serialization.jsonrpc_response_normalizer')
234+
->addArgument(new Reference('json_rpc_server_sdk.app.serialization.jsonrpc_response_error_normalizer'));
235235
}
236236
}
237237
}

tests/Functional/DependencyInjection/ConfigFilesTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Yoanm\JsonRpcServer\App\Serialization\JsonRpcCallSerializer;
1212
use Yoanm\JsonRpcServer\App\Serialization\JsonRpcRequestDenormalizer;
1313
use Yoanm\JsonRpcServer\App\Serialization\JsonRpcResponseNormalizer;
14+
use Yoanm\JsonRpcServer\App\Serialization\JsonRpcResponseErrorNormalizer;
1415
use Yoanm\JsonRpcServer\Infra\Endpoint\JsonRpcEndpoint;
1516
use Yoanm\SymfonyJsonRpcHttpServer\DependencyInjection\JsonRpcHttpServerExtension;
1617
use Yoanm\SymfonyJsonRpcHttpServer\Dispatcher\SymfonyJsonRpcServerDispatcher;
@@ -100,6 +101,11 @@ public function provideSDKAppServiceIdAndClass()
100101
'serviceClassName' => ResponseCreator::class,
101102
'public' => false,
102103
],
104+
'SDK - App - Response error normalizer' => [
105+
'serviceId' => 'json_rpc_server_sdk.app.serialization.jsonrpc_response_error_normalizer',
106+
'serviceClassName' => JsonRpcResponseErrorNormalizer::class,
107+
'public' => false,
108+
],
103109
];
104110
}
105111

tests/Functional/DependencyInjection/JsonRpcHttpServerExtensionTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,22 @@ public function testShouldThowAnExceptionIfMethodAwareServiceDoesNotImplementRig
185185

186186
$this->loadContainer();
187187
}
188+
189+
public function testShouldAddDebugResponseErrorNormalizerIfDebugModeEnabled()
190+
{
191+
$this->loadContainer([
192+
'debug' => [
193+
'enabled' => true,
194+
]
195+
]);
196+
197+
// Assert response normalizer has responseErrorNormalizer as first argument
198+
$this->assertContainerBuilderHasServiceDefinitionWithArgument(
199+
'json_rpc_server_sdk.app.serialization.jsonrpc_response_normalizer',
200+
0,
201+
new Reference('json_rpc_server_sdk.app.serialization.jsonrpc_response_error_normalizer'),
202+
);
203+
204+
$this->assertEndpointIsUsable();
205+
}
188206
}

0 commit comments

Comments
 (0)