Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.idea
vendor/
.php_cs.cache
.phpunit.result.cache
8 changes: 7 additions & 1 deletion src/Command/CommandCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace Minicli\Command;

use Assets\Command\Test\ParamsController;

class CommandCall
{
/** @var string */
Expand Down Expand Up @@ -70,7 +72,11 @@ public function hasParam($param)
*/
public function hasFlag($flag)
{
return in_array($flag, $this->flags);
if (in_array($flag, $this->flags)) {
return true;
}

return in_array('--' . $flag, $this->flags);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions tests/Feature/Command/CommandCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
$this->assertContains("--flag", $call->getFlags());
});

it('asserts flags can be obtained without "--"', function () {
$call = new CommandCall(["minicli", "help", "test", "--flag"]);

$this->assertTrue($call->hasFlag('flag'));
});

it('asserts params are correctly set', function () {
$call = new CommandCall(["minicli", "help", "test", "name=test"]);

Expand Down