本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Console\Application::addCommands方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::addCommands方法的具体用法?PHP Application::addCommands怎么用?PHP Application::addCommands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Bundle\FrameworkBundle\Console\Application
的用法示例。
在下文中一共展示了Application::addCommands方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUpBeforeClass
public static function setUpBeforeClass()
{
@unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml');
@unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/CarController.php');
@unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/OrderController.php');
$kernel = new \AppKernel('test', true);
$app = new Application($kernel);
$app->addCommands(array(new GenerateRestControllerCommand()));
$kernel->boot();
$command = $app->find('generate:rest:controller');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Order', '--entity' => 'TestTestBundle:Order', '--mongo' => true), array('interactive' => false));
$kernel->shutdown();
$kernel = new \AppKernel('test', true);
$app = new Application($kernel);
$app->addCommands(array(new GenerateRestControllerCommand()));
$kernel->boot();
$command = $app->find('generate:rest:controller');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Car', '--entity' => 'TestTestBundle:Car'), array('interactive' => false));
$kernel->shutdown();
@unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php.meta');
@unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php');
@unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php.meta');
@unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php');
}
示例2: testRun
public function testRun()
{
$app = new Application(self::$kernel);
$app->addCommands([new LoadFixturesCommand()]);
$command = $app->find('amstaffix:fixtures:load');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'dir-with-fixtures' => $this->dirWithFixtures], ['interactive' => false]);
$this->assertEquals(4, EntityHelper::getCountOfEntities($this->em, 'CoreTestFixture\\TestBundle\\Entity\\Article'));
$this->assertEquals(3, EntityHelper::getCountOfEntities($this->em, 'CoreTestFixture\\TestBundle\\Entity\\Author'));
$this->assertEquals(8, EntityHelper::getCountOfEntities($this->em, 'CoreTestFixture\\TestBundle\\Entity\\Book'));
}
示例3: tearDownAfterClass
public static function tearDownAfterClass()
{
parent::tearDownAfterClass();
$kernel = new \AppKernel('test', true);
$app = new Application($kernel);
$app->addCommands(array(new DropDatabaseDoctrineCommand()));
$kernel->boot();
$command = $app->find('doctrine:database:drop');
$commandTester = new CommandTester($command);
$commandTester->execute(array('command' => $command->getName(), '--force' => true));
$kernel->shutdown();
}
示例4: testRun
public function testRun()
{
$app = new Application(self::$kernel);
$app->addCommands([new GenerateFixturesFromProductionDBCommand()]);
$command = $app->find('amstaffix:fixtures:generate-from-db');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'target-dir' => $this->targetDir], ['interactive' => false]);
$this->assertTrue(file_exists($this->fullDirPath));
$this->assertTrue(is_dir($this->fullDirPath));
$finder = (new Finder())->files()->name('*.js')->in($this->fullDirPath);
foreach ($finder as $file) {
/** @var SplFileInfo $file */
$this->assertNotEmpty(file_get_contents($file->getPathname()));
}
}
开发者ID:amstaffix,项目名称:extjs-rest-common-bundle,代码行数:15,代码来源:GenerateFixturesFromProductionDBCommandTest.php
示例5: testSimple
public function testSimple()
{
$dir = __DIR__ . '/../data/saved_extjs_models';
$app = new Application(self::$kernel);
$app->addCommands([new SaveGeneratedExtJSModelsCommand()]);
$command = $app->find('amstaffix:extjs-models:save');
$commandTester = new CommandTester($command);
$commandTester->execute(['command' => $command->getName(), 'target-dir' => $dir], ['interactive' => false]);
$this->assertTrue(file_exists($dir));
$this->assertTrue(is_dir($dir));
$finder = (new Finder())->files()->name('*.js')->in($dir);
foreach ($finder as $file) {
/** @var SplFileInfo $file */
$this->assertNotEmpty(file_get_contents($file->getPathname()));
}
}
示例6: initializeEnvironment
private static function initializeEnvironment()
{
// Boot the AppKernel in the test environment and with the debug.
self::$kernel = new AppKernel('test', true);
self::$kernel->boot();
// Create the application for command execution
$helperSet = new HelperSet();
self::$application = new Application(self::$kernel);
self::$application->setHelperSet($helperSet);
self::$application->addCommands(self::enhance($helperSet, array(new RunSqlCommand(), new ImportCommand(), new ReservedWordsCommand(), new CreateDatabaseDoctrineCommand(), new DropDatabaseDoctrineCommand())));
self::$application->setAutoExit(false);
// Store the container and the DB connection in test case properties
self::$container = self::$kernel->getContainer();
self::$conn = self::$container->get('database_connection');
self::$transaction = self::$container->get('cantiga.transaction');
self::$eventDispatcher = new EventDispatcher();
$helperSet->set(new ConnectionHelper(self::$conn), 'db');
if (SharedResources::$dbInitializer !== null) {
self::$dbInitializer = SharedResources::$dbInitializer;
self::$dbReused = true;
} else {
SharedResources::$dbInitializer = self::$dbInitializer = new DBInitializer(self::$application, self::$container->getParameter('db_files'));
}
}