|
16 | 16 |
|
17 | 17 | class RawMessageTest extends TestCase
|
18 | 18 | {
|
19 |
| - public function testToString() |
| 19 | + /** |
| 20 | + * @dataProvider provideMessages |
| 21 | + */ |
| 22 | + public function testToString($messageParameter) |
20 | 23 | {
|
21 |
| - $message = new RawMessage('string'); |
22 |
| - $this->assertEquals('string', $message->toString()); |
23 |
| - $this->assertEquals('string', implode('', iterator_to_array($message->toIterable()))); |
24 |
| - // calling methods more than once work |
25 |
| - $this->assertEquals('string', $message->toString()); |
26 |
| - $this->assertEquals('string', implode('', iterator_to_array($message->toIterable()))); |
27 |
| - |
28 |
| - $message = new RawMessage(new \ArrayObject(['some', ' ', 'string'])); |
| 24 | + $message = new RawMessage($messageParameter); |
29 | 25 | $this->assertEquals('some string', $message->toString());
|
30 | 26 | $this->assertEquals('some string', implode('', iterator_to_array($message->toIterable())));
|
31 | 27 | // calling methods more than once work
|
32 | 28 | $this->assertEquals('some string', $message->toString());
|
33 | 29 | $this->assertEquals('some string', implode('', iterator_to_array($message->toIterable())));
|
34 | 30 | }
|
35 | 31 |
|
| 32 | + public function provideMessages(): array |
| 33 | + { |
| 34 | + return [ |
| 35 | + 'string' => ['some string'], |
| 36 | + 'traversable' => [new \ArrayObject(['some', ' ', 'string'])], |
| 37 | + 'array' => [['some', ' ', 'string']], |
| 38 | + ]; |
| 39 | + } |
| 40 | + |
36 | 41 | public function testSerialization()
|
37 | 42 | {
|
38 | 43 | $message = new RawMessage('string');
|
|
0 commit comments