});
context("with defaults options", function () {
it("allows boolean casting", function () {
$commandLine = new CommandLine(['option1' => ['type' => 'boolean', 'default' => true], 'option2' => ['type' => 'boolean', 'default' => false], 'option3' => ['type' => 'boolean', 'default' => true], 'option4' => ['type' => 'boolean', 'default' => false]]);
$actual = $commandLine->parse(['command', '--option1', '--option2']);
expect($actual)->toEqual(['option1' => true, 'option2' => true, 'option3' => true, 'option4' => false]);
});
});
context("with override set to `false`", function () {
it("doesn't override existing options when the override params is set to `false`", function () {
$commandLine = new CommandLine();
$commandLine->set('option1', 'value1');
$actual = $commandLine->parse(['--option1=valueX']);
expect($actual)->toBe(['option1' => 'valueX']);
$commandLine = new CommandLine();
$commandLine->set('option1', 'value1');
$actual = $commandLine->parse(['--option1=valueX'], false);
expect($actual)->toBe(['option1' => 'value1']);
});
});
});
describe("->get()", function () {
it("ignores option value if the value option is set", function () {
$commandLine = new CommandLine(['option1' => ['type' => 'string', 'value' => 'config_value']]);
$actual = $commandLine->parse(['command']);
expect($commandLine->get('option1'))->toEqual('config_value');
$actual = $commandLine->parse(['command', '--option1']);
expect($commandLine->get('option1'))->toEqual('config_value');
$actual = $commandLine->parse(['command', '--option1="some_value"']);
expect($commandLine->get('option1'))->toEqual('config_value');
});