function testGetContentWholeByOffset() { $file = new FRSFile(); $file->file_location = dirname(__FILE__) . '/_fixtures/file_sample'; $content = $file->getContent(0, 100); $content .= $file->getContent(100, 100); $content .= $file->getContent(200, 100); $content .= $file->getContent(300, 100); $this->assertIdentical(file_get_contents(dirname(__FILE__) . '/_fixtures/file_sample'), $content); }
function testWithBigFile() { //$this->assertTrue(is_writeable($this->writePath), "$this->writePath should be writable"); $writeFile = fopen(PHP_BigFile::stream($this->writePath), 'wb'); $this->assertTrue($writeFile); $file = new FRSFile(); $file->file_location = $this->readPath; $fileSize = PHP_BigFile::getSize($this->readPath); $chunkSize = 8 * 1024 * 1024; $nbChunks = ceil($fileSize / $chunkSize); for ($i = 0; $i < $nbChunks; $i++) { $data = $file->getContent($i * $chunkSize, $chunkSize); $written = fwrite($writeFile, $data); $this->assertEqual(strlen($data), $written); } $this->assertIdentical(md5_file($this->readPath), md5_file($this->writePath)); }