File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 214214});
215215
216216it ('serializes big integers correctly ' , function (): void {
217- $ bigInt = 9007199254740993 ;
217+ $ bigInt = 9007199254740993 ; // Greater than JavaScript's MAX_SAFE_INTEGER
218218 $ result = JavaScriptSerializer::serializeValue ($ bigInt );
219219
220220 expect ($ result )->toHaveKey ('bi ' );
227227
228228 expect ($ result )->toBe ('9007199254740993 ' );
229229});
230+
231+ it ('serializes resources as strings (fallback) ' , function (): void {
232+ $ resource = fopen ('php://memory ' , 'r ' );
233+ $ result = JavaScriptSerializer::serializeValue ($ resource );
234+
235+ expect ($ result )->toHaveKey ('s ' );
236+ expect ($ result ['s ' ])->toBeString ();
237+ expect ($ result ['s ' ])->toContain ('Resource ' );
238+
239+ fclose ($ resource );
240+ });
241+
242+ it ('parses values that are not arrays as-is ' , function (): void {
243+ expect (JavaScriptSerializer::parseValue ('plain string ' ))->toBe ('plain string ' );
244+ expect (JavaScriptSerializer::parseValue (42 ))->toBe (42 );
245+ expect (JavaScriptSerializer::parseValue (true ))->toBeTrue ();
246+ expect (JavaScriptSerializer::parseValue (null ))->toBeNull ();
247+ });
You can’t perform that action at this time.
0 commit comments