12 namespace Symfony\Component\Console\Tests\Input;
26 self::$fixtures = __DIR__.
'/../Fixtures/';
34 $this->assertEquals(array(), $definition->getArguments(),
'__construct() creates a new InputDefinition object');
37 $this->assertEquals(array(
'foo' => $this->foo,
'bar' => $this->bar), $definition->getArguments(),
'__construct() takes an array of InputArgument objects as its first argument');
45 $this->assertEquals(array(), $definition->getOptions(),
'__construct() creates a new InputDefinition object');
48 $this->assertEquals(array(
'foo' => $this->foo,
'bar' => $this->bar), $definition->getOptions(),
'__construct() takes an array of InputOption objects as its first argument');
56 $definition->setArguments(array($this->foo));
57 $this->assertEquals(array(
'foo' => $this->foo), $definition->getArguments(),
'->setArguments() sets the array of InputArgument objects');
58 $definition->setArguments(array($this->bar));
60 $this->assertEquals(array(
'bar' => $this->bar), $definition->getArguments(),
'->setArguments() clears all InputArgument objects');
68 $definition->addArguments(array($this->foo));
69 $this->assertEquals(array(
'foo' => $this->foo), $definition->getArguments(),
'->addArguments() adds an array of InputArgument objects');
70 $definition->addArguments(array($this->bar));
71 $this->assertEquals(array(
'foo' => $this->foo,
'bar' => $this->bar), $definition->getArguments(),
'->addArguments() does not clear existing InputArgument objects');
79 $definition->addArgument($this->foo);
80 $this->assertEquals(array(
'foo' => $this->foo), $definition->getArguments(),
'->addArgument() adds a InputArgument object');
81 $definition->addArgument($this->bar);
82 $this->assertEquals(array(
'foo' => $this->foo,
'bar' => $this->bar), $definition->getArguments(),
'->addArgument() adds a InputArgument object');
94 $definition->addArgument($this->foo);
95 $definition->addArgument($this->foo1);
120 $definition->addArgument($this->foo);
121 $definition->addArgument($this->foo2);
129 $definition->addArguments(array($this->foo));
130 $this->assertEquals($this->foo, $definition->getArgument(
'foo'),
'->getArgument() returns a InputArgument by its name');
142 $definition->addArguments(array($this->foo));
143 $definition->getArgument(
'bar');
151 $definition->addArguments(array($this->foo));
153 $this->assertTrue($definition->hasArgument(
'foo'),
'->hasArgument() returns true if a InputArgument exists for the given name');
154 $this->assertFalse($definition->hasArgument(
'bar'),
'->hasArgument() returns false if a InputArgument exists for the given name');
162 $definition->addArgument($this->foo2);
163 $this->assertEquals(1, $definition->getArgumentRequiredCount(),
'->getArgumentRequiredCount() returns the number of required arguments');
164 $definition->addArgument($this->foo);
165 $this->assertEquals(1, $definition->getArgumentRequiredCount(),
'->getArgumentRequiredCount() returns the number of required arguments');
173 $definition->addArgument($this->foo2);
174 $this->assertEquals(1, $definition->getArgumentCount(),
'->getArgumentCount() returns the number of arguments');
175 $definition->addArgument($this->foo);
176 $this->assertEquals(2, $definition->getArgumentCount(),
'->getArgumentCount() returns the number of arguments');
187 $this->assertEquals(array(
'foo1' => null,
'foo2' =>
'default',
'foo3' => array()), $definition->getArgumentDefaults(),
'->getArgumentDefaults() return the default values for each argument');
192 $this->assertEquals(array(
'foo4' => array(1, 2)), $definition->getArgumentDefaults(),
'->getArgumentDefaults() return the default values for each argument');
200 $this->assertEquals(array(
'foo' => $this->foo), $definition->getOptions(),
'->setOptions() sets the array of InputOption objects');
201 $definition->setOptions(array($this->bar));
202 $this->assertEquals(array(
'bar' => $this->bar), $definition->getOptions(),
'->setOptions() clears all InputOption objects');
214 $definition->setOptions(array($this->bar));
215 $definition->getOptionForShortcut(
'f');
223 $this->assertEquals(array(
'foo' => $this->foo), $definition->getOptions(),
'->addOptions() adds an array of InputOption objects');
224 $definition->addOptions(array($this->bar));
225 $this->assertEquals(array(
'foo' => $this->foo,
'bar' => $this->bar), $definition->getOptions(),
'->addOptions() does not clear existing InputOption objects');
233 $definition->addOption($this->foo);
234 $this->assertEquals(array(
'foo' => $this->foo), $definition->getOptions(),
'->addOption() adds a InputOption object');
235 $definition->addOption($this->bar);
236 $this->assertEquals(array(
'foo' => $this->foo,
'bar' => $this->bar), $definition->getOptions(),
'->addOption() adds a InputOption object');
248 $definition->addOption($this->foo);
249 $definition->addOption($this->foo2);
261 $definition->addOption($this->foo);
262 $definition->addOption($this->foo1);
270 $this->assertEquals($this->foo, $definition->getOption(
'foo'),
'->getOption() returns a InputOption by its name');
282 $definition->getOption(
'bar');
290 $this->assertTrue($definition->hasOption(
'foo'),
'->hasOption() returns true if a InputOption exists for the given name');
291 $this->assertFalse($definition->hasOption(
'bar'),
'->hasOption() returns false if a InputOption exists for the given name');
299 $this->assertTrue($definition->hasShortcut(
'f'),
'->hasShortcut() returns true if a InputOption exists for the given shortcut');
300 $this->assertFalse($definition->hasShortcut(
'b'),
'->hasShortcut() returns false if a InputOption exists for the given shortcut');
308 $this->assertEquals($this->foo, $definition->getOptionForShortcut(
'f'),
'->getOptionForShortcut() returns a InputOption by its shortcut');
316 $this->assertEquals($this->multi, $definition->getOptionForShortcut(
'm'),
'->getOptionForShortcut() returns a InputOption by its shortcut');
317 $this->assertEquals($this->multi, $definition->getOptionForShortcut(
'mmm'),
'->getOptionForShortcut() returns a InputOption by its shortcut');
329 $definition->getOptionForShortcut(
'l');
350 'foo7' => array(1, 2),
352 $this->assertSame($defaults, $definition->getOptionDefaults(),
'->getOptionDefaults() returns the default values for all options');
360 $this->assertEquals($expectedSynopsis, $definition->
getSynopsis(), $message ?
'->getSynopsis() '.$message :
'');
383 $this->assertEquals(
'[options] [--] [<cat>]', $definition->getSynopsis(
true),
'->getSynopsis(true) groups options in [options]');
402 $this->assertStringEqualsFile(self::$fixtures.
'/definition_astext.txt', $definition->asText(),
'->asText() returns a textual representation of the InputDefinition');
418 $this->assertXmlStringEqualsXmlFile(self::$fixtures.
'/definition_asxml.txt', $definition->asXml(),
'->asXml() returns an XML representation of the InputDefinition');
435 $this->multi =
new InputOption(
'multi',
'm|mm|mmm');