File tree 2 files changed +18
-7
lines changed
tests/Laravel5_3/Providers
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)
74
74
*/
75
75
public function geocode ($ value )
76
76
{
77
- $ cacheId = str_slug ($ value );
77
+ $ cacheKey = str_slug (strtolower ( urlencode ( $ value)) );
78
78
$ this ->results = cache ()->remember (
79
- "geocoder- {$ cacheId }" ,
79
+ "geocoder- {$ cacheKey }" ,
80
80
config ('geocoder.cache-duraction ' , 0 ),
81
81
function () use ($ value ) {
82
82
return parent ::geocode ($ value );
@@ -101,9 +101,9 @@ public function get()
101
101
*/
102
102
public function reverse ($ latitude , $ longitude )
103
103
{
104
- $ cacheId = str_slug ("{$ latitude }- {$ longitude }" );
104
+ $ cacheKey = str_slug (strtolower ( urlencode ( "{$ latitude }- {$ longitude }" )) );
105
105
$ this ->results = cache ()->remember (
106
- "geocoder- {$ cacheId }" ,
106
+ "geocoder- {$ cacheKey }" ,
107
107
config ('geocoder.cache-duraction ' , 0 ),
108
108
function () use ($ latitude , $ longitude ) {
109
109
return parent ::reverse ($ latitude , $ longitude );
Original file line number Diff line number Diff line change @@ -178,9 +178,20 @@ public function testCacheIsUsed()
178
178
{
179
179
$ result = app ('geocoder ' )->geocode ('1600 Pennsylvania Ave., Washington, DC USA ' )
180
180
->get ();
181
- $ cacheKey = ' geocoder- ' . str_slug ('1600 Pennsylvania Ave., Washington, DC USA ' );
181
+ $ cacheKey = str_slug (strtolower ( urlencode ( '1600 Pennsylvania Ave., Washington, DC USA ' )) );
182
182
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 }" ));
185
196
}
186
197
}
You can’t perform that action at this time.
0 commit comments