Esempio n. 1
0
 /**
  * 7z files consist of headers at the archive start and end, with the blocks
  * of packed data streams between. We should be abe to report an accurate list
  * of all headers in summmary form.
  *
  * @dataProvider  providerTestFixtures
  * @param  string  $filename  sample 7z filename
  * @param  string  $headers   expected list of valid headers
  */
 public function testStoresListOfAllValidHeaders($filename, $headers)
 {
     $szip = new SzipInfo();
     $szip->open($filename, true);
     $this->assertEmpty($szip->error, $szip->error);
     $headerList = $szip->getHeaders(true);
     $this->assertEquals(count($headers), count($headerList));
     $this->assertEquals($headers, $headerList);
 }
Esempio n. 2
0
/**
 * Generates test fixtures from 7z sample files.
 *
 * @param   boolean  $pretend  debug output only?
 * @param   boolean  $refresh  regenerate existing files?
 * @return  void
 */
function makeSzipFixtures($pretend = false, $refresh = true)
{
    $szip = new SzipInfo();
    foreach (glob(dirname(__FILE__) . '/szip/*.{7z,001,002}', GLOB_BRACE) as $szipfile) {
        $fname = pathinfo($szipfile, PATHINFO_BASENAME) . '.headers';
        $file = dirname(__FILE__) . "/szip/{$fname}";
        if (!$refresh && file_exists($file)) {
            continue;
        }
        echo "Generating for {$szipfile}:\n";
        $szip->open($szipfile, true);
        if ($szip->error) {
            echo "Error: {$szip->error}\n";
            continue;
        }
        $data = $szip->getHeaders();
        if (!$pretend) {
            $data = "<?php\nreturn " . var_export($data, true) . ";\n";
            file_put_contents($file, $data);
        }
        echo "-- {$fname}\n";
    }
}