|
292 | 292 | Http::assertSent(fn ($request) => $request->header('User-Agent')[0] === 'ContainerBoundAgent/1.0'); |
293 | 293 | }); |
294 | 294 |
|
| 295 | +it('propagates locale via the fluent locale() method on geocode()', function () { |
| 296 | + app('geocoder') |
| 297 | + ->locale('it') |
| 298 | + ->geocode('1600 Pennsylvania Ave NW, Washington, DC 20500, USA') |
| 299 | + ->get(); |
| 300 | + |
| 301 | + Http::assertSent(fn ($request) => str_contains($request->url(), 'accept-language=it')); |
| 302 | +}); |
| 303 | + |
| 304 | +it('propagates locale via the fluent locale() method on reverse()', function () { |
| 305 | + app('geocoder') |
| 306 | + ->locale('fr') |
| 307 | + ->reverse(38.8791981, -76.9818437) |
| 308 | + ->get(); |
| 309 | + |
| 310 | + Http::assertSent(fn ($request) => |
| 311 | + str_contains($request->url(), '/reverse') |
| 312 | + && str_contains($request->url(), 'accept-language=fr') |
| 313 | + ); |
| 314 | +}); |
| 315 | + |
| 316 | +it('caches locale-scoped convenience-method results separately per locale', function () { |
| 317 | + app('geocoder')->locale('it')->geocode('Washington')->get(); |
| 318 | + app('geocoder')->locale('fr')->geocode('Washington')->get(); |
| 319 | + app('geocoder')->locale('it')->geocode('Washington')->get(); |
| 320 | + |
| 321 | + Http::assertSentCount(2); |
| 322 | +}); |
| 323 | + |
| 324 | +it('propagates locale from geocodeQuery to the provider and caches per-locale', function () { |
| 325 | + $italianQuery = GeocodeQuery::create('1600 Pennsylvania Ave NW, Washington, DC 20500, USA') |
| 326 | + ->withLocale('it'); |
| 327 | + $frenchQuery = GeocodeQuery::create('1600 Pennsylvania Ave NW, Washington, DC 20500, USA') |
| 328 | + ->withLocale('fr'); |
| 329 | + |
| 330 | + app('geocoder')->geocodeQuery($italianQuery)->get(); |
| 331 | + app('geocoder')->geocodeQuery($frenchQuery)->get(); |
| 332 | + app('geocoder')->geocodeQuery($italianQuery)->get(); |
| 333 | + |
| 334 | + Http::assertSent(fn ($request) => str_contains($request->url(), 'accept-language=it')); |
| 335 | + Http::assertSent(fn ($request) => str_contains($request->url(), 'accept-language=fr')); |
| 336 | + Http::assertSentCount(2); |
| 337 | +}); |
| 338 | + |
295 | 339 | it('does not collide reverse cache keys across coordinate signs', function () { |
296 | 340 | $providerName = app('geocoder')->getProvider()->getName(); |
297 | 341 | $negativeKey = sha1("{$providerName}-" . strtolower(urlencode('-45.473282--73.834721'))); |
|
0 commit comments