本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Console\Application::run方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::run方法的具体用法?PHP Application::run怎么用?PHP Application::run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Console\Application
的用法示例。
在下文中一共展示了Application::run方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: command
public function command($command, $opts = [])
{
$opts['-e'] = 'test';
$opts['-q'] = null;
$opts['command'] = $command;
return $this->app->run(new ArrayInput($opts));
}
示例2: runConsole
/**
* @param $command
* @param array $options
* @return int
*/
protected function runConsole($command, array $options = array())
{
$options["-e"] = "test";
$options["-q"] = null;
$options = array_merge($options, array('command' => $command));
return $this->application->run(new \Symfony\Component\Console\Input\ArrayInput($options));
}
示例3: runConsole
/**
* Helper to run a Symfony command.
*
* @param string $command
* @param array $options
*
* @return int
* @throws \Exception
*/
protected function runConsole($command, array $options = [])
{
$options["-e"] = "test";
$options["-q"] = null;
$options = array_merge($options, ['command' => $command]);
return $this->application->run(new ArrayInput($options));
}
示例4: cleanDB
/**
* @BeforeScenario @cleanDB
* @AfterScenario @cleanDB
*/
public function cleanDB()
{
$application = new Application($this->getKernel());
$application->setAutoExit(false);
$application->run(new StringInput("doctrine:schema:drop --force -n -q"));
$application->run(new StringInput("doctrine:schema:create -n -q"));
}
示例5: tearDownAfterClass
/**
* Ensure next tests will have a clean database.
*/
public static function tearDownAfterClass()
{
$application = new Application(static::$kernel);
$application->setAutoExit(false);
$application->run(new ArrayInput(['command' => 'doctrine:schema:drop', '--no-interaction' => true, '--force' => true, '--env' => 'test']), new NullOutput());
$application->run(new ArrayInput(['command' => 'doctrine:schema:create', '--no-interaction' => true, '--env' => 'test']), new NullOutput());
$application->run(new ArrayInput(['command' => 'doctrine:fixtures:load', '--no-interaction' => true, '--env' => 'test']), new NullOutput());
}
示例6: setUp
protected function setUp()
{
$client = static::createClient();
$application = new Application($client->getKernel());
$application->setAutoExit(false);
$application->run(new StringInput('doctrine:database:drop --force'));
$application->run(new StringInput('doctrine:database:create'));
$application->run(new StringInput('doctrine:schema:update --force'));
}
示例7: runCommand
private static function runCommand($commandName, $options = array())
{
$options["-e"] = self::$kernel->getEnvironment();
$options['command'] = $commandName;
$input = new ArrayInput($options);
$output = new NullOutput();
static::$application->setAutoExit(false);
self::$application->run($input, $output);
}
示例8: testExecute
public function testExecute()
{
$kernel = $this->createKernel();
$kernel->boot();
$application = new Application($kernel);
$application->setAutoExit(false);
$input = new ArgvInput(['', 'doctrine:database:drop', '--no-interaction', '--force', '-q']);
$application->run($input);
$input = new ArgvInput(['', 'doctrine:database:create', '--no-interaction', '-q']);
$application->run($input);
$input = new ArgvInput(['', 'doctrine:migrations:migrate', '--no-interaction', '-q']);
$application->run($input);
$em = $kernel->getContainer()->get('doctrine')->getManager();
$customer = new Customer();
$customer->setEmail('example@example.org');
$customer->setActivationCode('abc');
$customer->setEmployeeNumber('1234567890');
$customer->setSalesdivision(Customer::SALESDIVISION_MEDIAMARKT_SATURN);
$customer->setIsActivated(true);
$customer->setCouponsHaveBeenSent(false);
$customer->setOptInAccepted(false);
$em->persist($customer);
$couponcode = new Couponcode();
$couponcode->setCode('111');
$em->persist($couponcode);
$couponcode = new Couponcode();
$couponcode->setCode('222');
$em->persist($couponcode);
$couponcode = new Couponcode();
$couponcode->setCode('333');
$em->persist($couponcode);
$couponcode = new Couponcode();
$couponcode->setCode('444');
$em->persist($couponcode);
$couponcode = new Couponcode();
$couponcode->setCode('555');
$em->persist($couponcode);
$couponcode = new Couponcode();
$couponcode->setCode('666');
$em->persist($couponcode);
$em->flush();
$application->add(new SendCouponsCommand());
$command = $application->find('app:sendcoupons');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName()));
$this->assertSame("example@example.org\n", $commandTester->getDisplay());
$this->assertTrue($customer->getCouponsHaveBeenSent());
$repo = $em->getRepository('AppBundle\\Entity\\Couponcode');
$codes = $repo->findBy(['customer' => 1]);
$this->assertSame('111', $codes[0]->getCode());
$this->assertSame('222', $codes[1]->getCode());
$this->assertSame('333', $codes[2]->getCode());
$this->assertSame('444', $codes[3]->getCode());
$this->assertSame('555', $codes[4]->getCode());
$this->assertSame('666', $codes[5]->getCode());
$this->assertSame(6, sizeof($codes));
}
示例9: setUp
/**
* Setup
*/
public function setUp()
{
static::$kernel = static::createKernel();
static::$kernel->boot();
static::$application = new Application(static::$kernel);
static::$application->setAutoExit(false);
$this->client = static::createClient();
static::$application->run(new ArrayInput(array('command' => 'doctrine:database:drop', '--no-interaction' => true, '--force' => true, '--quiet' => true)));
static::$application->run(new ArrayInput(array('command' => 'doctrine:database:create', '--no-interaction' => true, '--quiet' => true)));
static::$application->run(new ArrayInput(array('command' => 'doctrine:schema:create', '--no-interaction' => true, '--quiet' => true)));
}
示例10: restoreDatabase
/**
* @BeforeScenario
*/
public function restoreDatabase()
{
$this->getEntityManager()->getConnection()->executeUpdate("SET foreign_key_checks = 0;");
$application = new Application($this->kernel);
$application->setAutoExit(false);
$drop = array('command' => 'doctrine:schema:drop', '--force' => true, '--no-interaction' => true, '--quiet' => true, '--env' => 'test');
$this->getEntityManager()->getConnection()->executeUpdate("SET foreign_key_checks = 1;");
$application->run(new ArrayInput($drop));
$create = array('command' => 'doctrine:schema:create', '--no-interaction' => true, '--quiet' => true, '--env' => 'test');
$application->run(new ArrayInput($create));
}
示例11: setUp
public function setUp()
{
$this->client = static::createClient();
$this->em = $this->client->getContainer()->get('doctrine')->getManager();
$application = new Application($this->client->getKernel());
$application->setAutoExit(false);
$application->run(new StringInput('doctrine:database:drop --force'));
$application->run(new StringInput('doctrine:database:create'));
$application->run(new StringInput('doctrine:schema:update --force'));
$application->run(new StringInput('doctrine:fixtures:load --append'));
$this->logIn();
}
示例12: execute
/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int|null|void
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$this->io->title($this->getDescription());
foreach ($this->apiViews as $apiView) {
$bufferOutput = new BufferedOutput();
$this->application->run(new StringInput(sprintf('api:doc:dump --view=%s', $apiView)), $bufferOutput);
$viewDump = $bufferOutput->fetch();
$viewDumpFile = __DIR__ . '/../Resources/doc/' . $apiView . '-api-doc.md';
file_put_contents($viewDumpFile, $viewDump);
$this->io->writeln(sprintf("%s -> view dumped to %s", $apiView, $viewDumpFile));
}
}
示例13: prepareFixturesOnly
public function prepareFixturesOnly()
{
$application = new Application($this->kernel);
$application->setAutoExit(false);
$options = array('command' => 'doctrine:database:drop', '--force' => true);
$application->run(new ArrayInput($options));
$options = array('command' => 'doctrine:database:create');
$application->run(new ArrayInput($options));
$options = array('command' => 'doctrine:schema:create');
$application->run(new ArrayInput($options));
$this->fixturesApplier->applyFixtures();
}
示例14: execute
/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$listenerManager = $this->container->get('doctrine_extensions.listener_manager');
$listenerManager->addAllListeners($this->container->get('doctrine.orm.entity_manager'));
$purger = new ORMPurger($this->container->get('doctrine.orm.entity_manager'));
$purger->purge();
$string_input = new StringInput('yrch:populate');
$application = new Application($this->application->getKernel());
$application->setAutoExit(false);
$application->run($string_input, $output);
$string_input = new StringInput('doctrine:data:load --append=true');
$application->run($string_input, $output);
}
示例15: testIntegration
public function testIntegration()
{
$client = static::createClient();
$application = new Application($client->getKernel());
$output = new BufferedOutput();
$application->setAutoExit(false);
$application->run(new ArgvInput(), $output);
$this->assertTrue(strpos($output->fetch(), 'Comment from the method') !== false, 'Description of the command is not parse from the comment of the method');
$arguments = array('this will be ignored', 'test_service:hello', '--name=toto', '--help');
$application->run(new ArgvInput($arguments), $output);
$outputString = $output->fetch();
$this->assertTrue(strpos($outputString, 'The name of the person you want to say hello to') !== false, 'Parsing of param comment is not working');
$this->assertTrue(strpos($outputString, '--output') === false, 'Output parameter should not be there since it cannot be enter by the user');
}