Author: James Hautot (james@rezo.net)
Inheritance: extends Builder, implements Composer\Satis\Builder\BuilderInterface
Ejemplo n.º 1
0
 public function testTwigEnvironment()
 {
     $twig = new \Twig_Environment(new \Twig_Loader_Array([]));
     $this->webBuilder->setTwigEnvironment($twig);
     $reflection = new \ReflectionClass($this->webBuilder);
     $method = $reflection->getMethod('getTwigEnvironment');
     $method->setAccessible(true);
     $this->assertSame($twig, $method->invoke($this->webBuilder));
 }
Ejemplo n.º 2
0
 /**
  * @dataProvider dataAbandoned
  */
 public function testAbandoned($abandoned, $expected)
 {
     $webBuilder = new WebBuilder(new NullOutput(), vfsStream::url('build'), array(), false);
     $webBuilder->setRootPackage($this->rootPackage);
     $this->package->setAbandoned($abandoned);
     $webBuilder->dump(array($this->package));
     $html = $this->root->getChild('build/index.html')->getContent();
     $this->assertRegExp('/Package vendor\\/name is abandoned, you should avoid using it/', $html);
     $this->assertRegExp($expected, $html);
 }
Ejemplo n.º 3
0
 public function testNominalCase()
 {
     vfsStreamWrapper::register();
     $root = vfsStream::newDirectory('build');
     vfsStreamWrapper::setRoot($root);
     $webBuilder = new WebBuilder(new NullOutput(), vfsStream::url('build'), array(), false);
     $webBuilder->setRootPackage($this->rootPackage);
     $packages = array(new Package('vendor/name', '1.0.0.0', '1.0'));
     $webBuilder->dump($packages);
     $html = $root->getChild('build/index.html')->getContent();
     $this->assertRegExp('/<h3 id="vendor\\/name">vendor\\/name<\\/h3>/', $html);
 }
Ejemplo n.º 4
0
 /**
  * @param InputInterface $input The input instance
  * @param OutputInterface $output The output instance
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $verbose = $input->getOption('verbose');
     $configFile = $input->getArgument('file');
     $packagesFilter = $input->getArgument('packages');
     $repositoryUrl = $input->getOption('repository-url');
     $skipErrors = (bool) $input->getOption('skip-errors');
     if ($repositoryUrl !== null && count($packagesFilter) > 0) {
         throw new \InvalidArgumentException('The arguments "package" and "repository-url" can not be used together.');
     }
     // load auth.json authentication information and pass it to the io interface
     $io = $this->getIO();
     $io->loadConfiguration($this->getConfiguration());
     if (preg_match('{^https?://}i', $configFile)) {
         $rfs = new RemoteFilesystem($io);
         $contents = $rfs->getContents(parse_url($configFile, PHP_URL_HOST), $configFile, false);
         $config = JsonFile::parseJson($contents, $configFile);
     } else {
         $file = new JsonFile($configFile);
         if (!$file->exists()) {
             $output->writeln('<error>File not found: ' . $configFile . '</error>');
             return 1;
         }
         $config = $file->read();
     }
     // disable packagist by default
     unset(Config::$defaultRepositories['packagist']);
     if (!($outputDir = $input->getArgument('output-dir'))) {
         $outputDir = isset($config['output-dir']) ? $config['output-dir'] : null;
     }
     if (null === $outputDir) {
         throw new \InvalidArgumentException('The output dir must be specified as second argument or be configured inside ' . $input->getArgument('file'));
     }
     $composer = $this->getApplication()->getComposer(true, $config);
     $packageSelection = new PackageSelection($output, $outputDir, $config, $skipErrors);
     if ($repositoryUrl !== null) {
         $packageSelection->setRepositoryFilter($repositoryUrl);
     } else {
         $packageSelection->setPackagesFilter($packagesFilter);
     }
     $packages = $packageSelection->select($composer, $verbose);
     if (isset($config['archive']['directory'])) {
         $downloads = new ArchiveBuilder($output, $outputDir, $config, $skipErrors);
         $downloads->setComposer($composer);
         $downloads->dump($packages);
     }
     if ($packageSelection->hasFilterForPackages()) {
         // in case of an active package filter we need to load the dumped packages.json and merge the
         // updated packages in
         $oldPackages = $packageSelection->load();
         $packages += $oldPackages;
         ksort($packages);
     }
     $packagesBuilder = new PackagesBuilder($output, $outputDir, $config, $skipErrors);
     $packagesBuilder->dump($packages);
     if ($htmlView = !$input->getOption('no-html-output')) {
         $htmlView = !isset($config['output-html']) || $config['output-html'];
     }
     if ($htmlView) {
         $web = new WebBuilder($output, $outputDir, $config, $skipErrors);
         $web->setRootPackage($composer->getPackage());
         $web->dump($packages);
     }
 }