Skip to content

Commit 7795836

Browse files
Testing the service definitions & improving env loading (#8)
* Testing the services definition * Improving the env handling for the generic handler
1 parent 5b6ce5a commit 7795836

File tree

4 files changed

+5
-2
lines changed

4 files changed

+5
-2
lines changed

config/services.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ services:
2222
Phauthentic\Symfony\ProblemDetails\ExceptionConversion\GenericExceptionConverter:
2323
arguments:
2424
$problemDetailsFactory: '@Phauthentic\Symfony\ProblemDetails\ProblemDetailsFactoryInterface'
25+
$environment: '%kernel.environment%'
2526
tags: ['phauthentic.problem_details.exception_converter']
2627

2728
Phauthentic\Symfony\ProblemDetails\ThrowableToProblemDetailsKernelListener:

src/ExceptionConversion/GenericExceptionConverter.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class GenericExceptionConverter implements ExceptionConverterInterface
2626
*/
2727
public function __construct(
2828
protected ProblemDetailsFactoryInterface $problemDetailsFactory,
29-
protected string $environment = 'prod',
29+
protected string $environment,
3030
protected array $mappers = []
3131
) {
3232
}

tests/Unit/ExceptionConversion/GenericExceptionConverterTest.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ public function setUp(): void
2525
parent::setUp();
2626

2727
$this->converter = new GenericExceptionConverter(
28-
problemDetailsFactory: new ProblemDetailsFactory()
28+
problemDetailsFactory: new ProblemDetailsFactory(),
29+
environment: 'prod'
2930
);
3031
}
3132

tests/Unit/ServiceLoadingTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function testCreateValidResponse(): void
2525
$container = new ContainerBuilder();
2626
$loader = new YamlFileLoader($container, new FileLocator(__DIR__ . '/../../config'));
2727
$loader->load('services.yaml');
28+
$container->setParameter('kernel.environment', 'prod');
2829
$container->compile();
2930

3031
// Assert

0 commit comments

Comments
 (0)