本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Console\Application::setCatchExceptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::setCatchExceptions方法的具体用法?PHP Application::setCatchExceptions怎么用?PHP Application::setCatchExceptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Console\Application
的用法示例。
在下文中一共展示了Application::setCatchExceptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
self::bootKernel();
$this->container = static::$kernel->getContainer();
$this->application = new Application(static::$kernel);
$this->application->setAutoExit(false);
$this->application->setCatchExceptions(false);
}
示例2: setupSubject
/**
* @before
*/
public function setupSubject()
{
$this->supervisorManager = $this->getMockBuilder('YZ\\SupervisorBundle\\Manager\\SupervisorManager')->disableOriginalConstructor()->getMock();
self::bootKernel();
static::$kernel->getContainer()->set('supervisor.manager', $this->supervisorManager);
$this->application = new Application(static::$kernel);
$this->application->setAutoExit(false);
$this->application->setCatchExceptions(false);
}
示例3: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
self::bootKernel();
$this->container = static::$kernel->getContainer();
$this->application = new Application(static::$kernel);
$this->application->setAutoExit(false);
$this->application->setCatchExceptions(false);
$this->function_exists = $this->getFunctionMock('Abc\\ProcessControl', 'function_exists');
}
示例4: getApplication
/**
* @return Application
*/
protected static function getApplication()
{
if (null === self::$application) {
$client = static::createClient();
self::$application = new Application($client->getKernel());
self::$application->setAutoExit(false);
self::$application->setCatchExceptions(false);
}
return self::$application;
}
示例5: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
self::bootKernel();
$this->em = static::$kernel->getContainer()->get('doctrine')->getManager();
$this->container = static::$kernel->getContainer();
$this->application = new Application(static::$kernel);
$this->application->setAutoExit(false);
$this->application->setCatchExceptions(false);
$this->runConsole("doctrine:schema:drop", array("--force" => true));
$this->runConsole("doctrine:schema:update", array("--force" => true));
}
示例6: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
self::bootKernel();
$this->container = static::$kernel->getContainer();
$this->application = new Application(static::$kernel);
$this->application->setAutoExit(false);
$this->application->setCatchExceptions(false);
$this->metadataFactory = $this->container->get('abc.job.metadata_factory');
/** @var ClassMetadata $classMetadata */
$this->classMetadata = $this->metadataFactory->getMetadataForClass(AnnotatedJob::class)->getRootClassMetadata();
}
示例7: initDatabase
private static function initDatabase()
{
$console = new Application(static::$kernel);
$console->setAutoExit(false);
/**
* SQLite is not supported yet
*
* @link https://github.com/doctrine/dbal/pull/2402
*/
$commands = ['doctrine:database:create' => ['--if-not-exists' => true], 'doctrine:schema:drop' => ['--full-database' => true, '--force' => true], 'doctrine:migrations:migrate' => [], 'doctrine:fixtures:load' => []];
foreach ($commands as $command => $args) {
/** apply common commands options */
$args['--env'] = 'test';
$args['--quiet'] = true;
$args['--no-interaction'] = true;
$args['command'] = $command;
try {
$console->setCatchExceptions(false);
$console->run(new ArrayInput($args));
} catch (\Exception $e) {
echo PHP_EOL . $e->getMessage() . PHP_EOL;
echo PHP_EOL . $e->getTraceAsString() . PHP_EOL;
throw $e;
}
}
}
示例8: coreTest
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');
}
示例9: testCacheIsFreshAfterCacheClearedWithWarmup
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');
}
示例10: setUp
/**
* {@inheritDoc}
*/
public function setUp()
{
self::bootKernel($this->kernelOptions);
$this->em = static::$kernel->getContainer()->get('doctrine')->getManager();
$this->application = new Application(static::$kernel);
$this->application->setAutoExit(false);
$this->application->setCatchExceptions(false);
if (count($this->entityManagerNames) > 0) {
foreach ($this->entityManagerNames as $name) {
$this->runConsole("doctrine:schema:drop", ['--force' => true, '--em' => $name]);
$this->runConsole("doctrine:schema:update", ['--force' => true, '--em' => $name]);
}
} else {
$this->runConsole("doctrine:schema:drop", array("--force" => true));
$this->runConsole("doctrine:schema:update", array("--force" => true));
}
}
示例11: testExecute
public function testExecute()
{
self::bootKernel();
$application = new Application(static::$kernel);
$application->setCatchExceptions(false);
$application->setAutoExit(false);
$tester = new ApplicationTester($application);
$tester->run(['command' => 'api:swagger:export']);
$this->assertJson($tester->getDisplay());
}
示例12: testBundleCommandsHaveRightContainer
public function testBundleCommandsHaveRightContainer()
{
$command = $this->getMockForAbstractClass('Symfony\\Bundle\\FrameworkBundle\\Command\\ContainerAwareCommand', array('foo'), '', true, true, true, array('setContainer'));
$command->setCode(function () {
});
$command->expects($this->exactly(2))->method('setContainer');
$application = new Application($this->getKernel(array()));
$application->setAutoExit(false);
$application->setCatchExceptions(false);
$application->add($command);
$tester = new ApplicationTester($application);
// set container is called here
$tester->run(array('command' => 'foo'));
// as the container might have change between two runs, setContainer must called again
$tester->run(array('command' => 'foo'));
}
示例13: testCommand
/**
* @dataProvider provideTestCommand
*
* @param $command
* @param $reportFile
*/
public function testCommand($command, $arguments, $reportFile, $inputStream = null)
{
$client = static::createClient();
$application = new Application($client->getKernel());
$application->setCatchExceptions(false);
$output = new BufferedOutput();
$application->setAutoExit(false);
if ($inputStream) {
$application->getHelperSet()->get('dialog')->setInputStream($this->getInputStream($inputStream));
}
//We push a empty argument that is ignore by the application and we push the command itself
array_unshift($arguments, null, $command);
$application->run(new ArgvInput($arguments), $output);
if ($this->dev) {
file_put_contents($reportFile, $this->report($application));
}
$this->assertStringEqualsFile($reportFile, $this->report($application));
}
示例14: runCommand
/**
* Runs a command and returns it output
*/
public function runCommand(Client $client, $command, $exceptionOnExitCode = true)
{
$application = new Application($client->getKernel());
$application->setAutoExit(false);
$input = new StringInput($command);
$output = new StreamOutput($fp = tmpfile());
$application->setCatchExceptions(false);
$return = $application->run($input, $output);
fseek($fp, 0);
$output = '';
while (!feof($fp)) {
$output .= fread($fp, 4096);
}
fclose($fp);
if ($exceptionOnExitCode && $return !== 0) {
throw new \RuntimeException(sprintf('Return code is not 0: %s', $output));
}
return $output;
}
示例15: execCommand
/**
* Execute a symfony command.
*
* $this->executeCommand('sulu:security:user:create', array(
* 'firstName' => 'foo',
* '--option' => 'bar',
* ));
*
* @param string $command Command to execute
* @param array $args Arguments and options
*
* @return int Exit code of command
*/
protected function execCommand($command, $args)
{
$kernel = $this->kernel;
array_unshift($args, $command);
$input = new ArrayInput($args);
$application = new Application($kernel);
$application->all();
$application->setAutoExit(false);
$application->setCatchExceptions(false);
$command = $application->find($command);
$output = new StreamOutput(fopen('php://memory', 'w', false));
$exitCode = $application->run($input, $output);
if ($exitCode !== 0) {
rewind($output->getStream());
$output = stream_get_contents($output->getStream());
throw new \Exception(sprintf('Command in BaseContext exited with code "%s": "%s"', $exitCode, $output));
}
return $exitCode;
}