render(true); $zipcontents = ob_get_contents(); ob_end_clean(); // for this version php needs to be compiled with --enable-zip if (function_exists('zip_open')) { // yes, I'd rather have used php://memory here, but ZipArchive::open() // complained that it could not open the stream in question $filename = tempnam(Pluf::f('tmp_folder', '/tmp'), __CLASS__.'.'); file_put_contents($filename, $zipcontents); $za = new ZipArchive(); $za->open($filename); $this->assertEquals(2, $za->numFiles); // 2009-07-06T22:06:27 - one second // (don't ask me why, seems to be some quirk in zipstream) $mtime = 1246910787 - 1; // foo $data = $za->statIndex(0); $this->assertEquals('foo', $data['name']); $this->assertEquals(12, $data['size']); $this->assertEquals($mtime, $data['mtime']); // bar/baz $data = $za->statIndex(1); $this->assertEquals('bar/baz', $data['name']); $this->assertEquals(12, $data['size']); $this->assertEquals($mtime, $data['mtime']); $za->close(); unlink($filename); } else { $wrapped_act = wordwrap( base64_encode($zipcontents), 32, "\n", true ); $wrapped_exp = wordwrap( base64_encode(file_get_contents(DATADIR . '/' . __CLASS__ . '/data.zip')), 32, "\n", true ); $this->assertEquals($wrapped_exp, $wrapped_act); } } }