Exemplo n.º 1
0
<?php

namespace kahlan\spec\suite\cli;

use kahlan\cli\Args;
describe("Args", function () {
    describe("->argument()", function () {
        it("sets an argument config", function () {
            $args = new Args();
            $args->argument('argument1', ['type' => 'boolean']);
            expect($args->argument('argument1'))->toEqual(['type' => 'boolean', 'array' => false, 'value' => null, 'default' => null]);
            $arguments = $args->arguments();
            expect($arguments)->toBeAn('array');
            expect(isset($arguments['argument1']))->toBe(true);
            expect($arguments['argument1'])->toEqual(['type' => 'boolean', 'array' => false, 'value' => null, 'default' => null]);
        });
        it("gets the default config", function () {
            $args = new Args();
            expect($args->argument('argument1'))->toEqual(['type' => 'string', 'array' => false, 'value' => null, 'default' => null]);
        });
        it("sets/updates an attribute of an argument", function () {
            $args = new Args();
            $args->argument('argument1', ['type' => 'boolean']);
            expect($args->argument('argument1'))->toEqual(['type' => 'boolean', 'array' => false, 'value' => null, 'default' => null]);
            $args->argument('argument1', 'default', 'value1');
            expect($args->argument('argument1'))->toEqual(['type' => 'boolean', 'array' => false, 'value' => null, 'default' => 'value1']);
        });
    });
    describe("->parse()", function () {
        it("parses command line arguments", function () {
            $args = new Args();