@@ -117,7 +117,7 @@ public function dataCache()
117
117
'json ' ,
118
118
'json/syllable.en-us.json ' ,
119
119
'{ ' .
120
- '"version":1.4, ' .
120
+ '"version":" 1.4" , ' .
121
121
'"patterns":{%a}, ' .
122
122
'"max_pattern":9, ' .
123
123
'"hyphenation":{%a}, ' .
@@ -131,7 +131,7 @@ public function dataCache()
131
131
'serialized ' ,
132
132
'serialized/syllable.en-us.serialized ' ,
133
133
'a:6:{ ' .
134
- 's:7:"version";d: 1.4; ' .
134
+ 's:7:"version";s:3:" 1.4" ; ' .
135
135
's:8:"patterns";a:4939:{%a} ' .
136
136
's:11:"max_pattern";i:9; ' .
137
137
's:11:"hyphenation";a:15:{%a} ' .
@@ -169,14 +169,41 @@ public function testCache($cacheClass, $language, $cacheDirectory, $cacheFile, $
169
169
170
170
$ this ->assertFileExists ($ cacheFile );
171
171
$ this ->assertStringMatchesFormat ($ expectedCacheContent , file_get_contents ($ cacheFile ));
172
- $ this ->assertSame (1.4 , $ this ->object ->getCache ()->__get ('version ' ));
172
+ $ this ->assertSame (' 1.4 ' , $ this ->object ->getCache ()->__get ('version ' ));
173
173
$ this ->assertNotEmpty ($ this ->object ->getCache ()->__get ('patterns ' ));
174
174
$ this ->assertGreaterThan (0 , $ this ->object ->getCache ()->__get ('max_pattern ' ));
175
175
$ this ->assertNotEmpty ($ this ->object ->getCache ()->__get ('hyphenation ' ));
176
176
$ this ->assertInternalType ('int ' , $ this ->object ->getCache ()->__get ('left_min_hyphen ' ));
177
177
$ this ->assertInternalType ('int ' , $ this ->object ->getCache ()->__get ('right_min_hyphen ' ));
178
178
}
179
179
180
+ public function dataCacheVersionMatchesCacheFileVersionIsRelaxed ()
181
+ {
182
+ return [
183
+ 'Cache file version is float. ' => [1.4 ],
184
+ 'Cache file version is string. ' => ['1.4 ' ],
185
+ 'Cache file version is float with unexpected precision. ' => [1.3999999999999999 ],
186
+ 'Cache file version is string with unexpected precision. ' => ['1.3999999999999999 ' ],
187
+ ];
188
+ }
189
+
190
+ /**
191
+ * Some PHP versions have the Syllable cache version number 1.4 encoded in 1.39999999999999
192
+ * instead of 1.4 in the cache files. To fix this, the internal representation of
193
+ * the cache version is changed from float to string. This test shows that the user's existing
194
+ * cache files are still valid after this change and do not need to be recreated.
195
+ *
196
+ * @dataProvider dataCacheVersionMatchesCacheFileVersionIsRelaxed
197
+ *
198
+ * @return void
199
+ */
200
+ public function testCacheVersionMatchesCacheFileVersionIsRelaxed ($ cacheFileVersion )
201
+ {
202
+ $ cacheVersion = '1.4 ' ;
203
+
204
+ $ this ->assertTrue ($ cacheVersion == $ cacheFileVersion );
205
+ }
206
+
180
207
/**
181
208
* @todo Implement testSetSource().
182
209
*/
0 commit comments