Ejemplo n.º 1
0
 /**
  * Headers can be compressed or encrypted, and we should be able to use an
  * external client to extract these before further parsing.
  *
  * @depends testExtractsFilesWithExternalClient
  * @group   external
  */
 public function testExtractsEncodedHeadersWithExternalClient()
 {
     if (!($unzip = $this->getUnzipPath())) {
         $this->markTestSkipped();
     }
     $szip = new SzipInfo();
     // Compressed headers
     $file = $this->fixturesDir . '/store_method_enc_headers.7z';
     $szip->open($file);
     $this->assertEmpty($szip->error);
     $this->assertSame(1, $szip->blockCount);
     $this->assertEmpty($szip->getFileList());
     $szip->setExternalClient($unzip);
     $szip->open($file);
     $this->assertEmpty($szip->error);
     $this->assertSame(2, $szip->blockCount);
     $files = $szip->getFileList();
     $this->assertCount(2, $files);
     $file = $files[0];
     $this->assertSame('7zFormat.txt', $file['name']);
     $this->assertSame('32-7604', $file['range']);
     $file = $files[1];
     $this->assertSame('foo.txt', $file['name']);
     $this->assertSame('7605-7619', $file['range']);
     // Encrypted headers
     $file = $this->fixturesDir . '/encrypted_headers.7z';
     $szip->open($file);
     $this->assertNotEmpty($szip->error);
     $this->assertContains('password needed', $szip->error);
     $this->assertTrue($szip->isEncrypted);
     $this->assertSame(1, $szip->blockCount);
     $this->assertEmpty($szip->getFileList());
     $szip->setPassword('password');
     $szip->open($file);
     $this->assertEmpty($szip->error);
     $this->assertSame(1, $szip->blockCount);
     $files = $szip->getFilelist();
     $this->assertCount(1, $files);
     $file = $files[0];
     $this->assertSame('7zFormat.txt', $file['name']);
     $this->assertSame(7573, $file['size']);
     $this->assertSame('32-7615', $file['range']);
     $this->assertSame(1, $file['pass']);
     $this->assertSame(0, $file['compressed']);
 }