StreamChunksTest.php 645 B

123456789101112131415161718192021222324252627
  1. <?php
  2. declare(strict_types=1);
  3. namespace JsonMachineTest;
  4. use JsonMachine\Exception\InvalidArgumentException;
  5. use JsonMachine\StreamChunks;
  6. /**
  7. * @covers \JsonMachine\StreamChunks
  8. */
  9. class StreamChunksTest extends \PHPUnit_Framework_TestCase
  10. {
  11. public function testThrowsIfNoResource()
  12. {
  13. $this->expectException(InvalidArgumentException::class);
  14. /* @phpstan-ignore-next-line */
  15. new StreamChunks(false);
  16. }
  17. public function testGeneratorYieldsData()
  18. {
  19. $result = iterator_to_array(new StreamChunks(fopen('data://text/plain,test', 'r')));
  20. $this->assertSame(['test'], $result);
  21. }
  22. }