2010-03-18 07:48:03 +00:00
< ? php
/*
2010-04-25 16:06:54 +01:00
* This file is part of the Symfony package .
2011-01-15 13:29:43 +00:00
*
2011-03-06 11:40:06 +00:00
* ( c ) Fabien Potencier < fabien @ symfony . com >
2010-03-18 07:48:03 +00:00
*
* For the full copyright and license information , please view the LICENSE
* file that was distributed with this source code .
*/
2010-08-20 22:09:55 +01:00
namespace Symfony\Tests\Component\Console\Input ;
2010-03-18 07:48:03 +00:00
2010-08-20 22:09:55 +01:00
use Symfony\Component\Console\Input\InputDefinition ;
use Symfony\Component\Console\Input\InputArgument ;
use Symfony\Component\Console\Input\InputOption ;
2010-03-18 07:48:03 +00:00
class InputDefinitionTest extends \PHPUnit_Framework_TestCase
{
2010-05-06 12:25:53 +01:00
static protected $fixtures ;
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
protected $foo , $bar , $foo1 , $foo2 ;
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
static public function setUpBeforeClass ()
{
2010-06-28 08:31:54 +01:00
self :: $fixtures = __DIR__ . '/../Fixtures/' ;
2010-05-06 12:25:53 +01:00
}
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
public function testConstructor ()
{
$this -> initializeArguments ();
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ();
$this -> assertEquals ( array (), $definition -> getArguments (), '__construct() creates a new InputDefinition object' );
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ( array ( $this -> foo , $this -> bar ));
$this -> assertEquals ( array ( 'foo' => $this -> foo , 'bar' => $this -> bar ), $definition -> getArguments (), '__construct() takes an array of InputArgument objects as its first argument' );
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$this -> initializeOptions ();
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ();
$this -> assertEquals ( array (), $definition -> getOptions (), '__construct() creates a new InputDefinition object' );
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ( array ( $this -> foo , $this -> bar ));
$this -> assertEquals ( array ( 'foo' => $this -> foo , 'bar' => $this -> bar ), $definition -> getOptions (), '__construct() takes an array of InputOption objects as its first argument' );
}
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
public function testSetArguments ()
{
$this -> initializeArguments ();
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ();
$definition -> setArguments ( array ( $this -> foo ));
$this -> assertEquals ( array ( 'foo' => $this -> foo ), $definition -> getArguments (), '->setArguments() sets the array of InputArgument objects' );
$definition -> setArguments ( array ( $this -> bar ));
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$this -> assertEquals ( array ( 'bar' => $this -> bar ), $definition -> getArguments (), '->setArguments() clears all InputArgument objects' );
}
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
public function testAddArguments ()
{
$this -> initializeArguments ();
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ();
$definition -> addArguments ( array ( $this -> foo ));
$this -> assertEquals ( array ( 'foo' => $this -> foo ), $definition -> getArguments (), '->addArguments() adds an array of InputArgument objects' );
$definition -> addArguments ( array ( $this -> bar ));
$this -> assertEquals ( array ( 'foo' => $this -> foo , 'bar' => $this -> bar ), $definition -> getArguments (), '->addArguments() does not clear existing InputArgument objects' );
}
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
public function testAddArgument ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeArguments ();
$definition = new InputDefinition ();
$definition -> addArgument ( $this -> foo );
$this -> assertEquals ( array ( 'foo' => $this -> foo ), $definition -> getArguments (), '->addArgument() adds a InputArgument object' );
$definition -> addArgument ( $this -> bar );
$this -> assertEquals ( array ( 'foo' => $this -> foo , 'bar' => $this -> bar ), $definition -> getArguments (), '->addArgument() adds a InputArgument object' );
// arguments must have different names
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> addArgument ( $this -> foo1 );
$this -> fail ( '->addArgument() throws a Exception if another argument is already registered with the same name' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->addArgument() throws a Exception if another argument is already registered with the same name' );
$this -> assertEquals ( 'An argument with name "foo" already exist.' , $e -> getMessage ());
}
// cannot add a parameter after an array parameter
$definition -> addArgument ( new InputArgument ( 'fooarray' , InputArgument :: IS_ARRAY ));
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> addArgument ( new InputArgument ( 'anotherbar' ));
$this -> fail ( '->addArgument() throws a Exception if there is an array parameter already registered' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->addArgument() throws a Exception if there is an array parameter already registered' );
$this -> assertEquals ( 'Cannot add an argument after an array argument.' , $e -> getMessage ());
}
// cannot add a required argument after an optional one
$definition = new InputDefinition ();
$definition -> addArgument ( $this -> foo );
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> addArgument ( $this -> foo2 );
$this -> fail ( '->addArgument() throws an exception if you try to add a required argument after an optional one' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->addArgument() throws an exception if you try to add a required argument after an optional one' );
$this -> assertEquals ( 'Cannot add a required argument after an optional one.' , $e -> getMessage ());
}
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testGetArgument ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeArguments ();
$definition = new InputDefinition ();
$definition -> addArguments ( array ( $this -> foo ));
$this -> assertEquals ( $this -> foo , $definition -> getArgument ( 'foo' ), '->getArgument() returns a InputArgument by its name' );
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> getArgument ( 'bar' );
$this -> fail ( '->getArgument() throws an exception if the InputArgument name does not exist' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->getArgument() throws an exception if the InputArgument name does not exist' );
$this -> assertEquals ( 'The "bar" argument does not exist.' , $e -> getMessage ());
}
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testHasArgument ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeArguments ();
$definition = new InputDefinition ();
$definition -> addArguments ( array ( $this -> foo ));
$this -> assertTrue ( $definition -> hasArgument ( 'foo' ), '->hasArgument() returns true if a InputArgument exists for the given name' );
$this -> assertFalse ( $definition -> hasArgument ( 'bar' ), '->hasArgument() returns false if a InputArgument exists for the given name' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testGetArgumentRequiredCount ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeArguments ();
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ();
$definition -> addArgument ( $this -> foo2 );
$this -> assertEquals ( 1 , $definition -> getArgumentRequiredCount (), '->getArgumentRequiredCount() returns the number of required arguments' );
$definition -> addArgument ( $this -> foo );
$this -> assertEquals ( 1 , $definition -> getArgumentRequiredCount (), '->getArgumentRequiredCount() returns the number of required arguments' );
}
2010-04-10 22:23:20 +01:00
2010-05-06 12:25:53 +01:00
public function testGetArgumentCount ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeArguments ();
$definition = new InputDefinition ();
$definition -> addArgument ( $this -> foo2 );
$this -> assertEquals ( 1 , $definition -> getArgumentCount (), '->getArgumentCount() returns the number of arguments' );
$definition -> addArgument ( $this -> foo );
$this -> assertEquals ( 2 , $definition -> getArgumentCount (), '->getArgumentCount() returns the number of arguments' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testGetArgumentDefaults ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ( array (
new InputArgument ( 'foo1' , InputArgument :: OPTIONAL ),
new InputArgument ( 'foo2' , InputArgument :: OPTIONAL , '' , 'default' ),
new InputArgument ( 'foo3' , InputArgument :: OPTIONAL | InputArgument :: IS_ARRAY ),
// new InputArgument('foo4', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, '', array(1, 2)),
));
$this -> assertEquals ( array ( 'foo1' => null , 'foo2' => 'default' , 'foo3' => array ()), $definition -> getArgumentDefaults (), '->getArgumentDefaults() return the default values for each argument' );
$definition = new InputDefinition ( array (
new InputArgument ( 'foo4' , InputArgument :: OPTIONAL | InputArgument :: IS_ARRAY , '' , array ( 1 , 2 )),
));
$this -> assertEquals ( array ( 'foo4' => array ( 1 , 2 )), $definition -> getArgumentDefaults (), '->getArgumentDefaults() return the default values for each argument' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testSetOptions ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeOptions ();
$definition = new InputDefinition ( array ( $this -> foo ));
$this -> assertEquals ( array ( 'foo' => $this -> foo ), $definition -> getOptions (), '->setOptions() sets the array of InputOption objects' );
$definition -> setOptions ( array ( $this -> bar ));
$this -> assertEquals ( array ( 'bar' => $this -> bar ), $definition -> getOptions (), '->setOptions() clears all InputOption objects' );
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> getOptionForShortcut ( 'f' );
$this -> fail ( '->setOptions() clears all InputOption objects' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->setOptions() clears all InputOption objects' );
$this -> assertEquals ( 'The "-f" option does not exist.' , $e -> getMessage ());
}
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testAddOptions ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeOptions ();
$definition = new InputDefinition ( array ( $this -> foo ));
$this -> assertEquals ( array ( 'foo' => $this -> foo ), $definition -> getOptions (), '->addOptions() adds an array of InputOption objects' );
$definition -> addOptions ( array ( $this -> bar ));
$this -> assertEquals ( array ( 'foo' => $this -> foo , 'bar' => $this -> bar ), $definition -> getOptions (), '->addOptions() does not clear existing InputOption objects' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testAddOption ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeOptions ();
$definition = new InputDefinition ();
$definition -> addOption ( $this -> foo );
$this -> assertEquals ( array ( 'foo' => $this -> foo ), $definition -> getOptions (), '->addOption() adds a InputOption object' );
$definition -> addOption ( $this -> bar );
$this -> assertEquals ( array ( 'foo' => $this -> foo , 'bar' => $this -> bar ), $definition -> getOptions (), '->addOption() adds a InputOption object' );
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> addOption ( $this -> foo2 );
$this -> fail ( '->addOption() throws a Exception if the another option is already registered with the same name' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->addOption() throws a Exception if the another option is already registered with the same name' );
$this -> assertEquals ( 'An option named "foo" already exist.' , $e -> getMessage ());
}
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> addOption ( $this -> foo1 );
$this -> fail ( '->addOption() throws a Exception if the another option is already registered with the same shortcut' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->addOption() throws a Exception if the another option is already registered with the same shortcut' );
$this -> assertEquals ( 'An option with shortcut "f" already exist.' , $e -> getMessage ());
}
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testGetOption ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeOptions ();
$definition = new InputDefinition ( array ( $this -> foo ));
$this -> assertEquals ( $this -> foo , $definition -> getOption ( 'foo' ), '->getOption() returns a InputOption by its name' );
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> getOption ( 'bar' );
$this -> fail ( '->getOption() throws an exception if the option name does not exist' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->getOption() throws an exception if the option name does not exist' );
$this -> assertEquals ( 'The "--bar" option does not exist.' , $e -> getMessage ());
}
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testHasOption ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeOptions ();
$definition = new InputDefinition ( array ( $this -> foo ));
$this -> assertTrue ( $definition -> hasOption ( 'foo' ), '->hasOption() returns true if a InputOption exists for the given name' );
$this -> assertFalse ( $definition -> hasOption ( 'bar' ), '->hasOption() returns false if a InputOption exists for the given name' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testHasShortcut ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeOptions ();
$definition = new InputDefinition ( array ( $this -> foo ));
$this -> assertTrue ( $definition -> hasShortcut ( 'f' ), '->hasShortcut() returns true if a InputOption exists for the given shortcut' );
$this -> assertFalse ( $definition -> hasShortcut ( 'b' ), '->hasShortcut() returns false if a InputOption exists for the given shortcut' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testGetOptionForShortcut ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> initializeOptions ();
$definition = new InputDefinition ( array ( $this -> foo ));
$this -> assertEquals ( $this -> foo , $definition -> getOptionForShortcut ( 'f' ), '->getOptionForShortcut() returns a InputOption by its shortcut' );
2010-05-07 15:09:11 +01:00
try {
2010-05-06 12:25:53 +01:00
$definition -> getOptionForShortcut ( 'l' );
$this -> fail ( '->getOption() throws an exception if the shortcut does not exist' );
2010-05-07 15:09:11 +01:00
} catch ( \Exception $e ) {
2010-05-06 12:25:53 +01:00
$this -> assertInstanceOf ( '\Exception' , $e , '->getOption() throws an exception if the shortcut does not exist' );
$this -> assertEquals ( 'The "-l" option does not exist.' , $e -> getMessage ());
}
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testGetOptionDefaults ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ( array (
2010-11-27 16:56:55 +00:00
new InputOption ( 'foo1' , null , InputOption :: VALUE_NONE ),
new InputOption ( 'foo2' , null , InputOption :: VALUE_REQUIRED ),
new InputOption ( 'foo3' , null , InputOption :: VALUE_REQUIRED , '' , 'default' ),
new InputOption ( 'foo4' , null , InputOption :: VALUE_OPTIONAL ),
new InputOption ( 'foo5' , null , InputOption :: VALUE_OPTIONAL , '' , 'default' ),
new InputOption ( 'foo6' , null , InputOption :: VALUE_OPTIONAL | InputOption :: VALUE_IS_ARRAY ),
new InputOption ( 'foo7' , null , InputOption :: VALUE_OPTIONAL | InputOption :: VALUE_IS_ARRAY , '' , array ( 1 , 2 )),
2010-05-06 12:25:53 +01:00
));
$defaults = array (
'foo1' => null ,
'foo2' => null ,
'foo3' => 'default' ,
'foo4' => null ,
'foo5' => 'default' ,
'foo6' => array (),
'foo7' => array ( 1 , 2 ),
);
$this -> assertEquals ( $defaults , $definition -> getOptionDefaults (), '->getOptionDefaults() returns the default values for all options' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testGetSynopsis ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ( array ( new InputOption ( 'foo' )));
$this -> assertEquals ( '[--foo]' , $definition -> getSynopsis (), '->getSynopsis() returns a synopsis of arguments and options' );
$definition = new InputDefinition ( array ( new InputOption ( 'foo' , 'f' )));
$this -> assertEquals ( '[-f|--foo]' , $definition -> getSynopsis (), '->getSynopsis() returns a synopsis of arguments and options' );
2010-11-27 16:56:55 +00:00
$definition = new InputDefinition ( array ( new InputOption ( 'foo' , 'f' , InputOption :: VALUE_REQUIRED )));
2010-05-06 12:25:53 +01:00
$this -> assertEquals ( '[-f|--foo="..."]' , $definition -> getSynopsis (), '->getSynopsis() returns a synopsis of arguments and options' );
2010-11-27 16:56:55 +00:00
$definition = new InputDefinition ( array ( new InputOption ( 'foo' , 'f' , InputOption :: VALUE_OPTIONAL )));
2010-05-06 12:25:53 +01:00
$this -> assertEquals ( '[-f|--foo[="..."]]' , $definition -> getSynopsis (), '->getSynopsis() returns a synopsis of arguments and options' );
$definition = new InputDefinition ( array ( new InputArgument ( 'foo' )));
$this -> assertEquals ( '[foo]' , $definition -> getSynopsis (), '->getSynopsis() returns a synopsis of arguments and options' );
$definition = new InputDefinition ( array ( new InputArgument ( 'foo' , InputArgument :: REQUIRED )));
$this -> assertEquals ( 'foo' , $definition -> getSynopsis (), '->getSynopsis() returns a synopsis of arguments and options' );
$definition = new InputDefinition ( array ( new InputArgument ( 'foo' , InputArgument :: IS_ARRAY )));
$this -> assertEquals ( '[foo1] ... [fooN]' , $definition -> getSynopsis (), '->getSynopsis() returns a synopsis of arguments and options' );
$definition = new InputDefinition ( array ( new InputArgument ( 'foo' , InputArgument :: REQUIRED | InputArgument :: IS_ARRAY )));
$this -> assertEquals ( 'foo1 ... [fooN]' , $definition -> getSynopsis (), '->getSynopsis() returns a synopsis of arguments and options' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testAsText ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$definition = new InputDefinition ( array (
2011-12-15 06:07:36 +00:00
new InputArgument ( 'foo' , InputArgument :: OPTIONAL , 'The foo argument' ),
new InputArgument ( 'baz' , InputArgument :: OPTIONAL , 'The baz argument' , true ),
new InputArgument ( 'bar' , InputArgument :: OPTIONAL | InputArgument :: IS_ARRAY , 'The bar argument' , array ( 'bar' )),
2010-11-27 16:56:55 +00:00
new InputOption ( 'foo' , 'f' , InputOption :: VALUE_REQUIRED , 'The foo option' ),
2011-12-15 06:07:36 +00:00
new InputOption ( 'baz' , null , InputOption :: VALUE_OPTIONAL , 'The baz option' , false ),
new InputOption ( 'bar' , 'b' , InputOption :: VALUE_OPTIONAL , 'The bar option' , 'bar' ),
2012-01-09 11:22:03 +00:00
new InputOption ( 'qux' , '' , InputOption :: VALUE_OPTIONAL | InputOption :: VALUE_IS_ARRAY , 'The qux option' , array ( 'foo' , 'bar' )),
2012-01-08 23:03:43 +00:00
new InputOption ( 'qux2' , '' , InputOption :: VALUE_OPTIONAL | InputOption :: VALUE_IS_ARRAY , 'The qux2 option' , array ( 'foo' => 'bar' )),
2010-05-06 12:25:53 +01:00
));
$this -> assertStringEqualsFile ( self :: $fixtures . '/definition_astext.txt' , $definition -> asText (), '->asText() returns a textual representation of the InputDefinition' );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
public function testAsXml ()
{
$definition = new InputDefinition ( array (
2011-12-15 06:07:36 +00:00
new InputArgument ( 'foo' , InputArgument :: OPTIONAL , 'The foo argument' ),
new InputArgument ( 'baz' , InputArgument :: OPTIONAL , 'The baz argument' , true ),
new InputArgument ( 'bar' , InputArgument :: OPTIONAL | InputArgument :: IS_ARRAY , 'The bar argument' , array ( 'bar' )),
2010-11-27 16:56:55 +00:00
new InputOption ( 'foo' , 'f' , InputOption :: VALUE_REQUIRED , 'The foo option' ),
2011-12-15 06:07:36 +00:00
new InputOption ( 'baz' , null , InputOption :: VALUE_OPTIONAL , 'The baz option' , false ),
new InputOption ( 'bar' , 'b' , InputOption :: VALUE_OPTIONAL , 'The bar option' , 'bar' ),
2010-05-06 12:25:53 +01:00
));
$this -> assertXmlStringEqualsXmlFile ( self :: $fixtures . '/definition_asxml.txt' , $definition -> asXml (), '->asText() returns a textual representation of the InputDefinition' );
}
2010-03-18 07:48:03 +00:00
2010-05-06 12:25:53 +01:00
protected function initializeArguments ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> foo = new InputArgument ( 'foo' );
$this -> bar = new InputArgument ( 'bar' );
$this -> foo1 = new InputArgument ( 'foo' );
$this -> foo2 = new InputArgument ( 'foo2' , InputArgument :: REQUIRED );
2010-03-18 07:48:03 +00:00
}
2010-05-06 12:25:53 +01:00
protected function initializeOptions ()
2010-03-18 07:48:03 +00:00
{
2010-05-06 12:25:53 +01:00
$this -> foo = new InputOption ( 'foo' , 'f' );
$this -> bar = new InputOption ( 'bar' , 'b' );
$this -> foo1 = new InputOption ( 'fooBis' , 'f' );
$this -> foo2 = new InputOption ( 'foo' , 'p' );
2010-03-18 07:48:03 +00:00
}
}