-
Notifications
You must be signed in to change notification settings - Fork 1
Dummy pr #2129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dummy pr #2129
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,10 +43,28 @@ public function register(): void | |
| ) | ||
| ); | ||
|
|
||
| $container->addShared( | ||
| 'Dutch_' . StreetSuggester::class, | ||
| fn () => new CachedStreetSuggester( | ||
| new BPostStreetSuggester( | ||
| new Client(), | ||
| $container->get('config')['bpost']['doman'], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "doman" should be "domain" This typo will cause a configuration lookup failure. Line 34 correctly uses |
||
| $container->get('config')['bpost']['stage'], | ||
| $container->get('config')['bpost']['token'], | ||
| ), | ||
| CacheFactory::create( | ||
| $container->get('app_cache'), | ||
| 'dutch_streets', | ||
| 86400 | ||
| ) | ||
| ) | ||
| ); | ||
|
|
||
| $container->addShared( | ||
| GetStreetRequestHandler::class, | ||
| fn () => new GetStreetRequestHandler( | ||
| $container->get(StreetSuggester::class) | ||
| $container->get(StreetSuggester::class), | ||
| $container->get('Dutch_' . StreetSuggester::class) | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,9 +16,12 @@ final class GetStreetRequestHandler implements RequestHandlerInterface | |
| { | ||
| private StreetSuggester $belgiumStreetSuggester; | ||
|
|
||
| public function __construct(StreetSuggester $belgiumStreetSuggester) | ||
| private StreetSuggester $dutchStreetSuggester; | ||
|
|
||
| public function __construct(StreetSuggester $belgiumStreetSuggester, StreetSuggester $duchtStreetSuggester) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "duchtStreetSuggester" should be "dutchStreetSuggester" Parameter name has a typo ("ducht" instead of "dutch"). While this technically works, it's inconsistent with the property name on line 19 and reduces code readability. |
||
| { | ||
| $this->belgiumStreetSuggester = $belgiumStreetSuggester; | ||
| $this->dutchStreetSuggester = $duchtStreetSuggester; | ||
| } | ||
|
|
||
| public function handle(ServerRequestInterface $request): ResponseInterface | ||
|
|
@@ -46,10 +49,20 @@ public function handle(ServerRequestInterface $request): ResponseInterface | |
| return new JsonResponse($content); | ||
| } | ||
|
|
||
| if ($countryCode === 'NL') { | ||
| $content = $this->dutchStreetSuggester->suggest( | ||
| $postalCode, | ||
| $locality, | ||
| $query, | ||
| $limit | ||
| ); | ||
| return new JsonResponse($content); | ||
| } | ||
|
|
||
| throw ApiProblem::queryParameterInvalidValue( | ||
| 'country', | ||
| $countryCode, | ||
| ['BE'] | ||
| ['BE', 'NLD'] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Inconsistency: Error message uses 'NLD' but code checks for 'NL' Line 52 checks The check should match the error message. Since ISO 3166-1 alpha-2 country code for Netherlands is 'NL', the error message should be |
||
| ); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,12 +20,15 @@ final class GetStreetRequestHandlerTest extends TestCase | |
|
|
||
| private StreetSuggester&MockObject $streetSuggester; | ||
|
|
||
| private StreetSuggester&MockObject $steetSuggester2; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Typo: "steetSuggester2" should be "streetSuggester2" Property name has a typo ("steet" instead of "street"). Consider using a more descriptive name like |
||
|
|
||
| private GetStreetRequestHandler $getStreetRequestHandler; | ||
|
|
||
| protected function setUp(): void | ||
| { | ||
| $this->streetSuggester = $this->createMock(StreetSuggester::class); | ||
| $this->getStreetRequestHandler = new GetStreetRequestHandler($this->streetSuggester); | ||
| $this->steetSuggester2 = $this->createMock(StreetSuggester::class); | ||
| $this->getStreetRequestHandler = new GetStreetRequestHandler($this->streetSuggester, $this->steetSuggester2); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing test coverage for NL country code The PR adds support for Dutch street suggestions (country code 'NL'), but there's no test case verifying this new functionality works correctly. You should add a test similar to |
||
| } | ||
|
|
||
| /** | ||
|
|
@@ -98,14 +101,14 @@ public function it_supports_limits(): void | |
| public function it_will_throw_on_unsupported_countries(): void | ||
| { | ||
| $request = (new Psr7RequestBuilder()) | ||
| ->withUriFromString('streets?country=NL&postalCode=1012AB&locality=Amsterdam&query=Maria') | ||
| ->withUriFromString('streets?country=DK&postalCode=1012AB&locality=Amsterdam&query=Maria') | ||
| ->build('GET'); | ||
|
|
||
| $this->streetSuggester->expects($this->never()) | ||
| ->method('suggest'); | ||
|
|
||
| $this->assertCallableThrowsApiProblem( | ||
| ApiProblem::queryParameterInvalidValue('country', 'NL', ['BE']), | ||
| ApiProblem::queryParameterInvalidValue('country', 'DK', ['BE', 'NLD']), | ||
| fn () => $this->getStreetRequestHandler->handle($request) | ||
| ); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Service registration not added to getProvidedServiceNames()
The new
'Dutch_' . StreetSuggester::classservice is registered but not declared in thegetProvidedServiceNames()method (lines 17-23). This could cause issues with service discovery or dependency management depending on how the container is configured.