作者:Herriniain
项目:iVarotr
public function testGetCommand()
{
$cmd = new Command('foo');
$helperset = new HelperSet();
$helperset->setCommand($cmd);
$this->assertEquals($cmd, $helperset->getCommand(), '->getCommand() retrieves stored command');
}
作者:Leem
项目:silex-doctrine-migrations-provide
/**
* Bootstraps the application.
*
* This method is called after all services are registered
* and should be used for "dynamic" configuration (whenever
* a service must be requested).
*
* @param Application $app
*/
public function boot(Application $app)
{
$helperSet = new HelperSet(array('connection' => new ConnectionHelper($app['db']), 'dialog' => new DialogHelper()));
if (isset($app['orm.em'])) {
$helperSet->set(new EntityManagerHelper($app['orm.em']), 'em');
}
$this->console->setHelperSet($helperSet);
$commands = array('Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\ExecuteCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\GenerateCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\MigrateCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\StatusCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\VersionCommand');
// @codeCoverageIgnoreStart
if (true === $this->console->getHelperSet()->has('em')) {
$commands[] = 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\DiffCommand';
}
// @codeCoverageIgnoreEnd
$configuration = new Configuration($app['db'], $app['migrations.output_writer']);
$configuration->setMigrationsDirectory($app['migrations.directory']);
$configuration->setName($app['migrations.name']);
$configuration->setMigrationsNamespace($app['migrations.namespace']);
$configuration->setMigrationsTableName($app['migrations.table_name']);
$configuration->registerMigrationsFromDirectory($app['migrations.directory']);
foreach ($commands as $name) {
/** @var AbstractCommand $command */
$command = new $name();
$command->setMigrationConfiguration($configuration);
$this->console->add($command);
}
}
作者:mindgruv
项目:gruve
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->get('entity_manager');
$helperSet = new HelperSet();
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
$helperSet->set($this->getHelper('dialog'), 'dialog');
$arguments = array();
if ($input->getArgument('version')) {
$arguments['version'] = $input->getArgument('version');
}
if ($input->getOption('write-sql')) {
$arguments['--write-sql'] = $input->getOption('write-sql');
}
if ($input->getOption('dry-run')) {
$arguments['--dry-run'] = $input->getOption('dry-run');
}
if ($input->getOption('query-time')) {
$arguments['--query-time'] = $input->getOption('query-time');
}
if ($input->getOption('allow-no-migration')) {
$arguments['--allow-no-migration'] = $input->getOption('allow-no-migration');
}
$configDir = $this->get('config')->get('[directories][config_dir]');
$arguments['--configuration'] = $configDir . '/migrations.yml';
$command = new MigrateCommand();
$command->setHelperSet($helperSet);
$returnCode = $command->run(new ArrayInput($arguments), $output);
return $returnCode;
}
作者:mindgruv
项目:gruve
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->get('entity_manager');
$helperSet = new HelperSet();
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
$arguments = array();
if ($input->getArgument('version')) {
$arguments['version'] = $input->getArgument('version');
}
if ($input->getOption('add')) {
$arguments['--add'] = $input->getOption('add');
}
if ($input->getOption('delete')) {
$arguments['--delete'] = $input->getOption('delete');
}
if ($input->getOption('all')) {
$arguments['--all'] = $input->getOption('all');
}
if ($input->getOption('range-from')) {
$arguments['--range-from'] = $input->getOption('range-from');
}
if ($input->getOption('range-to')) {
$arguments['--range-to'] = $input->getOption('range-to');
}
$configDir = $this->get('config')->get('[directories][config_dir]');
$arguments['--configuration'] = $configDir . '/migrations.yml';
$command = new VersionCommand();
$command->setHelperSet($helperSet);
$returnCode = $command->run(new ArrayInput($arguments), $output);
return $returnCode;
}
作者:balee
项目:cl
/**
* @inheritdoc
*/
public function register()
{
$container = $this->getContainer();
$container->singleton(Services::HELPERSET, function () use($container) {
$helperSet = new HelperSet();
$helperSet->set($container->get(Services::HELPERSET_QUESTION), 'question');
return $helperSet;
})->withArgument(Services::CONFIG);
$container->add(Services::HELPERSET_QUESTION, QuestionHelper::class);
}
作者:abdeldaye
项目:pim-community-de
function it_dumps_field_filters(OutputInterface $output, HelperSet $helperSet, TableHelper $table)
{
$output->writeln(Argument::any())->shouldBeCalled();
$helperSet->get('table')->willReturn($table);
$headers = ['field', 'filter_class', 'operators'];
$table->setHeaders($headers)->shouldBeCalled()->willReturn($table);
$table->setRows(Argument::any())->shouldBeCalled();
$table->render(Argument::any())->shouldBeCalled();
$this->dump($output, $helperSet);
}
作者:abdeldaye
项目:pim-community-de
function it_dumps_field_filters(OutputInterface $output, HelperSet $helperSet, TableHelper $table, $repository)
{
$output->writeln(Argument::any())->shouldBeCalled();
$repository->findAll()->willReturn([]);
$helperSet->get('table')->willReturn($table);
$headers = ['attribute', 'localizable', 'scopable', 'attribute type', 'filter_class', 'operators'];
$table->setHeaders($headers)->shouldBeCalled()->willReturn($table);
$table->setRows(Argument::any())->shouldBeCalled();
$table->render(Argument::any())->shouldBeCalled();
$this->dump($output, $helperSet);
}
作者:JesseDarellMoor
项目:CS49
public function testIteration()
{
$helperset = new HelperSet();
$helperset->set($this->getGenericMockHelper('fake_helper_01', $helperset));
$helperset->set($this->getGenericMockHelper('fake_helper_02', $helperset));
$helpers = array('fake_helper_01', 'fake_helper_02');
$i = 0;
foreach ($helperset as $helper) {
$this->assertEquals($helpers[$i++], $helper->getName());
}
}
作者:quickstra
项目:quickstra
/**
* @param HelperSet $helpers
* @return TravisCiCommand
* @throws \Symfony\Component\Console\Exception\InvalidArgumentException
* @throws \Symfony\Component\Console\Exception\LogicException
*/
public static function createCommand(HelperSet $helpers)
{
/** @var QuestionHelper $questionHelper */
$questionHelper = $helpers->get('question');
$travisCiQuestionHelper = new TravisCiQuestionHelper($questionHelper);
/** @var PackageHelper $packageHelper */
$packageHelper = $helpers->get('package');
$configBuilder = new ConfigBuilder($travisCiQuestionHelper, $packageHelper);
$configWriter = new ConfigWriter();
return new TravisCiCommand($travisCiQuestionHelper, $configBuilder, $configWriter);
}
作者:h2aki
项目:backu
function it_should_execute_when_calling_fire_action(QuestionHelper $question, HelperSet $helpers)
{
$helpers->get('question')->willReturn($question);
$input = new ArrayInput([]);
$output = new NullOutput();
$query = Argument::type('Symfony\\Component\\Console\\Question\\ChoiceQuestion');
$question->ask($input, $output, $query)->willReturn(1);
$helpers->get('question')->willReturn($question);
$this->setHelperSet($helpers);
$this->run($input, $output);
$this->fire();
}
作者:ronald13
项目:dojoModul
/**
* Sets the dojo theme to use.
*
* @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
* @return \Symfony\Component\Console\Application
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config')['sds']['dojo'];
$configHelper = new \Sds\DojoModule\Tools\Console\Helper\ConfigHelper($config);
$helperSet = new HelperSet();
$helperSet->set($configHelper, 'config');
$cli = new Application();
$cli->setName('DojoModule Command Line Interface');
$cli->setHelperSet($helperSet);
$cli->addCommands(array(new \Sds\DojoModule\Tools\Console\Command\GenerateProfile()));
return $cli;
}
作者:quickstra
项目:quickstra
protected function setUp()
{
parent::setUp();
$this->application = static::getMock(Application::class);
$this->sut = $this->getSut();
$command = static::getMockBuilder(Command::class)->disableOriginalConstructor()->getMock();
$command->expects(static::any())->method('getApplication')->willReturn($this->application);
$command->expects(static::any())->method('getName')->willReturn('mock command');
$helperSet = new HelperSet();
$helperSet->setCommand($command);
$this->sut->setHelperSet($helperSet);
$this->application->setHelperSet($helperSet);
}
作者:Kyra277
项目:AM
public function testExecute()
{
$profiler = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')->disableOriginalConstructor()->getMock();
$profiler->expects($this->once())->method('import')->will($this->returnValue(new Profile('TOKEN')));
$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\\Component\\Console\\Helper\\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');
$command = new ImportCommand($profiler);
$command->setHelperSet($helperSet);
$commandTester = new CommandTester($command);
$commandTester->execute(array('filename' => __DIR__ . '/../Fixtures/profile.data'));
$this->assertRegExp('/Profile "TOKEN" has been successfully imported\\./', $commandTester->getDisplay());
}
作者:codesleev
项目:generato
/**
* If the user answers yes then we can override the file
* or if the file doesn't exist then we will just answer
* yes because we aren't overriding anything.
*
* @param string $filename
* @param OutputInterface $output
* @param HelperSet $helperSet
* @return boolean
*/
protected function yes($filename, $output, $helperSet, $options)
{
if (!$this->file->exists($this->basePath . '/' . $filename)) {
return true;
}
if (isset($options['yes']) && $options['yes'] == true) {
return true;
}
$dialog = $helperSet->get('dialog');
if ($dialog->askConfirmation($output, "<question>Would you like to override {$filename}? [y/N]</question>", false)) {
return true;
}
return false;
}
作者:a2xchi
项目:pim-community-de
/**
* {@inheritdoc}
*/
public function dump(OutputInterface $output, HelperSet $helperSet)
{
$output->writeln("<info>Useable attributes filters...</info>");
$attributeFilters = $this->getAttributeFilters();
$attributes = $this->repository->findAll();
$rows = [];
foreach ($attributes as $attribute) {
$rows = array_merge($rows, $this->getFilterInformationForAttribute($attribute, $attributeFilters));
}
$table = $helperSet->get('table');
$headers = ['attribute', 'localizable', 'scopable', 'attribute type', 'operators', 'filter_class'];
$table->setHeaders($headers)->setRows($rows);
$table->render($output);
}
作者:ven
项目:doxpor
/**
* Runs the application using the given HelperSet
*
* This method is responsible for creating the console application, adding
* relevant commands, and running it. Other code is responsible for producing
* the HelperSet itself (your cli-config.php or bootstrap code), and for
* calling this method (the actual bin command file).
*
* @param HelperSet $helperSet
* @param Application $application
* @throws \Doxport\Exception\Exception
* @return integer 0 if everything went fine, or an error code
*/
public static function run(HelperSet $helperSet, Application $application = null)
{
if (!$helperSet->has('em')) {
throw new Exception('Helper set passed to Doxport console runner must have an entity manager ("em")');
}
if (!$application) {
$application = new Application('Doxport relational data tool', Version::VERSION);
}
$application->setCatchExceptions(true);
$application->setHelperSet($helperSet);
$application->add(new ExportCommand());
$application->add(new DeleteCommand());
$application->add(new ImportCommand());
return $application->run();
}
作者:tsurun
项目:Prueba
public function testExecuteWithToken()
{
$profiler = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')->disableOriginalConstructor()->getMock();
$profile = new Profile('TOKEN');
$profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile));
$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\\Component\\Console\\Helper\\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');
$command = new ExportCommand($profiler);
$command->setHelperSet($helperSet);
$commandTester = new CommandTester($command);
$commandTester->execute(array('token' => 'TOKEN'));
$this->assertEquals($profiler->export($profile), $commandTester->getDisplay());
}
作者:quickstra
项目:quickstra
protected function setUp()
{
parent::setUp();
$this->inputMock = static::getMock(InputInterface::class);
$this->outputMock = static::getMock(OutputInterface::class);
$this->packageMock = static::getMock(PackageHelper::class);
$this->requireMock = static::getMock(RequireHelper::class);
$this->questionMock = Mockery::mock(QuestionHelper::class)->makePartial();
$helperSet = new HelperSet();
$helperSet->set($this->questionMock, 'question');
$helperSet->set($this->packageMock, 'package');
$helperSet->set($this->requireMock, 'composer require');
$this->sut = new CodeSnifferCommand();
$this->sut->setHelperSet($helperSet);
}
作者:mindgruv
项目:gruve
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->get('entity_manager');
$helperSet = new HelperSet();
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
$arguments = array();
if ($input->getOption('dump-sql')) {
$arguments['--dump-sql'] = $input->getOption('dump-sql');
}
$command = new CreateCommand();
$command->setHelperSet($helperSet);
$returnCode = $command->run(new ArrayInput($arguments), $output);
return $returnCode;
}
作者:a2xchi
项目:pim-community-de
/**
* {@inheritdoc}
*/
public function dump(OutputInterface $output, HelperSet $helperSet)
{
$output->writeln("<info>Useable field filters...</info>");
$rows = [];
foreach ($this->registry->getFieldFilters() as $filter) {
$class = get_class($filter);
$operators = implode(', ', $filter->getOperators());
foreach ($filter->getFields() as $field) {
$rows[] = [$field, $operators, $class];
}
}
$headers = ['field', 'operators', 'filter_class'];
$table = $helperSet->get('table');
$table->setHeaders($headers)->setRows($rows);
$table->render($output);
}