@@ -19,36 +19,40 @@ class RawMessageTest extends TestCase
1919/**
2020 * @dataProvider provideMessages
2121 */
22- public function testToString ($ messageParameter )
22+ public function testToString (mixed $ messageParameter, bool $ supportReuse )
2323 {
2424$ message =new RawMessage ($ messageParameter );
2525$ this ->assertEquals ('some string ' ,$ message ->toString ());
2626$ this ->assertEquals ('some string ' ,implode ('' ,iterator_to_array ($ message ->toIterable ())));
27- // calling methods more than once work
28- $ this ->assertEquals ('some string ' ,$ message ->toString ());
29- $ this ->assertEquals ('some string ' ,implode ('' ,iterator_to_array ($ message ->toIterable ())));
27+
28+ if ($ supportReuse ) {
29+ // calling methods more than once work
30+ $ this ->assertEquals ('some string ' ,$ message ->toString ());
31+ $ this ->assertEquals ('some string ' ,implode ('' ,iterator_to_array ($ message ->toIterable ())));
32+ }
3033 }
3134
32- public static function provideMessages ():array
35+ /**
36+ * @dataProvider provideMessages
37+ */
38+ public function testSerialization (mixed $ messageParameter ,bool $ supportReuse )
3339 {
34- return [
35- 'string ' => ['some string ' ],
36- 'traversable ' => [new \ArrayObject (['some ' ,' ' ,'string ' ])],
37- 'array ' => [['some ' ,' ' ,'string ' ]],
38- ];
40+ $ message =new RawMessage ($ messageParameter );
41+ $ this ->assertEquals ('some string ' ,unserialize (serialize ($ message ))->toString ());
42+
43+ if ($ supportReuse ) {
44+ // calling methods more than once work
45+ $ this ->assertEquals ('some string ' ,unserialize (serialize ($ message ))->toString ());
46+ }
3947 }
4048
41- public function testSerialization ()
49+ public static function provideMessages (): array
4250 {
43- $ message =new RawMessage ('string ' );
44- $ this ->assertEquals ('string ' ,unserialize (serialize ($ message ))->toString ());
45- // calling methods more than once work
46- $ this ->assertEquals ('string ' ,unserialize (serialize ($ message ))->toString ());
47-
48- $ message =new RawMessage (new \ArrayObject (['some ' ,' ' ,'string ' ]));
49- $ message =new RawMessage ($ message ->toIterable ());
50- $ this ->assertEquals ('some string ' ,unserialize (serialize ($ message ))->toString ());
51- // calling methods more than once work
52- $ this ->assertEquals ('some string ' ,unserialize (serialize ($ message ))->toString ());
51+ return [
52+ 'string ' => ['some string ' ,true ],
53+ 'traversable ' => [new \ArrayObject (['some ' ,' ' ,'string ' ]),true ],
54+ 'array ' => [['some ' ,' ' ,'string ' ],true ],
55+ 'generator ' => [(function () {yield 'some ' ;yield ' ' ;yield 'string ' ; })(),false ],
56+ ];
5357 }
5458}