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
110110
111111 public function geocode (string $ value ) : self
112112 {
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 )));
115114 $ this ->results = cache ()->remember (
116115 "geocoder- {$ cacheKey }" ,
117116 config ('geocoder.cache-duraction ' , 0 ),
@@ -125,9 +124,9 @@ function () use ($value) {
125124
126125 public function reverse (float $ latitude , float $ longitude ) : self
127126 {
128- $ cacheId = str_slug ("{$ latitude }- {$ longitude }" );
127+ $ cacheKey = str_slug (strtolower ( urlencode ( "{$ latitude }- {$ longitude }" )) );
129128 $ this ->results = cache ()->remember (
130- "geocoder- {$ cacheId }" ,
129+ "geocoder- {$ cacheKey }" ,
131130 config ('geocoder.cache-duraction ' , 0 ),
132131 function () use ($ latitude , $ longitude ) {
133132 return collect ($ this ->aggregator ->reverse ($ latitude , $ longitude ));
Original file line number Diff line number Diff line change @@ -177,12 +177,13 @@ public function testGeocoder()
177177
178178 public function testCacheIsUsed ()
179179 {
180+ $ cacheKey = str_slug (strtolower (urlencode ('1600 Pennsylvania Ave., Washington, DC USA ' )));
181+
180182 $ result = app ('geocoder ' )->geocode ('1600 Pennsylvania Ave., Washington, DC USA ' )
181183 ->get ();
182- $ cacheKey = 'geocoder- ' . str_slug ('1600 Pennsylvania Ave., Washington, DC USA ' );
183184
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}" ));
186187 }
187188
188189 /**
@@ -266,4 +267,16 @@ public function testGetProviders()
266267 $ this ->assertTrue ($ providers ->has ('bing_maps ' ));
267268 $ this ->assertTrue ($ providers ->has ('google_maps ' ));
268269 }
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+ }
269282}
You can’t perform that action at this time.
0 commit comments