pantr::silent(function () use(&$self) { pantr::rm($self->peardir); }); }); // preparation $self->peardir = __DIR__ . '/../../../tmp/pear'; pantr::silent(function () use(&$self) { pantr::mkdirs($self->peardir); }); $self->peardir = realpath($self->peardir); $self->repo = new Repository($self->peardir); $self->repo->create(); it('should create a new repository if there is none', function ($self) { // in case it has already been created we just delete it pantr::silent(function () use($self) { pantr::rm($self->peardir); pantr::mkdirs($self->peardir); }); theFile($self->peardir . '/.pearrc')->shouldNotExist(); $repo = new Repository($self->peardir); theValueOf($repo->exists())->shouldBe(false); $repo->create(); theValueOf($repo->exists())->shouldBeTrue(); theFile($self->peardir . '/.pearrc')->shouldExist(); }); it('should discover a channel', function ($self) { $discovery = function () use($self) { $self->repo->discoverChannel('pear.pagosoft.com'); }; evaluating($discovery)->shouldProduceOutput("Adding Channel \"pear.pagosoft.com\" succeeded\n" . "Discovery of channel \"pear.pagosoft.com\" succeeded\n"); });
public static function rm($arg, $target_dir = '', $recursive = null) { if (!is_string($target_dir) && is_null($recursive)) { $recursive = $target_dir; $target_dir = ''; } $files = array_reverse(pantr::_getFinderFromArg($arg, $target_dir)); foreach ($files as $target) { if (!file_exists($target)) { pantr::writeAction('rm', $target . ' does not exist', pantr::INFO); return; } if (is_dir($target) && !is_link($target)) { // remove all files pantr::rm(pantr::fileset()->in($target)); // and now all empty directories pantr::rm(pantr::finder(self::TYPE_DIR)->in($target)); pantr::writeAction('rm', $target); rmdir($target); } else { pantr::writeAction('rm', $target); unlink($target); } } }