2020-05-13 17:15:21 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Amp\Test\Stream;
|
|
|
|
|
2020-05-17 21:41:42 +02:00
|
|
|
use Amp\PHPUnit\AsyncTestCase;
|
2020-05-13 17:15:21 +02:00
|
|
|
use Amp\Stream;
|
|
|
|
|
2020-05-17 21:41:42 +02:00
|
|
|
class ToArrayTest extends AsyncTestCase
|
2020-05-13 17:15:21 +02:00
|
|
|
{
|
|
|
|
public function testNonEmpty()
|
|
|
|
{
|
2020-05-17 21:41:42 +02:00
|
|
|
$stream = Stream\fromIterable(["abc", "foo", "bar"], 5);
|
|
|
|
$this->assertSame(["abc", "foo", "bar"], yield Stream\toArray($stream));
|
2020-05-13 17:15:21 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testEmpty()
|
|
|
|
{
|
2020-05-17 21:41:42 +02:00
|
|
|
$stream = Stream\fromIterable([], 5);
|
|
|
|
$this->assertSame([], yield Stream\toArray($stream));
|
2020-05-13 17:15:21 +02:00
|
|
|
}
|
|
|
|
}
|