1
0
mirror of https://github.com/halaxa/json-machine.git synced 2025-07-16 12:06:23 +02:00
Files
json-machine/test/JsonMachineTest/StreamChunksTest.php
2023-11-26 22:07:06 +01:00

28 lines
645 B
PHP

<?php
declare(strict_types=1);
namespace JsonMachineTest;
use JsonMachine\Exception\InvalidArgumentException;
use JsonMachine\StreamChunks;
/**
* @covers \JsonMachine\StreamChunks
*/
class StreamChunksTest extends \PHPUnit_Framework_TestCase
{
public function testThrowsIfNoResource()
{
$this->expectException(InvalidArgumentException::class);
/* @phpstan-ignore-next-line */
new StreamChunks(false);
}
public function testGeneratorYieldsData()
{
$result = iterator_to_array(new StreamChunks(fopen('data://text/plain,test', 'r')));
$this->assertSame(['test'], $result);
}
}