Skip to content

Commit 298a77c

Browse files
authored
Merge pull request #48 from clue-labs/update-tests
Update tests to avoid using internal classes from reactphp/http
2 parents d32f54d + 9806d88 commit 298a77c

File tree

1 file changed

+19
-20
lines changed

1 file changed

+19
-20
lines changed

tests/EventSourceTest.php

+19-20
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Clue\React\EventSource\EventSource;
66
use PHPUnit\Framework\TestCase;
7-
use React\Http\Io\ReadableBodyStream;
87
use React\Http\Message\Response;
98
use React\Promise\Deferred;
109
use React\Promise\Promise;
@@ -286,7 +285,7 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes
286285
});
287286

288287
$stream = new ThroughStream();
289-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
288+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
290289
$deferred->resolve($response);
291290

292291
$this->assertEquals(EventSource::OPEN, $readyState);
@@ -307,7 +306,7 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes
307306
});
308307

309308
$stream = new ThroughStream();
310-
$response = new Response(200, array('CONTENT-type' => 'TEXT/Event-Stream'), new ReadableBodyStream($stream));
309+
$response = new Response(200, array('CONTENT-type' => 'TEXT/Event-Stream'), $stream);
311310
$deferred->resolve($response);
312311

313312
$this->assertEquals(EventSource::OPEN, $readyState);
@@ -328,7 +327,7 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes
328327
});
329328

330329
$stream = new ThroughStream();
331-
$response = new Response(200, array('Content-Type' => 'text/event-stream;charset=utf-8;foo=bar'), new ReadableBodyStream($stream));
330+
$response = new Response(200, array('Content-Type' => 'text/event-stream;charset=utf-8;foo=bar'), $stream);
332331
$deferred->resolve($response);
333332

334333
$this->assertEquals(EventSource::OPEN, $readyState);
@@ -350,7 +349,7 @@ public function testCloseResponseStreamWillStartRetryTimerWithErrorEvent()
350349
$es = new EventSource('http://example.com', $browser, $loop);
351350

352351
$stream = new ThroughStream();
353-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
352+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
354353
$deferred->resolve($response);
355354

356355
$error = null;
@@ -378,7 +377,7 @@ public function testCloseResponseStreamWillNotStartRetryTimerWhenEventSourceIsCl
378377
$es = new EventSource('http://example.com', $browser, $loop);
379378

380379
$stream = new ThroughStream();
381-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
380+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
382381
$deferred->resolve($response);
383382

384383
$es->on('error', function ($e) use ($es) {
@@ -404,7 +403,7 @@ public function testCloseFromOpenEventWillCloseResponseStreamAndCloseEventSource
404403
});
405404

406405
$stream = new ThroughStream();
407-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
406+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
408407
$deferred->resolve($response);
409408

410409
$this->assertEquals(EventSource::CLOSED, $es->readyState);
@@ -421,7 +420,7 @@ public function testEmitMessageWithParsedDataFromEventStream()
421420
$es = new EventSource('http://example.com', $browser);
422421

423422
$stream = new ThroughStream();
424-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
423+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
425424
$deferred->resolve($response);
426425

427426
$message = null;
@@ -446,7 +445,7 @@ public function testEmitMessageWithParsedIdAndDataOverMultipleRowsFromEventStrea
446445
$es = new EventSource('http://example.com', $browser);
447446

448447
$stream = new ThroughStream();
449-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
448+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
450449
$deferred->resolve($response);
451450

452451
$message = null;
@@ -471,7 +470,7 @@ public function testEmitMessageWithParsedEventTypeAndDataWithTrailingWhitespaceF
471470
$es = new EventSource('http://example.com', $browser);
472471

473472
$stream = new ThroughStream();
474-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
473+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
475474
$deferred->resolve($response);
476475

477476
$message = null;
@@ -495,7 +494,7 @@ public function testDoesNotEmitMessageWhenParsedEventStreamHasNoData()
495494
$es = new EventSource('http://example.com', $browser);
496495

497496
$stream = new ThroughStream();
498-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
497+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
499498
$deferred->resolve($response);
500499

501500
$message = null;
@@ -518,7 +517,7 @@ public function testEmitMessageWithParsedDataAndPreviousIdWhenNotGivenAgainFromE
518517
$es = new EventSource('http://example.com', $browser);
519518

520519
$stream = new ThroughStream();
521-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
520+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
522521
$deferred->resolve($response);
523522

524523
$message = null;
@@ -543,7 +542,7 @@ public function testEmitMessageOnceWhenCallingCloseFromMessageHandlerFromEventSt
543542
$es = new EventSource('http://example.com', $browser);
544543

545544
$stream = new ThroughStream();
546-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
545+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
547546
$deferred->resolve($response);
548547

549548
$message = null;
@@ -589,7 +588,7 @@ public function testReconnectAfterStreamClosesUsesLastEventIdFromParsedEventStre
589588
$es = new EventSource('http://example.com', $browser, $loop);
590589

591590
$stream = new ThroughStream();
592-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
591+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
593592
$deferred->resolve($response);
594593

595594
$stream->write("id:123\n\n");
@@ -625,7 +624,7 @@ public function testReconnectAfterStreamClosesUsesSpecifiedRetryTime()
625624
$es = new EventSource('http://example.com', $browser, $loop);
626625

627626
$stream = new ThroughStream();
628-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
627+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
629628
$deferred->resolve($response);
630629

631630
$stream->write("retry:2543\n\n");
@@ -661,7 +660,7 @@ public function testReconnectAfterStreamClosesIgnoresInvalidRetryTime()
661660
$es = new EventSource('http://example.com', $browser, $loop);
662661

663662
$stream = new ThroughStream();
664-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
663+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
665664
$deferred->resolve($response);
666665

667666
$stream->write("retry:now\n\n");
@@ -698,7 +697,7 @@ public function testSplitMessagesWithCarriageReturn()
698697
$es = new EventSource('http://example.com', $browser);
699698

700699
$stream = new ThroughStream();
701-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
700+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
702701
$deferred->resolve($response);
703702

704703
$messages = [];
@@ -726,7 +725,7 @@ public function testSplitMessagesWithWindowsEndOfLineSequence()
726725
$es = new EventSource('http://example.com', $browser);
727726

728727
$stream = new ThroughStream();
729-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
728+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
730729
$deferred->resolve($response);
731730

732731
$messages = [];
@@ -754,7 +753,7 @@ public function testSplitMessagesWithBufferedWindowsEndOfLineSequence()
754753
$es = new EventSource('http://example.com', $browser);
755754

756755
$stream = new ThroughStream();
757-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
756+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
758757
$deferred->resolve($response);
759758

760759
$messages = [];
@@ -783,7 +782,7 @@ public function testSplitMessagesWithMixedEndOfLine()
783782
$es = new EventSource('http://example.com', $browser);
784783

785784
$stream = new ThroughStream();
786-
$response = new Response(200, array('Content-Type' => 'text/event-stream'), new ReadableBodyStream($stream));
785+
$response = new Response(200, array('Content-Type' => 'text/event-stream'), $stream);
787786
$deferred->resolve($response);
788787

789788
$messages = [];

0 commit comments

Comments
 (0)