use pantr\pantr; // try to load pearfarm $tryLoad = function () { foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) { $dir = $path . DIRECTORY_SEPARATOR . 'pearfarm/src/Pearfarm'; if (file_exists($dir)) { $classes = array('ITask', 'PackageSpec', 'Task' . DIRECTORY_SEPARATOR . 'Push'); foreach ($classes as $class) { require_once $dir . DIRECTORY_SEPARATOR . $class . '.php'; } } } }; $tryLoad(); if (!class_exists('Pearfarm_PackageSpec')) { // try to install it now pantr::silent(function () { $repo = pantr::getRepository(); if (!$repo->hasChannel('pearfarm')) { $repo->discoverChannel('pearfarm.pearfarm.org'); } $repo->install('pearfarm/pearfarm'); $tryLoad(); }); if (!class_exists('Pearfarm_PackageSpec')) { throw new \Exception('Pearfarm is not installed!'); } else { pantr::writeAction('install', 'Pearfarm'); } }
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"); }); it('should install a package', function ($self) {
$sync->sync(); }); theFile($self->peardir . '/pgs')->shouldExist(); $pkgs = $self->repo->listAllPackages(); theValueOf($pkgs['pear.pagosoft.com'])->shouldContain('cli'); }); it('should remove packages', function ($self) { skip(); $sync = new Sync($self->repo); $sync->fromChannel('pear.pagosoft.com'); $pkgs = $self->repo->listAllPackages(); theValueOf($pkgs)->shouldHaveKey('pear.pagosoft.com'); // theValueOf($pkgs['pear.pagosoft.com'])->shouldContain('util'); pantr::silent(function () use($sync) { $sync->sync(); }); theFile($self->peardir . '/pgs')->shouldNotExist(); // $pkgs = $self->repo->listAllPackages(); // theValueOf($pkgs['pear.pagosoft.com'])->shouldNotContain('util'); }); it('should remove channels', function ($self) { $sync = new Sync($self->repo); $channels = $self->repo->listChannels(); the($channels)->shouldContain('pear.pagosoft.com'); pantr::silent(function () use($sync) { $sync->sync(); }); $channels = $self->repo->listChannels(); the($channels)->shouldNotContain('pear.pagosoft.com'); }); });