12 namespace Symfony\Component\Console\Tests\Input;
21 $this->assertEquals(
'foo', $option->getName(),
'__construct() takes a name as its first argument');
23 $this->assertEquals(
'foo', $option->getName(),
'__construct() removes the leading -- of the option name');
38 $this->assertEquals(
'f', $option->getShortcut(),
'__construct() can take a shortcut as its second argument');
40 $this->assertEquals(
'f|ff|fff', $option->getShortcut(),
'__construct() removes the leading - of the shortcuts');
41 $option =
new InputOption(
'foo', array(
'f',
'ff',
'-fff'));
42 $this->assertEquals(
'f|ff|fff', $option->getShortcut(),
'__construct() removes the leading - of the shortcuts');
44 $this->assertNull($option->getShortcut(),
'__construct() makes the shortcut null by default');
50 $this->assertFalse($option->acceptValue(),
'__construct() gives a "InputOption::VALUE_NONE" mode by default');
51 $this->assertFalse($option->isValueRequired(),
'__construct() gives a "InputOption::VALUE_NONE" mode by default');
52 $this->assertFalse($option->isValueOptional(),
'__construct() gives a "InputOption::VALUE_NONE" mode by default');
55 $this->assertFalse($option->acceptValue(),
'__construct() can take "InputOption::VALUE_NONE" as its mode');
56 $this->assertFalse($option->isValueRequired(),
'__construct() can take "InputOption::VALUE_NONE" as its mode');
57 $this->assertFalse($option->isValueOptional(),
'__construct() can take "InputOption::VALUE_NONE" as its mode');
60 $this->assertFalse($option->acceptValue(),
'__construct() can take "InputOption::VALUE_NONE" as its mode');
61 $this->assertFalse($option->isValueRequired(),
'__construct() can take "InputOption::VALUE_NONE" as its mode');
62 $this->assertFalse($option->isValueOptional(),
'__construct() can take "InputOption::VALUE_NONE" as its mode');
65 $this->assertTrue($option->acceptValue(),
'__construct() can take "InputOption::VALUE_REQUIRED" as its mode');
66 $this->assertTrue($option->isValueRequired(),
'__construct() can take "InputOption::VALUE_REQUIRED" as its mode');
67 $this->assertFalse($option->isValueOptional(),
'__construct() can take "InputOption::VALUE_REQUIRED" as its mode');
70 $this->assertTrue($option->acceptValue(),
'__construct() can take "InputOption::VALUE_OPTIONAL" as its mode');
71 $this->assertFalse($option->isValueRequired(),
'__construct() can take "InputOption::VALUE_OPTIONAL" as its mode');
72 $this->assertTrue($option->isValueOptional(),
'__construct() can take "InputOption::VALUE_OPTIONAL" as its mode');
80 $this->setExpectedException(
'InvalidArgumentException', sprintf(
'Option mode "%s" is not valid.', $mode));
120 $this->assertTrue($option->isArray(),
'->isArray() returns true if the option can be an array');
122 $this->assertFalse($option->isArray(),
'->isArray() returns false if the option can not be an array');
127 $option =
new InputOption(
'foo',
'f', null,
'Some description');
128 $this->assertEquals(
'Some description', $option->getDescription(),
'->getDescription() returns the description message');
134 $this->assertEquals(
'default', $option->getDefault(),
'->getDefault() returns the default value');
137 $this->assertEquals(
'default', $option->getDefault(),
'->getDefault() returns the default value');
140 $this->assertNull($option->getDefault(),
'->getDefault() returns null if no default value is configured');
143 $this->assertEquals(array(), $option->getDefault(),
'->getDefault() returns an empty array if option is an array');
146 $this->assertFalse($option->getDefault(),
'->getDefault() returns false if the option does not take a value');
152 $option->setDefault(null);
153 $this->assertNull($option->getDefault(),
'->setDefault() can reset the default value by passing null');
154 $option->setDefault(
'another');
155 $this->assertEquals(
'another', $option->getDefault(),
'->setDefault() changes the default value');
158 $option->setDefault(array(1, 2));
159 $this->assertEquals(array(1, 2), $option->getDefault(),
'->setDefault() changes the default value');
169 $option->setDefault(
'default');
179 $option->setDefault(
'default');
184 $option =
new InputOption(
'foo',
'f', null,
'Some description');
185 $option2 =
new InputOption(
'foo',
'f', null,
'Alternative description');
186 $this->assertTrue($option->equals($option2));
190 $this->assertFalse($option->equals($option2));
192 $option =
new InputOption(
'foo',
'f', null,
'Some description');
193 $option2 =
new InputOption(
'bar',
'f', null,
'Some description');
194 $this->assertFalse($option->equals($option2));
196 $option =
new InputOption(
'foo',
'f', null,
'Some description');
197 $option2 =
new InputOption(
'foo',
'', null,
'Some description');
198 $this->assertFalse($option->equals($option2));
200 $option =
new InputOption(
'foo',
'f', null,
'Some description');
202 $this->assertFalse($option->equals($option2));