@@ -113,7 +113,9 @@ public function testJsonStreamerJsonLd(): void
113113 $ r = self ::createClient ()->request ('GET ' , '/json_stream_resources/1 ' , ['headers ' => ['accept ' => 'application/ld+json ' ]]);
114114 $ res = json_decode ($ r ->getBrowserKitResponse ()->getContent (), true );
115115 $ this ->assertIsInt ($ res ['views ' ]);
116- $ this ->assertIsFloat ($ res ['rating ' ]);
116+ // json-streamer only encodes with JSON_PRESERVE_ZERO_FRACTION since 8.1.4, so an integral
117+ // float decodes as int on lower versions
118+ $ this ->assertTrue (\is_int ($ res ['rating ' ]) || \is_float ($ res ['rating ' ]));
117119 $ this ->assertIsBool ($ res ['isFeatured ' ]);
118120 $ this ->assertIsString ($ res ['price ' ]);
119121 $ this ->assertEquals ('/json_stream_resources/1 ' , $ res ['@id ' ]);
@@ -170,7 +172,9 @@ public function testJsonStreamerJson(): void
170172 $ r = self ::createClient ()->request ('GET ' , '/json_stream_resources/1 ' , ['headers ' => ['accept ' => 'application/json ' ]]);
171173 $ res = json_decode ($ r ->getBrowserKitResponse ()->getContent (), true );
172174 $ this ->assertIsInt ($ res ['views ' ]);
173- $ this ->assertIsFloat ($ res ['rating ' ]);
175+ // json-streamer only encodes with JSON_PRESERVE_ZERO_FRACTION since 8.1.4, so an integral
176+ // float decodes as int on lower versions
177+ $ this ->assertTrue (\is_int ($ res ['rating ' ]) || \is_float ($ res ['rating ' ]));
174178 $ this ->assertIsBool ($ res ['isFeatured ' ]);
175179 $ this ->assertIsString ($ res ['price ' ]);
176180 $ this ->assertArrayNotHasKey ('@id ' , $ res );
@@ -227,7 +231,7 @@ public function testJsonStreamerWriteJsonLd(): void
227231 $ this ->assertResponseIsSuccessful ();
228232 $ this ->assertSame ('asd ' , $ res ['title ' ]);
229233 $ this ->assertSame (0 , $ res ['views ' ]);
230- $ this ->assertSame ( 0. 0 , $ res ['rating ' ]);
234+ $ this ->assertEquals ( 0 , $ res ['rating ' ]);
231235 $ this ->assertFalse ($ res ['isFeatured ' ]);
232236 $ this ->assertContains ($ res ['price ' ], ['0 ' , '0.00 ' ]); // Depends on DB
233237 $ this ->assertStringStartsWith ('/json_stream_resources/ ' , $ res ['@id ' ]);
@@ -276,7 +280,7 @@ public function testJsonStreamerWriteJson(): void
276280 $ this ->assertResponseIsSuccessful ();
277281 $ this ->assertSame ('asd ' , $ res ['title ' ]);
278282 $ this ->assertSame (0 , $ res ['views ' ]);
279- $ this ->assertSame ( 0. 0 , $ res ['rating ' ]);
283+ $ this ->assertEquals ( 0 , $ res ['rating ' ]);
280284 $ this ->assertFalse ($ res ['isFeatured ' ]);
281285 $ this ->assertContains ($ res ['price ' ], ['0 ' , '0.00 ' ]); // Depends on DB
282286 $ this ->assertArrayNotHasKey ('@id ' , $ res );
0 commit comments