doRun() public method

Runs the current application.
public doRun ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
return integer 0 if everything went fine, or an error code
Example #1
0
 public function testBundleCommandsAreRegistered()
 {
     $bundle = $this->createBundleMock(array());
     $kernel = $this->getKernel(array($bundle), true);
     $application = new Application($kernel);
     $application->doRun(new ArrayInput(array('list')), new NullOutput());
     // Calling twice: registration should only be done once.
     $application->doRun(new ArrayInput(array('list')), new NullOutput());
 }
Example #2
0
 public function testBundleCommandsAreRegistered()
 {
     $bundle = $this->getMock('Symfony\\Component\\HttpKernel\\Bundle\\Bundle');
     $bundle->expects($this->once())->method('registerCommands');
     $kernel = $this->getKernel(array($bundle), true);
     $application = new Application($kernel);
     $application->doRun(new ArrayInput(array('list')), new NullOutput());
     // Calling twice: registration should only be done once.
     $application->doRun(new ArrayInput(array('list')), new NullOutput());
 }
 /**
  * @param array $input
  *
  * @return integer
  */
 public function run($input = array())
 {
     $this->input = new ArrayInput((array) $input);
     $this->input->setInteractive(false);
     $this->output = new StreamOutput(fopen('php://memory', 'r+', false));
     $inputStream = $this->getInputStream();
     rewind($inputStream);
     $this->application->getHelperSet()->get('dialog')->setInputStream($inputStream);
     return $this->application->doRun($this->input, $this->output);
 }
 /**
  * @param string $command
  *
  * @When /^I run (.*)$/
  */
 public function iRunCommand($command)
 {
     $inputString = trim($command);
     $input = new StringInput($inputString);
     $this->output = new StreamOutput(tmpfile());
     $this->exception = null;
     try {
         $this->exitCode = $this->application->doRun($input, $this->output);
     } catch (\Exception $e) {
         $this->exception = $e;
         $this->exitCode = -255;
     }
 }
 protected function coreTest(array $arguments)
 {
     $input = new ArrayInput($arguments);
     $application = new Application(static::$kernel);
     $application->setCatchExceptions(false);
     $application->doRun($input, new NullOutput());
     // Ensure that all *.meta files are fresh
     $finder = new Finder();
     $metaFiles = $finder->files()->in(static::$kernel->getCacheDir())->name('*.php.meta');
     // simply check that cache is warmed up
     $this->assertGreaterThanOrEqual(1, count($metaFiles));
     foreach ($metaFiles as $file) {
         $configCache = new ConfigCache(substr($file, 0, -5), true);
         $this->assertTrue($configCache->isFresh(), sprintf('Meta file "%s" is not fresh', (string) $file));
     }
     // check that app kernel file present in meta file of container's cache
     $containerRef = new \ReflectionObject(static::$kernel->getContainer());
     $containerFile = $containerRef->getFileName();
     $containerMetaFile = $containerFile . '.meta';
     $kernelRef = new \ReflectionObject(static::$kernel);
     $kernelFile = $kernelRef->getFileName();
     /** @var ResourceInterface[] $meta */
     $meta = unserialize(file_get_contents($containerMetaFile));
     $found = false;
     foreach ($meta as $resource) {
         if ((string) $resource === $kernelFile) {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found, 'Kernel file should present as resource');
     $this->assertRegExp(sprintf('/\'kernel.name\'\\s*=>\\s*\'%s\'/', static::$kernel->getName()), file_get_contents($containerFile), 'kernel.name is properly set on the dumped container');
     $this->assertEquals(ini_get('memory_limit'), '1024M');
 }
Example #6
0
 public function testCacheIsFreshAfterCacheClearedWithWarmup()
 {
     $input = new ArrayInput(array('cache:clear'));
     $application = new Application($this->kernel);
     $application->setCatchExceptions(false);
     $application->doRun($input, new NullOutput());
     // Ensure that all *.meta files are fresh
     $finder = new Finder();
     $metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
     // simply check that cache is warmed up
     $this->assertGreaterThanOrEqual(1, count($metaFiles));
     foreach ($metaFiles as $file) {
         $configCache = new ConfigCache(substr($file, 0, -5), true);
         $this->assertTrue($configCache->isFresh(), sprintf('Meta file "%s" is not fresh', (string) $file));
     }
     // check that app kernel file present in meta file of container's cache
     $containerRef = new \ReflectionObject($this->kernel->getContainer());
     $containerFile = $containerRef->getFileName();
     $containerMetaFile = $containerFile . '.meta';
     $kernelRef = new \ReflectionObject($this->kernel);
     $kernelFile = $kernelRef->getFileName();
     /** @var ResourceInterface[] $meta */
     $meta = unserialize(file_get_contents($containerMetaFile));
     $found = false;
     foreach ($meta as $resource) {
         if ((string) $resource === $kernelFile) {
             $found = true;
             break;
         }
     }
     $this->assertTrue($found, 'Kernel file should present as resource');
 }
Example #7
0
 public function someAction(Request $request)
 {
     $session = $request->getSession();
     if ($session->get('user') == 'thaian2009') {
         $act = $request->get('act');
         if (isset($act)) {
             if ($act == '1') {
                 $sact = 'cache:clear --env=prod';
             }
             if ($act == '2') {
                 $sact = 'doctrine:mapping:import --force HoaianWebBundle yml';
             }
             if ($act == '3') {
                 $sact = 'doctrine:mapping:convert annotation ./src';
             }
             if ($act == '4') {
                 $sact = 'doctrine:generate:entities HoaianWebBundle';
             }
             if ($act == '5') {
                 $sact = 'assets:install /home/vol10_4/ultimatefreehost.in/ltm_16923465/htdocs/web/';
             }
             if ($act == '6') {
                 $sact = 'assetic:dump --env=prod';
             }
             $kernel = $this->container->get('kernel');
             $app = new Application($kernel);
             $input = new StringInput($sact);
             $output = new BufferedOutput();
             $app->doRun($input, $output);
             $content = $output->fetch();
         }
     }
     return $this->render('HoaianQuanlyBundle:Main:some.html.twig', array('scontent' => $content));
 }
Example #8
0
 public function testBundleCommandsAreRegistered()
 {
     $bundle = $this->getMock("Symfony\\Component\\HttpKernel\\Bundle\\Bundle");
     $bundle->expects($this->once())->method('registerCommands');
     $kernel = $this->getKernel(array($bundle));
     $application = new Application($kernel);
     $application->doRun(new ArrayInput(array('list')), new NullOutput());
 }
Example #9
0
 /**
  * Execute a symfony command
  * @param string $command
  * @param array  $arguments
  */
 public function runCommand($command, array $arguments = array())
 {
     $application = new Application($this->kernel);
     $args = array_merge(['command' => $command], $arguments);
     $input = new ArrayInput($args);
     $output = new NullOutput();
     // Run the command
     $application->doRun($input, $output);
 }
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     try {
         $rs = parent::doRun($input, $output);
         $this->saveDebugInformation();
         return $rs;
     } catch (\Exception $ex) {
         $this->saveDebugInformation($ex);
         throw $ex;
     }
 }
Example #11
0
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->siteAccessName = $input->getParameterOption('--siteaccess', null);
     return parent::doRun($input, $output);
 }
 /**
  * Executes a single command
  *
  * @param Application     $application
  * @param OutputInterface $output
  * @param array           $arguments
  *
  * @return int
  */
 protected function runCommand(array $arguments)
 {
     $input = new ArrayInput($arguments);
     $input->setInteractive(false);
     return $this->application->doRun($input, $this->output);
 }
Example #13
0
 /**
  * {@inheritdoc}
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     // Set the input to non-interactive if the yes or no options are used.
     if ($input->hasParameterOption(array('--yes', '-y')) || $input->hasParameterOption(array('--no', '-n'))) {
         $input->setInteractive(false);
     } elseif ($input->hasParameterOption(array('--shell', '-s'))) {
         $shell = new Shell($this);
         $shell->run();
         return 0;
     }
     $this->output = $output;
     return parent::doRun($input, $output);
 }