예제 #1
0
/**
 * Generates test fixtures from PAR2 sample files.
 *
 * @param   boolean  $pretend  debug output only?
 * @param   boolean  $refresh  regenerate existing files?
 * @return  void
 */
function makePar2Fixtures($pretend = false, $refresh = true)
{
    $par2 = new Par2Info();
    foreach (glob(dirname(__FILE__) . '/par2/*.par2') as $par2file) {
        $fname = pathinfo($par2file, PATHINFO_BASENAME) . '.packets';
        $file = dirname(__FILE__) . "/par2/{$fname}";
        if (!$refresh && file_exists($file)) {
            continue;
        }
        echo "Generating for {$par2file}:\n";
        $par2->open($par2file);
        if ($par2->error) {
            echo "Error: {$par2->error}\n";
            continue;
        }
        $data = $par2->getPackets(true);
        if (!$pretend) {
            $data = "<?php\nreturn " . var_export($data, true) . ";\n";
            file_put_contents($file, $data);
        }
        echo "-- {$fname}\n";
    }
}
예제 #2
0
 /**
  * We should be able to report on the client used to create the PAR2 file.
  */
 public function testReportsClientInfo()
 {
     $par2 = new Par2Info();
     $par2->open($this->fixturesDir . '/testdata.par2');
     $this->assertSame('Created by QuickPar 0.4', $par2->client);
 }