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

25 lines
547 B
PHP
Raw Normal View History

2018-09-23 21:30:08 +02:00
<?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));
}
}