@@ -19,36 +19,40 @@ class RawMessageTest extends TestCase
19
19
/**
20
20
* @dataProvider provideMessages
21
21
*/
22
- public function testToString ($ messageParameter )
22
+ public function testToString (mixed $ messageParameter, bool $ supportReuse )
23
23
{
24
24
$ message = new RawMessage ($ messageParameter );
25
25
$ this ->assertEquals ('some string ' , $ message ->toString ());
26
26
$ 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
+ }
30
33
}
31
34
32
- public static function provideMessages (): array
35
+ /**
36
+ * @dataProvider provideMessages
37
+ */
38
+ public function testSerialization (mixed $ messageParameter , bool $ supportReuse )
33
39
{
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
+ }
39
47
}
40
48
41
- public function testSerialization ()
49
+ public static function provideMessages (): array
42
50
{
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
+ ];
53
57
}
54
58
}
0 commit comments