Ejemplo n.º 1
0
 /**
  * If the archive files aren't compressed, we should just be able to extract
  * the file data and use it as is.
  *
  * @depends testListsPackedRangesWithPartialData
  */
 public function testExtractsUncompressedFileData()
 {
     $szip = new SzipInfo();
     // With all data available
     $szip->open($this->fixturesDir . '/store_method.7z');
     $this->assertEmpty($szip->error);
     $files = $szip->getFileList();
     $this->assertCount(2, $files);
     $this->assertSame('7zFormat.txt', $files[0]['name']);
     $this->assertSame(0, $files[0]['compressed']);
     $data = $szip->getFileData($files[0]['name']);
     $this->assertSame($files[0]['size'], strlen($data));
     $this->assertSame($files[0]['crc32'], dechex(crc32($data)));
     $this->assertStringStartsWith('7z Format description', $data);
     $this->assertStringEndsWith("End of document\r\n", $data);
     $this->assertSame('foo.txt', $files[1]['name']);
     $this->assertSame(0, $files[1]['compressed']);
     $data = $szip->getFileData($files[1]['name']);
     $this->assertSame($files[1]['size'], strlen($data));
     $this->assertSame($files[1]['crc32'], dechex(crc32($data)));
     $this->assertSame('sample foo text', $data);
     // With partial data available
     $szip->open($this->fixturesDir . '/multi_volume.7z.002', true);
     $this->assertEmpty($szip->error);
     $files = $szip->getFileList();
     $this->assertCount(2, $files);
     $this->assertSame('7zFormat.txt', $files[0]['name']);
     $this->assertSame(0, $files[0]['compressed']);
     $data = $szip->getFileData($files[0]['name']);
     $this->assertNotSame($files[0]['size'], strlen($data));
     $this->assertStringStartsWith('odecIdSize', $data);
     $this->assertStringEndsWith("End of document\r\n", $data);
 }