File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed
tests/Laravel5_3/Providers Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,7 @@ public function getName() : string
110
110
111
111
public function geocode (string $ value ) : self
112
112
{
113
- #https://stackoverflow.com/questions/22112029/strslug-alternative-for-hindi-and-arabic-strings?noredirect=1&lq=1
114
- $ cacheKey = (empty (str_slug ($ value )))?urlencode ($ value ):str_slug ($ value );
113
+ $ cacheKey = str_slug (strtolower (urlencode ($ value )));
115
114
$ this ->results = cache ()->remember (
116
115
"geocoder- {$ cacheKey }" ,
117
116
config ('geocoder.cache-duraction ' , 0 ),
@@ -125,9 +124,9 @@ function () use ($value) {
125
124
126
125
public function reverse (float $ latitude , float $ longitude ) : self
127
126
{
128
- $ cacheId = str_slug ("{$ latitude }- {$ longitude }" );
127
+ $ cacheKey = str_slug (strtolower ( urlencode ( "{$ latitude }- {$ longitude }" )) );
129
128
$ this ->results = cache ()->remember (
130
- "geocoder- {$ cacheId }" ,
129
+ "geocoder- {$ cacheKey }" ,
131
130
config ('geocoder.cache-duraction ' , 0 ),
132
131
function () use ($ latitude , $ longitude ) {
133
132
return collect ($ this ->aggregator ->reverse ($ latitude , $ longitude ));
Original file line number Diff line number Diff line change @@ -177,12 +177,13 @@ public function testGeocoder()
177
177
178
178
public function testCacheIsUsed ()
179
179
{
180
+ $ cacheKey = str_slug (strtolower (urlencode ('1600 Pennsylvania Ave., Washington, DC USA ' )));
181
+
180
182
$ result = app ('geocoder ' )->geocode ('1600 Pennsylvania Ave., Washington, DC USA ' )
181
183
->get ();
182
- $ cacheKey = 'geocoder- ' . str_slug ('1600 Pennsylvania Ave., Washington, DC USA ' );
183
184
184
- $ this ->assertTrue (cache ()->has ($ cacheKey ));
185
- $ this ->assertEquals ($ result , cache ($ cacheKey ));
185
+ $ this ->assertTrue (cache ()->has (" geocoder- { $ cacheKey}" ));
186
+ $ this ->assertEquals ($ result , cache (" geocoder- { $ cacheKey}" ));
186
187
}
187
188
188
189
/**
@@ -266,4 +267,16 @@ public function testGetProviders()
266
267
$ this ->assertTrue ($ providers ->has ('bing_maps ' ));
267
268
$ this ->assertTrue ($ providers ->has ('google_maps ' ));
268
269
}
270
+
271
+
272
+ public function testJapaneseCharacterGeocoding ()
273
+ {
274
+ $ cacheKey = str_slug (strtolower (urlencode ('108-0075 東京都港区港南2丁目16-3 ' )));
275
+
276
+ app ('geocoder ' )->geocode ('108-0075 東京都港区港南2丁目16-3 ' )
277
+ ->get ();
278
+
279
+ $ this ->assertEquals ($ cacheKey , '108-0075e69db1e4baace983bde6b8afe58cbae6b8afe58d97efbc92e4b881e79baeefbc91efbc96efbc8defbc93 ' );
280
+ $ this ->assertTrue (cache ()->has ("geocoder- {$ cacheKey }" ));
281
+ }
269
282
}
You can’t perform that action at this time.
0 commit comments