Ejemplo n.º 1
0
<?php

use pho\Console\ConsoleOption;
describe('ConsoleOption', function () {
    $optInfo = array('longName' => 'testLongName', 'shortName' => 'testShortName', 'description' => 'testDescription', 'argumentName' => 'testArgumentName');
    $option = new ConsoleOption($optInfo['longName'], $optInfo['shortName'], $optInfo['description'], $optInfo['argumentName']);
    context('basic getters', function () use($option, $optInfo) {
        it('return longName', function () use($option, $optInfo) {
            expect($option->getLongName())->toBe($optInfo['longName']);
        });
        it('return shortName', function () use($option, $optInfo) {
            expect($option->getShortName())->toBe($optInfo['shortName']);
        });
        it('return description', function () use($option, $optInfo) {
            expect($option->getDescription())->toBe($optInfo['description']);
        });
        it('return argumentName', function () use($option, $optInfo) {
            expect($option->getArgumentName())->toBe($optInfo['argumentName']);
        });
        it('return value', function () use($option, $optInfo) {
            expect($option->getValue())->toBeFalse();
        });
    });
    context('acceptArguments', function () {
        it('returns true if an argument name was defined', function () {
            $option = new ConsoleOption('sname', 'lname', 'desc', 'argname');
            expect($option->acceptsArguments())->toBeTrue();
        });
        it('returns true if an argument name was not defined', function () {
            $option = new ConsoleOption('sname', 'lname', 'desc');
            expect($option->acceptsArguments())->toBeFalse();