/** * SRR files include both specialised SRR blocks alongside RAR blocks that * follow the RAR specification, apart from File blocks and certain Subblock * types lacking bodies. * * @dataProvider providerTestFixtures * @param string $filename sample srr filename * @param string $blocks expected list of valid blocks */ public function testStoresListOfAllValidBlocks($filename, $blocks) { $srr = new SrrInfo(); $srr->open($filename); $this->assertEmpty($srr->error, $srr->error); $blockList = $srr->getBlocks(); $this->assertEquals(count($blocks), count($blockList)); $this->assertEquals($blocks, $blockList); }
/** * 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"; } }