forked from clue/reactphp-eventsource
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageEventTest.php
More file actions
58 lines (42 loc) · 1.58 KB
/
Copy pathMessageEventTest.php
File metadata and controls
58 lines (42 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
namespace Clue\Tests\React\EventSource;
use PHPUnit\Framework\TestCase;
use Clue\React\EventSource\MessageEvent;
class MessageEventTest extends TestCase
{
public function testParseSimpleData()
{
$message = MessageEvent::parse("data: hello");
$this->assertEquals('hello', $message->data);
}
public function testParseDataOverTwoLinesWillBeCombined()
{
$message = MessageEvent::parse("data: hello\ndata: world");
$this->assertEquals("hello\nworld", $message->data);
}
public function testParseDataOverTwoLinesWithCarrigeReturnsWillBeCombinedWithNewline()
{
$message = MessageEvent::parse("data: hello\rdata: world");
$this->assertEquals("hello\nworld", $message->data);
}
public function testParseDataOverTwoLinesWithCarrigeReturnsAndNewlinesWillBeCombinedWithNewline()
{
$message = MessageEvent::parse("data: hello\r\ndata: world");
$this->assertEquals("hello\nworld", $message->data);
}
public function testParseDataWithTrailingNewlineOverTwoLines()
{
$message = MessageEvent::parse("data: hello\ndata:");
$this->assertEquals("hello\n", $message->data);
}
public function testParseDataWithCarrigeReturnOverTwoLines()
{
$message = MessageEvent::parse("data: hello\rdata:");
$this->assertEquals("hello\n", $message->data);
}
public function testParseDataWithCarrigeReturnAndNewlineOverTwoLines()
{
$message = MessageEvent::parse("data: hello\r\ndata:");
$this->assertEquals("hello\n", $message->data);
}
}