File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed
tests/Laravel5_3/Providers Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -74,9 +74,9 @@ public function dump($dumper)
7474 */
7575 public function geocode ($ value )
7676 {
77- $ cacheId = str_slug ($ value );
77+ $ cacheKey = str_slug (strtolower ( urlencode ( $ value)) );
7878 $ this ->results = cache ()->remember (
79- "geocoder- {$ cacheId }" ,
79+ "geocoder- {$ cacheKey }" ,
8080 config ('geocoder.cache-duraction ' , 0 ),
8181 function () use ($ value ) {
8282 return parent ::geocode ($ value );
@@ -101,9 +101,9 @@ public function get()
101101 */
102102 public function reverse ($ latitude , $ longitude )
103103 {
104- $ cacheId = str_slug ("{$ latitude }- {$ longitude }" );
104+ $ cacheKey = str_slug (strtolower ( urlencode ( "{$ latitude }- {$ longitude }" )) );
105105 $ this ->results = cache ()->remember (
106- "geocoder- {$ cacheId }" ,
106+ "geocoder- {$ cacheKey }" ,
107107 config ('geocoder.cache-duraction ' , 0 ),
108108 function () use ($ latitude , $ longitude ) {
109109 return parent ::reverse ($ latitude , $ longitude );
Original file line number Diff line number Diff line change @@ -178,9 +178,20 @@ public function testCacheIsUsed()
178178 {
179179 $ result = app ('geocoder ' )->geocode ('1600 Pennsylvania Ave., Washington, DC USA ' )
180180 ->get ();
181- $ cacheKey = ' geocoder- ' . str_slug ('1600 Pennsylvania Ave., Washington, DC USA ' );
181+ $ cacheKey = str_slug (strtolower ( urlencode ( '1600 Pennsylvania Ave., Washington, DC USA ' )) );
182182
183- $ this ->assertTrue (cache ()->has ($ cacheKey ));
184- $ this ->assertEquals ($ result , cache ($ cacheKey ));
183+ $ this ->assertEquals ($ result , cache ("geocoder- {$ cacheKey }" ));
184+ $ this ->assertTrue (cache ()->has ("geocoder- {$ cacheKey }" ));
185+ }
186+
187+ public function testJapaneseCharacterGeocoding ()
188+ {
189+ $ cacheKey = str_slug (strtolower (urlencode ('108-0075 東京都港区港南2丁目16-3 ' )));
190+
191+ app ('geocoder ' )->geocode ('108-0075 東京都港区港南2丁目16-3 ' )
192+ ->get ();
193+
194+ $ this ->assertEquals ($ cacheKey , '108-0075e69db1e4baace983bde6b8afe58cbae6b8afe58d97efbc92e4b881e79baeefbc91efbc96efbc8defbc93 ' );
195+ $ this ->assertTrue (cache ()->has ("geocoder- {$ cacheKey }" ));
185196 }
186197}
You can’t perform that action at this time.
0 commit comments