Skip to content

Commit

Permalink
Split test for required option up
Browse files Browse the repository at this point in the history
Put the exception based test in its own method.
  • Loading branch information
markstory committed May 5, 2020
1 parent d9456f3 commit fb2416e
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions tests/TestCase/Console/ConsoleOptionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,11 @@ public function testAddOptionMultipleOptionsWithMultiple()
}

/**
* test adding a required option.
* test adding a required option with a default.
*
* @return void
*/
public function testAddOptionRequired()
public function testAddOptionRequiredDefaultValue()
{
$parser = new ConsoleOptionParser('test', false);
$parser
Expand All @@ -359,6 +359,24 @@ public function testAddOptionRequired()
['no-default' => 'value', 'help' => false, 'test' => 'default value'],
$result[0]
);
}

/**
* test adding a required option that is missing.
*
* @return void
*/
public function testAddOptionRequiredMissing()
{
$parser = new ConsoleOptionParser('test', false);
$parser
->addOption('test', [
'default' => 'default value',
'required' => true,
])
->addOption('no-default', [
'required' => true,
]);

$this->expectException(ConsoleException::class);
$parser->parse(['--test']);
Expand Down

0 comments on commit fb2416e

Please sign in to comment.