ServerSentEventsTest.php 451 B

123456789101112131415
  1. <?php
  2. use Workerman\Protocols\Http\ServerSentEvents;
  3. it('tests ' . ServerSentEvents::class, function () {
  4. $data = [
  5. 'event' => 'ping',
  6. 'data' => 'some thing',
  7. 'id' => 1000,
  8. 'retry' => 5000,
  9. ];
  10. $sse = new ServerSentEvents($data);
  11. $expected = "event: {$data['event']}\nid: {$data['id']}\nretry: {$data['retry']}\ndata: {$data['data']}\n\n";
  12. expect((string)$sse)->toBe($expected);
  13. });