/** * Executes the current command. * * This method is not abstract because you can use this class * as a concrete class. In this case, instead of defining the * execute() method, you set the code to execute by passing * a Closure to the setCode() method. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return null|integer null or 0 if everything went fine, or an error code * * @throws \LogicException When this abstract method is not implemented * @see setCode() */ protected function execute(InputInterface $input, OutputInterface $output) { $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($input->getOption('debug')); $logger->info('Build started.'); $buildFolder = $input->getOption('output'); $buildGenerator = new BuildGenerator($input->getOption('resources'), $buildFolder); $writerCollectionFactory = new FullCollectionFactory(); $writerCollection = $writerCollectionFactory->createCollection($logger, $buildFolder); $buildGenerator->setLogger($logger)->setCollectionCreator(new CollectionCreator())->setWriterCollection($writerCollection); $buildGenerator->run($input->getArgument('version')); $logger->info('Build done.'); }
/** * Generate a build for build number specified * * @param string $buildNumber * @param \Composer\IO\IOInterface $io * @param bool $debug */ public static function createBuild($buildNumber, IOInterface $io = null, $debug = false) { $buildFolder = 'build/build-' . $buildNumber . '/'; $resourceFolder = 'vendor/browscap/browscap/resources/'; if (!file_exists($buildFolder)) { if ($io) { $io->write(' - Creating build folder'); } mkdir($buildFolder, 0775, true); } // Create a logger if ($io) { $io->write(' - Setting up logging'); } $loggerHelper = new LoggerHelper(); $logger = $loggerHelper->create($debug); $collectionCreator = new CollectionCreator(); if ($io) { $io->write(' - Creating writer collection'); } $writerCollectionFactory = new FullCollectionFactory(); $writerCollection = $writerCollectionFactory->createCollection($logger, $buildFolder); // Generate the actual browscap.ini files if ($io) { $io->write(' - Creating actual build'); } $buildGenerator = new BuildGenerator($resourceFolder, $buildFolder); $buildGenerator->setLogger($logger); $buildGenerator->setCollectionCreator($collectionCreator); $buildGenerator->setWriterCollection($writerCollection); $buildGenerator->run($buildNumber, false); if ($io) { $io->write(' - Creating cache'); } $iniFile = $buildFolder . 'full_php_browscap.ini'; $cache = new File(array(File::DIR => 'cache/')); $browscap = new Browscap(); $browscap->setCache($cache)->setLogger($logger); $browscap->convertFile($iniFile); }
/** * tests creating a writer collection * * @group writer * @group sourcetest */ public function testCreateCollection() { $logger = $this->createMock(\Monolog\Logger::class); $dir = vfsStream::url(self::STORAGE_DIR); self::assertInstanceOf(\Browscap\Writer\WriterCollection::class, $this->object->createCollection($logger, $dir)); }
/** * tests creating a writer collection * * @group writer * @group sourcetest */ public function testCreateCollection() { $mockLogger = $this->getMock('\\Monolog\\Logger', array(), array(), '', false); $dir = vfsStream::url(self::STORAGE_DIR); self::assertInstanceOf('\\Browscap\\Writer\\WriterCollection', $this->object->createCollection($mockLogger, $dir)); }