1
0
mirror of https://github.com/danog/byte-stream.git synced 2024-11-30 04:19:23 +01:00
byte-stream/test/PipeTest.php
2018-10-03 17:37:23 +02:00

25 lines
547 B
PHP

<?php
namespace Amp\ByteStream\Test;
use Amp\ByteStream\IteratorStream;
use Amp\ByteStream\OutputBuffer;
use Amp\Iterator;
use Amp\PHPUnit\TestCase;
use function Amp\ByteStream\pipe;
use function Amp\Promise\wait;
class PipeTest extends TestCase
{
public function testPipe()
{
$stream = new IteratorStream(Iterator\fromIterable(["abc", "def"]));
$buffer = new OutputBuffer;
$this->assertSame(6, wait(pipe($stream, $buffer)));
$buffer->end();
$this->assertSame("abcdef", wait($buffer));
}
}