public function test_chunk_callback()
 {
     $file = __DIR__ . "/../../../xml/pubmed-example.xml";
     $chunkSize = 100;
     $callbackCount = 0;
     $stream = new File($file, 100, function ($buffer, $readBytes) use(&$callbackCount) {
         $callbackCount++;
     });
     $chunkCount = 0;
     while ($chunk = $stream->getChunk()) {
         $chunkCount++;
     }
     $this->assertEquals($callbackCount, $chunkCount, "Chunk callback count should be the same as getChunk count");
 }
Exemplo n.º 2
0
 public function __construct($chunkSize = 1024, $chunkCallback = null)
 {
     parent::__construct(fopen("php://stdin", "r"), $chunkSize, $chunkCallback);
 }