}); describe("->exists()", function () { it("returns `true` if the option exists", function () { $commandLine = new CommandLine(); $actual = $commandLine->parse(['command', '--option1', '--option2=true', '--option3=false', '--option4=0']); expect($commandLine->exists('option1'))->toBe(true); expect($commandLine->exists('option2'))->toBe(true); expect($commandLine->exists('option3'))->toBe(true); expect($commandLine->exists('option4'))->toBe(true); expect($commandLine->exists('option5'))->toBe(false); }); it("returns `true` if the option as a default value", function () { $commandLine = new CommandLine(); $commandLine->option('option1', ['type' => 'boolean']); $commandLine->option('option2', ['type' => 'boolean', 'default' => false]); expect($commandLine->exists('option1'))->toBe(false); expect($commandLine->exists('option2'))->toBe(true); }); }); describe("->cast()", function () { it("casts array", function () { $commandLine = new CommandLine(); $cast = $commandLine->cast(["some", "string", "and", 10], "string"); expect($cast)->toBeAn('array'); foreach ($cast as $c) { expect($c)->toBeA('string'); } }); it("casts boolean", function () { $commandLine = new CommandLine(); $cast = $commandLine->cast(["true", "false", "some_string", null, 10], "boolean");