You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
1.6 KiB
71 lines
1.6 KiB
<?php |
|
|
|
namespace React\Tests\Stream; |
|
|
|
use React\Stream\ReadableStream; |
|
use React\Stream\WritableStream; |
|
|
|
/** |
|
* @covers React\Stream\WritableStream |
|
*/ |
|
class WritableStreamTest extends TestCase |
|
{ |
|
/** @test */ |
|
public function pipingStuffIntoItShouldWorkButDoNothing() |
|
{ |
|
$readable = new ReadableStream(); |
|
$through = new WritableStream(); |
|
|
|
$readable->pipe($through); |
|
$readable->emit('data', array('foo')); |
|
} |
|
|
|
/** @test */ |
|
public function endShouldCloseTheStream() |
|
{ |
|
$through = new WritableStream(); |
|
$through->on('data', $this->expectCallableNever()); |
|
$through->end(); |
|
|
|
$this->assertFalse($through->isWritable()); |
|
} |
|
|
|
/** @test */ |
|
public function endShouldWriteDataBeforeClosing() |
|
{ |
|
$through = $this->getMock('React\Stream\WritableStream', array('write')); |
|
$through |
|
->expects($this->once()) |
|
->method('write') |
|
->with('foo'); |
|
$through->end('foo'); |
|
|
|
$this->assertFalse($through->isWritable()); |
|
} |
|
|
|
/** @test */ |
|
public function itShouldBeWritableByDefault() |
|
{ |
|
$through = new WritableStream(); |
|
$this->assertTrue($through->isWritable()); |
|
} |
|
|
|
/** @test */ |
|
public function closeShouldClose() |
|
{ |
|
$through = new WritableStream(); |
|
$through->close(); |
|
|
|
$this->assertFalse($through->isWritable()); |
|
} |
|
|
|
/** @test */ |
|
public function doubleCloseShouldWork() |
|
{ |
|
$through = new WritableStream(); |
|
$through->close(); |
|
$through->close(); |
|
|
|
$this->assertFalse($through->isWritable()); |
|
} |
|
}
|
|
|