public function testAskingForAFreeResponseForAMissingMandatoryOptionsWithoutAvailableValues()
 {
     $command = new SampleCommand(null);
     $this->application->add($command);
     $this->runtimeInputIs($command, "free response");
     $commandTester = new CommandTester($command);
     $commandTester->execute(['command' => $command->getName()]);
     $this->assertEquals('free response', $commandTester->getInput()->getOption('option'));
 }
示例#2
0
 /**
  * Test specifying a prefix for different connections.
  */
 public function testPrefix()
 {
     if (Database::getConnection()->driver() == 'sqlite') {
         $this->markTestSkipped('SQLITE modifies the prefixes so we cannot effectively test it');
     }
     Database::addConnectionInfo('magic_db', 'default', Database::getConnectionInfo('default')['default']);
     $command = new DbCommandBaseTester();
     $command_tester = new CommandTester($command);
     $command_tester->execute(['--database' => 'magic_db', '--prefix' => 'extra']);
     $this->assertEquals('extra', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
     $connection_info = Database::getConnectionInfo('default')['default'];
     $command_tester->execute(['-db-url' => $connection_info['driver'] . '://' . $connection_info['username'] . ':' . $connection_info['password'] . '@' . $connection_info['host'] . '/' . $connection_info['database'], '--prefix' => 'extra2']);
     $this->assertEquals('extra2', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
     // This breaks simpletest cleanup.
     //    $command_tester->execute([
     //      '--prefix' => 'notsimpletest',
     //    ]);
     //    $this->assertEquals('notsimpletest', $command->getDatabaseConnection($command_tester->getInput())->tablePrefix());
 }
 public function testTheWrapperTypeCanBeChanged()
 {
     $application = new Application();
     $command = $application->find('compare');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName(), '--type' => 'directory', 'previous' => __DIR__, 'latest' => __DIR__), ['verbosity' => OutputInterface::VERBOSITY_DEBUG]);
     $argument = $command->getDefinition()->getOption('type');
     $this->assertNotEquals($argument->getDefault(), $commandTester->getInput()->getOption('type'));
     $this->assertNotContains('Unknown wrapper', $commandTester->getDisplay());
     $this->assertContains('Total time', $commandTester->getDisplay());
 }
 public function testSuccessIfAdminAlreadyPresentAndUserUsesForce()
 {
     $options = ['--username' => 'myUsername', '--name' => 'myName', '--email' => '*****@*****.**', '--password' => 'superSecret', '--force' => true];
     $expected = ['username' => 'myUsername', 'name' => 'myName', 'email' => '*****@*****.**', 'password' => 'superSecret', 'force' => true];
     $installTool = $this->getInstallToolMock(true, true);
     $command = new DatabaseAddAdminCommand($this->getFrameworkMock(), $installTool, 'en');
     $command->setHelperSet($this->getHelperSet());
     $tester = new CommandTester($command);
     $code = $tester->execute($options);
     $this->assertEquals(0, $code);
     $this->assertEquals($expected, $tester->getInput()->getOptions());
     $this->assertContains('Success: Admin user added', $tester->getDisplay());
 }
示例#5
0
 public function testmanageArguments()
 {
     $application = $this->getApplication();
     $application->add(new DummyCommand());
     $command = $application->find('eav:attribute:create-dummy-values');
     $dialog = $this->getMock('Symfony\\Component\\Console\\Helper\\QuestionHelper', array('ask'));
     // ASK - attribute-id
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(92));
     // ASK - values-type
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue('int'));
     // ASK - values-number
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(1));
     // We override the standard helper with our mock
     $command->getHelperSet()->set($dialog, 'dialog');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $arguments = $commandTester->getInput()->getArguments();
     $this->assertArrayHasKey('attribute-id', $arguments);
     $this->assertArrayHasKey('values-type', $arguments);
     $this->assertArrayHasKey('values-number', $arguments);
 }
示例#6
0
 public function testmanageArguments()
 {
     $application = $this->getApplication();
     $application->add(new DummyCommand());
     $command = $application->find('category:create:dummy');
     $dialog = $this->getMock('Symfony\\Component\\Console\\Helper\\QuestionHelper', array('ask'));
     // ASK - store-id
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(1));
     // ASK - children-categories-number
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(0));
     // ASK - category-name-prefix
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue('My Awesome Category '));
     // ASK - category-number
     $dialog->expects($this->any())->method('ask')->with($this->isInstanceOf('Symfony\\Component\\Console\\Input\\InputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Output\\OutputInterface'), $this->isInstanceOf('Symfony\\Component\\Console\\Question\\Question'))->will($this->returnValue(0));
     // We override the standard helper with our mock
     $command->getHelperSet()->set($dialog, 'dialog');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $arguments = $commandTester->getInput()->getArguments();
     $this->assertArrayHasKey('store-id', $arguments);
     $this->assertArrayHasKey('children-categories-number', $arguments);
     $this->assertArrayHasKey('category-name-prefix', $arguments);
     $this->assertArrayHasKey('category-number', $arguments);
 }
 public function testSetArgumentsAndOptionsCorrectly()
 {
     $application = new Application();
     $createApache = new CreateApacheCommand($this->container);
     $application->add($createApache);
     $command = $application->find('apache:create');
     $commandTester = new CommandTester($command);
     $arguments = ['server-name' => 'marvin.dev', 'document-root' => '/home/marvin/app'];
     $options = ['ip' => '192.50.50.40', 'port' => '80', 'server-admin' => 'marvin@webmaster', 'alias' => 'marvin.local', 'log-dir' => '/home/marvin/app/logs'];
     $parameters = $arguments;
     $parameters['command'] = $command->getName();
     $parameters['--ip'] = $options['ip'];
     $parameters['--port'] = $options['port'];
     $parameters['--server-admin'] = $options['server-admin'];
     $parameters['--alias'] = $options['alias'];
     $parameters['--log-dir'] = $options['log-dir'];
     $commandTester->execute($parameters);
     $inpArguments = $commandTester->getInput()->getArguments();
     $inpOptions = $commandTester->getInput()->getOptions();
     // Assert Arguments
     $this->assertEquals($arguments['server-name'], $inpArguments['server-name']);
     $this->assertEquals($arguments['document-root'], $inpArguments['document-root']);
     // Assert Options
     $this->assertEquals($options['ip'], $inpOptions['ip']);
     $this->assertEquals($options['port'], $inpOptions['port']);
     $this->assertEquals($options['server-admin'], $inpOptions['server-admin']);
     $this->assertEquals($options['alias'], $inpOptions['alias']);
     $this->assertEquals($options['log-dir'], $inpOptions['log-dir']);
 }