Пример #1
0
/**
 * Generates test fixtures from SRR sample files.
 *
 * @param   boolean  $pretend  debug output only?
 * @param   boolean  $refresh  regenerate existing files?
 * @return  void
 */
function makeSrrFixtures($pretend = false, $refresh = true)
{
    $srr = new SrrInfo();
    foreach (glob(dirname(__FILE__) . '/srr/*.srr') as $srrfile) {
        $fname = pathinfo($srrfile, PATHINFO_BASENAME) . '.blocks';
        $file = dirname(__FILE__) . "/srr/{$fname}";
        if (!$refresh && file_exists($file)) {
            continue;
        }
        echo "Generating for {$srrfile}:\n";
        $srr->open($srrfile);
        if ($srr->error) {
            echo "Error: {$srr->error}\n";
            continue;
        }
        $data = $srr->getBlocks();
        if (!$pretend) {
            $data = "<?php\nreturn " . var_export($data, true) . ";\n";
            file_put_contents($file, $data);
        }
        echo "-- {$fname}\n";
    }
}
Пример #2
0
 /**
  * SRR files should not contain any file data in the File blocks, but we
  * should fail to read it gracefully.
  */
 public function testFileDataCannotBeExtracted()
 {
     $srr = new SrrInfo();
     $srr->open($this->fixturesDir . '/store_rr_solid_auth.part1.srr');
     $this->assertFalse($srr->getFileData('users_manual4.00.txt'));
     foreach ($srr->getFileList() as $vol) {
         foreach ($vol['files'] as $file) {
             $this->assertArrayNotHasKey('range', $file);
         }
     }
 }