Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions tests/EventSourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Clue\React\EventSource\EventSource;
use PHPUnit\Framework\TestCase;
use React\Http\Io\ReadableBodyStream;
use React\Http\Message\Response;
use React\Promise\Deferred;
use React\Promise\Promise;
Expand Down Expand Up @@ -286,7 +285,7 @@ public function testConstructorWillReportOpenWhenGetResponseResolvesWithValidRes
});

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

$messages = [];
Expand Down