/** * Creates a new test archive. * * If a `$build` callback is not given, the default build will be used. * * @param callable $build The archive build callback. * * @return string The path to the test archive. */ protected function createArchive(callable $build = null) { $path = tempnam($this->dir, ''); unlink($path); $path .= '.phar'; $builder = new Builder($path); if (null === $build) { $builder->addEmptyDir('a'); $builder->addFromString('b/b', 'b'); $builder->addFromString('c/c/c', 'c'); $builder->addFromString('d/d/d/d', 'd'); $builder->addFromString('e', 'e'); $builder->resolvePath('c/c/c')->compress(Builder::BZ2); $builder->resolvePath('d/d/d/d')->compress(Builder::GZ); } else { $build($builder); } return $path; }
/** * Creates a new archive file for testing. * * @param callable $tweak Make tweaks to the archive. * * @return string The path the new archive file. */ protected function buildArchive(callable $tweak = null) { $file = tempnam(sys_get_temp_dir(), 'box-'); unlink($file); $this->paths[] = $file .= '.phar'; $builder = new Builder($file, 0, basename($file)); $builder->addFromString('a', 'a'); $builder->addFromString('b/b', ''); $builder->addFromString('c/c/c', 'c'); $builder->addEmptyDir('d/d/d/d'); if (null !== $tweak) { $tweak($builder); } $builder = null; return $file; }