forked from clue/php-sse-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncoderTest.php
More file actions
43 lines (34 loc) · 956 Bytes
/
Copy pathEncoderTest.php
File metadata and controls
43 lines (34 loc) · 956 Bytes
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
<?php
namespace Clue\React\Tests\Sse;
use Clue\React\Sse\Encoder;
class EncoderTest extends TestCase
{
private $encoder;
/**
* @before
*/
public function setUpEncoder()
{
$this->encoder = new Encoder();
}
public function testData()
{
$this->assertEquals("data: test\n", $this->encoder->encodeData('test'));
}
public function testDataMultiLine()
{
$this->assertEquals("data: first\ndata: second\n", $this->encoder->encodeData("first\nsecond"));
}
public function testDataEmpty()
{
$this->assertEquals("data: \n", $this->encoder->encodeData(""));
}
public function testComment()
{
$this->assertEquals(":welcome!\n", $this->encoder->encodeComment('welcome!'));
}
public function testMessage()
{
$this->assertEquals("id: 123\nevent: demo\ndata: test\n\n", $this->encoder->encodeMessage('test', 'demo', 123));
}
}