Skip to content

Commit db65d32

Browse files
committed
feat: add test for reading large files in stream with chunk size validation
1 parent 0ace6b9 commit db65d32

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

tests/Storage/S3Base.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,24 @@ public function testPartRead($path)
375375
$this->assertEquals($chunk, $readChunk);
376376
}
377377

378+
/**
379+
* @depends testPartUpload
380+
*/
381+
public function testReadStreamLargeFile($path)
382+
{
383+
$source = __DIR__.'/../resources/disk-a/large_file.mp4';
384+
$expectedSize = \filesize($source);
385+
386+
$totalRead = 0;
387+
foreach ($this->object->readStream($path) as $chunk) {
388+
$totalRead += strlen($chunk);
389+
// Each chunk should be <= 2MB
390+
$this->assertLessThanOrEqual(2 * 1024 * 1024, strlen($chunk));
391+
}
392+
393+
$this->assertEquals($expectedSize, $totalRead);
394+
}
395+
378396
/**
379397
* @depends testPartUpload
380398
*/
@@ -502,24 +520,6 @@ public function testReadStreamPartialMatchesRead()
502520
$this->assertEquals($readContent, $streamContent);
503521
}
504522

505-
/**
506-
* @depends testPartUpload
507-
*/
508-
public function testReadStreamLargeFile($path)
509-
{
510-
$source = __DIR__.'/../resources/disk-a/large_file.mp4';
511-
$expectedSize = \filesize($source);
512-
513-
$totalRead = 0;
514-
foreach ($this->object->readStream($path) as $chunk) {
515-
$totalRead += strlen($chunk);
516-
// Each chunk should be <= 2MB
517-
$this->assertLessThanOrEqual(2 * 1024 * 1024, strlen($chunk));
518-
}
519-
520-
$this->assertEquals($expectedSize, $totalRead);
521-
}
522-
523523
public function testTransferNonExistentFile()
524524
{
525525
$device = new Local(__DIR__.'/../resources/disk-a');

0 commit comments

Comments
 (0)